Skip to content

Commit 80c225f

Browse files
author
Don Brady
committed
DLPX-73229 iSCSI initiator name should be unique on each engine
1 parent b52e8f3 commit 80c225f

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

debian/postinst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -eux
22
#
3-
# Copyright 2018, 2019 Delphix
3+
# Copyright 2018, 2021 Delphix
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -51,6 +51,7 @@ configure)
5151
systemctl enable delphix.target
5252
systemctl enable delphix-platform.service
5353
systemctl enable systemd-networkd.service
54+
systemctl enable iscsi-name-init.service
5455

5556
if ! id -u postgres >/dev/null; then
5657
# When installing postgres, a postgres user is created unless it
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2021 by Delphix. All rights reserved.
4+
#
5+
6+
#
7+
# This script generates a unique initiator name based on the system-uuid
8+
#
9+
10+
PATH=/bin:/usr/bin/:/usr/sbin
11+
12+
NAME_FILE="/etc/iscsi/initiatorname.iscsi"
13+
AUTHORITY="2008-07.com.delphix"
14+
DMI_KEYWORD="system-uuid"
15+
16+
#
17+
# IBMcloud changes the system-uuid whenever the engine is
18+
# power-cycled but preserves the chassis-asset-tag-uuid. For that
19+
# cloud we use that property to obtain a UUID.
20+
#
21+
if [[ "$(dmidecode -s chassis-asset-tag)" == "ibmcloud" ]]; then
22+
DMI_KEYWORD="baseboard-asset-tag"
23+
fi
24+
25+
system_uuid=$(dmidecode -s $DMI_KEYWORD | awk '{print tolower($0)}')
26+
27+
if [[ -f $NAME_FILE ]]; then
28+
if [[ ${#system_uuid} -ne 36 ]]; then
29+
echo "Error: unexpected UUID -- $system_uuid" >&2
30+
exit 1
31+
fi
32+
33+
name_entry="InitiatorName=iqn.$AUTHORITY:$system_uuid"
34+
35+
#
36+
# Generate IQN for this Delphix Engine (if not already present)
37+
#
38+
if ! grep -Gq "^$name_entry" $NAME_FILE; then
39+
{
40+
echo "## DO NOT EDIT OR REMOVE THIS FILE!"
41+
echo "## If you remove this file, the iSCSI daemon will not start."
42+
echo "## If you change the InitiatorName, existing access control lists"
43+
echo "## may reject this initiator. The InitiatorName must be unique"
44+
echo "## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames."
45+
printf '%s\n' "$name_entry"
46+
} >$NAME_FILE
47+
chmod 640 $NAME_FILE
48+
echo "Generating unique iSCSI name using UUID $system_uuid"
49+
fi
50+
fi
51+
52+
exit 0
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Copyright 2021 Delphix
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
[Unit]
18+
Description=One time IQN configuration for iscsid.service
19+
Before=open-iscsi.service
20+
21+
[Service]
22+
Type=oneshot
23+
RemainAfterExit=no
24+
ExecStart=/lib/open-iscsi/unique-name-check.sh
25+
26+
[Install]
27+
WantedBy=open-iscsi.service

0 commit comments

Comments
 (0)