Skip to content

Commit 2f333a9

Browse files
authored
Update linux_userData.sh
remove test file change vol size to be without unit
1 parent fe19660 commit 2f333a9

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Management-Utilities/ec2-user-data-iscsi-create-and-mount/linux_userData.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ FSXN_ADMIN_IP=[Fsx admin ip, e.g. 172.25.45.32]
99
# Volume name
1010
VOLUME_NAME=[Fsx volume name, e.g. iscsiVol]
1111
# Volume size in GB
12-
VOLUME_SIZE=[volume size in GB, e.g 100g]
12+
VOLUME_SIZE=[volume size in GB, e.g 100]
1313
# Default value is fsx, but you can change it to any other value according to yours FSx for ONTAP SVM name
1414
SVM_NAME=fsx
1515
# Default value is fsxadmin, but you can change it to any other value according to yours FSx for ONTAP admin user name
@@ -146,15 +146,15 @@ else
146146
./uninstall.sh
147147
fi
148148

149-
commandDescription="Create volume for vserver: ${SVM_NAME} volume name: ${VOLUME_NAME} and size: ${VOLUME_SIZE}"
149+
commandDescription="Create volume for vserver: ${SVM_NAME} volume name: ${VOLUME_NAME} and size: ${VOLUME_SIZE}g"
150150
logMessage "${commandDescription}"
151-
sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "volume create -vserver $SVM_NAME -volume $VOLUME_NAME -aggregate aggr1 -size $VOLUME_SIZE -state online"
151+
sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "volume create -vserver ${SVM_NAME} -volume ${VOLUME_NAME} -aggregate aggr1 -size ${VOLUME_SIZE}g -state online"
152152
checkCommand "${commandDescription}"
153153
addUndoCommand "sshpass -p ${FSXN_PASSWORD} ssh -o StrictHostKeyChecking=no ${ONTAP_USER}@${FSXN_ADMIN_IP} volume delete -vserver ${SVM_NAME} -volume ${VOLUME_NAME} -force"
154154

155155
commandDescription="Create iscsi lun for vserver: ${SVM_NAME} volume name: ${VOLUME_NAME} and lun name: ${LUN_NAME} and size: ${LUN_SIZE}g which is 90% of the volume size"
156156
logMessage "${commandDescription}"
157-
sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "lun create -vserver $SVM_NAME -path /vol/$VOLUME_NAME/$LUN_NAME -size "${LUN_SIZE}g" -ostype linux -space-allocation enabled"
157+
sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "lun create -vserver ${SVM_NAME} -path /vol/${VOLUME_NAME}/$LUN_NAME -size ${LUN_SIZE}g -ostype linux -space-allocation enabled"
158158
checkCommand "${commandDescription}"
159159
addUndoCommand "sshpass -p ${FSXN_PASSWORD} ssh -o StrictHostKeyChecking=no ${ONTAP_USER}@${FSXN_ADMIN_IP} lun delete -vserver ${SVM_NAME} -path /vol/${VOLUME_NAME}/${LUN_NAME} -force"
160160

@@ -164,12 +164,12 @@ addUndoCommand "sshpass -p ${FSXN_PASSWORD} ssh -o StrictHostKeyChecking=no ${ON
164164
commandDescription="Create a mapping from the LUN you created to the igroup you created"
165165
logMessage "${commandDescription}"
166166
lun_id=0
167-
sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "lun mapping create -vserver $SVM_NAME -path /vol/$VOLUME_NAME/$LUN_NAME -igroup $groupName -lun-id 0"
167+
sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "lun mapping create -vserver ${SVM_NAME} -path /vol/${VOLUME_NAME}/${LUN_NAME} -igroup ${groupName} -lun-id 0"
168168
checkCommand "${commandDescription}"
169169

170170
commandDescription="Validate the lun mapping was created"
171171
logMessage "${commandDescription}"
172-
serialHex=$(sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "lun show -path /vol/$VOLUME_NAME/$LUN_NAME -fields state,mapped,serial-hex" | grep $SVM_NAME | awk '{print $3}')
172+
serialHex=$(sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "lun show -path /vol/${VOLUME_NAME}/${LUN_NAME} -fields state,mapped,serial-hex" | grep $SVM_NAME | awk '{print $3}')
173173
if [ -n "$serialHex" ]; then
174174
logMessage "Lun mapping was created"
175175
else
@@ -180,8 +180,8 @@ fi
180180
# The serail hex in needed for creating readable name for the block device.
181181
commandDescription="Get the iscsi interface addresses for the svm ${SVM_NAME}"
182182
logMessage "${commandDescription}"
183-
iscsi1IP=$(sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "network interface show -vserver $SVM_NAME" | grep -e iscsi_1 | awk '{print $3}')
184-
iscsi2IP=$(sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "network interface show -vserver $SVM_NAME" | grep -e iscsi_2 | awk '{print $3}')
183+
iscsi1IP=$(sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "network interface show -vserver ${SVM_NAME}" | grep -e iscsi_1 | awk '{print $3}')
184+
iscsi2IP=$(sshpass -p $FSXN_PASSWORD ssh -o StrictHostKeyChecking=no $ONTAP_USER@$FSXN_ADMIN_IP "network interface show -vserver ${SVM_NAME}" | grep -e iscsi_2 | awk '{print $3}')
185185

186186
if [ -n "$i$iscsi1IP" ] && [ -n "$iscsi2IP" ]; then
187187
iscsi1IP=$(echo ${iscsi1IP%/*})
@@ -197,8 +197,8 @@ commandDescription="Discover the target iSCSI nodes, iscsi IP: ${iscsi1IP}"
197197
logMessage "${commandDescription}"
198198
iscsiadm --mode discovery --op update --type sendtargets --portal $iscsi1IP
199199
checkCommand "${commandDescription}"
200-
addUndoCommand "iscsiadm --mode discovery --op delete --type sendtargets --portal $iscsi1IP"
201-
addUndoCommand "iscsiadm --mode discovery --op delete --type sendtargets --portal $iscsi2IP"
200+
addUndoCommand "iscsiadm --mode discovery --op delete --type sendtargets --portal ${iscsi1IP}"
201+
addUndoCommand "iscsiadm --mode discovery --op delete --type sendtargets --portal ${iscsi2IP}"
202202

203203
logMessage "Getting target initiator"
204204
targetInitiator=$(iscsiadm --mode discovery --op update --type sendtargets --portal $iscsi1IP | awk '{print $2}' | head -n 1)
@@ -302,7 +302,7 @@ chown $username:$username /$directory_path/$mount_point
302302
# verify read write
303303
# example: echo "test mount iscsci" > /mnt/myIscsi/testIscsi.txt
304304
echo "test mount iscsci" > /$directory_path/$mount_point/testIscsi.txt
305-
cat /$directory_path/$mount_point/testIscsci.txt
305+
cat /$directory_path/$mount_point/testIscsi.txt
306306
rm /$directory_path/$mount_point/testIscsi.txt
307307

308308
logMessage "Mounting the FSXn iSCSI volume was successful."

0 commit comments

Comments
 (0)