Skip to content

Commit 1c13f93

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

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-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: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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 Delphix Engine UUID
8+
#
9+
10+
PATH=/bin
11+
12+
EIDFILE="/etc/engine-uuid"
13+
BOSMGMT="/opt/delphix/server/bin/bos_mgmt"
14+
NAMEFILE="/etc/iscsi/initiatorname.iscsi"
15+
AUTHORITY="2008-07.com.delphix"
16+
17+
#
18+
# Consult bos_mgmt, if available, since it will return the updated Engine UUID
19+
# after a VM is cloned whereas '/etc/engine-uuid' isn't updated until after the
20+
# management stack is started.
21+
#
22+
if [[ -f $BOSMGMT ]]; then
23+
ENGINEID=$($BOSMGMT get_system_uuid appliance)
24+
elif [[ -f $EIDFILE ]]; then
25+
ENGINEID=$(<$EIDFILE)
26+
else
27+
exit 0
28+
fi
29+
30+
if [[ -f $NAMEFILE ]]; then
31+
if [[ ${#ENGINEID} -ne 36 ]]; then
32+
echo "Error: unexpected UUID -- $ENGINEID" >&2
33+
exit 1
34+
fi
35+
36+
NAMEENTRY="InitiatorName=iqn.$AUTHORITY:$ENGINEID"
37+
38+
#
39+
# Generate IQN for this Delphix Engine (if not already present)
40+
#
41+
if ! grep -Gq "^$NAMEENTRY" $NAMEFILE; then
42+
{
43+
echo "## DO NOT EDIT OR REMOVE THIS FILE!"
44+
echo "## If you remove this file, the iSCSI daemon will not start."
45+
echo "## If you change the InitiatorName, existing access control lists"
46+
echo "## may reject this initiator. The InitiatorName must be unique"
47+
echo "## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames."
48+
printf '%s\n' "$NAMEENTRY"
49+
} >$NAMEFILE
50+
chmod 640 $NAMEFILE
51+
echo "Generating unique iSCSI name for engine $ENGINEID"
52+
fi
53+
fi
54+
55+
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)