Skip to content

Commit 1716caf

Browse files
committed
Added endpoint support.
1 parent 79c2225 commit 1716caf

9 files changed

Lines changed: 133 additions & 111 deletions

File tree

Management-Utilities/fsx-ontap-aws-cli-scripts/create_fsxn_filesystem

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ Usage: $(basename $0) -name fileSystemName -subnetID1 subnetID1 -subnetID2 subne
2424
where
2525
fileSystemName: Is the name you want to assign the file system.
2626
subnetID1: Is the subnet ID of the preferred subnet you want the file system to be accessible from.
27-
subnetID2: Is the subnet ID of the standby subnet you want the file system to be accessible from. Only allowed for multi availability zone deployments.
27+
subnetID2: Is the subnet ID of the standby subnet you want the file system to be accessible from. Only allowed for multi-availability zone deployments.
2828
security-group-id: Is the security ID that you want applied to the ENIs that are assigned to the file system.
29-
route_table_ids: is a comma separated list of route table ids you want updated with the floating IPs from the file system. Only useful for multi available zone deployments.
29+
route_table_ids: is a comma separated list of route table ids you want updated with the floating IPs from the file system. Only useful for multi-availability zone deployments.
3030
region: Is the AWS region where the FSxN file system will reside.
3131
availability: Specifies whether the HA pair should be spread across 'single' or 'multiple' availability zones. Valid settings are 'single' or 'multi' (default).
3232
size: Is size, in gigabytes, you want the file system to be. Minimum is 1024 per number of HA pairs. Default is 1024.
@@ -121,7 +121,7 @@ while [ ! -z "$1" ]; do
121121
-security-group-id|--security-group-id) securityGroupOption="--security-group-ids $2"
122122
shift
123123
;;
124-
-route-tables|--route-tables) routeTables='"RouteTableIds":"'$2'",'
124+
-route-tables|--route-tables) routeTables='"RouteTableIds":["'$(echo "$2" | sed -e 's/,/","/g')'"],'
125125
shift
126126
;;
127127
-type|--type)

Management-Utilities/fsx-ontap-aws-cli-scripts/create_fsxn_svm

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
################################################################################
2222
usage () {
2323
cat 1>&2 <<EOF
24-
Usage: $(basename $0) -n svmName [-f fileSystemName] [-i fileSystemId] [-r region] [-w]
24+
Usage: $(basename $0) -n svmName [-f fileSystemName] [-i fileSystemId] [-r region] [-w] [-e endpoint_url]
2525
Where:
2626
svmName: Is the name you want to assign the storage virtual machine.
2727
fileSystemName: Is the name of the FSxN file system where you want the SVM created. This option is mutually exclusive with the -i option.
2828
fileSystemID: Is the file system ID where you want to create the SVM on. This option is mutually exclusive with the -f option.
2929
region: Is the AWS region where the FSxN file system resides.
3030
-w : Wait for the SVM to be created before returning.
31+
endpoint_url: Is the endpoint url to use when connecting to the AWS API.
3132
EOF
3233
exit 1
3334
}
@@ -52,7 +53,7 @@ maxIterations=24
5253
sleepTime=5
5354
#
5455
# Process command line arguments.
55-
while getopts "hwn:r:f:i:" option; do
56+
while getopts "hwn:r:f:i:e:" option; do
5657
case $option in
5758
n) svmName=$OPTARG
5859
;;
@@ -64,6 +65,8 @@ while getopts "hwn:r:f:i:" option; do
6465
;;
6566
w) waitForCompletion=true
6667
;;
68+
e) endpoint_url="--endpoint-url $OPTARG"
69+
;;
6770
*) usage
6871
;;
6972
esac
@@ -82,7 +85,7 @@ fi
8285
#
8386
# Get the file system id from the file system name.
8487
if [ -z "$fsid" ]; then
85-
fsid=$(aws fsx describe-file-systems --region $region --output=json 2> /dev/null | jq -r ".FileSystems[] | if((.Tags[] | select(.Key == \"Name\") .Value) == \"${fileSystemName}\") then .FileSystemId else empty end" 2> /dev/null)
88+
fsid=$(aws fsx describe-file-systems $endpoint_url --region $region --output=json 2> /dev/null | jq -r ".FileSystems[] | if((.Tags[] | select(.Key == \"Name\") .Value) == \"${fileSystemName}\") then .FileSystemId else empty end" 2> /dev/null)
8689
fi
8790

8891
if [ -z "$fsid" ]; then
@@ -91,7 +94,7 @@ if [ -z "$fsid" ]; then
9194
fi
9295
#
9396
# Create the SVM
94-
aws fsx create-storage-virtual-machine --name $svmName --region=$region --file-system-id "$fsid" --output=json > $tmpout 2>&1
97+
aws fsx create-storage-virtual-machine $endpoint_url --name $svmName --region=$region --file-system-id "$fsid" --output=json > $tmpout 2>&1
9598

9699
if [ $? != "0" ]; then
97100
echo "Failed to create storage virtual machine." 1>&2
@@ -107,7 +110,7 @@ else
107110
if [ $waitForCompletion == true ]; then
108111
i=0
109112
while [ $i -lt $maxIterations ]; do
110-
aws fsx describe-storage-virtual-machines --storage-virtual-machine-ids $svmId --output=json --region=$region > $tmpout 2>&1
113+
aws fsx describe-storage-virtual-machines $endpoint_url --storage-virtual-machine-ids $svmId --output=json --region=$region > $tmpout 2>&1
111114
if [ $? -eq 0 ]; then
112115
status=$(jq -r '.StorageVirtualMachines[0].Lifecycle' $tmpout 2> /dev/null)
113116
if [ "$status" == "CREATED" ]; then

Management-Utilities/fsx-ontap-aws-cli-scripts/create_fsxn_volume

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
################################################################################
2222
usage () {
2323
cat 1>&2 <<EOF
24-
Usage: $(basename $0) -i svmID -n volumeName [-r region] [-s size] [-v volumeStyle] [-a aggregate] [-w]
24+
Usage: $(basename $0) -i svmID -n volumeName [-r region] [-s size] [-v volumeStyle] [-a aggregate] [-w] [-e endpoint_url]
2525
where
2626
svmID: is the SVM ID in the filesystem you want to create the volume.
2727
volumeName: is the name you want to assign the volume.
@@ -30,6 +30,7 @@ where
3030
volumeStyle: Is the style of the volume. Either FlexVol or FlexGroup. Default is flexvol.
3131
aggregate: is the name of the aggregate you want the volume put on. Required for FlexVol volumes on Scale-Out deployments. Default is aggr1.
3232
-w : wait for the volume to be created before returning.
33+
endpoint_url: Is the endpoint url to use when connecting to the AWS API.
3334
EOF
3435
exit 1
3536
}
@@ -58,28 +59,22 @@ volumeStyle="flexvol"
5859
aggregateOption=""
5960
#
6061
# Process command line arguments.
61-
while getopts "ha:i:n:r:s:v:w" option; do
62+
while getopts "ha:i:n:r:s:v:we:" option; do
6263
case $option in
63-
i) svmId=$OPTARG
64-
;;
65-
n) volumeName=$OPTARG
66-
;;
67-
r) region=$OPTARG
68-
;;
64+
i) svmId=$OPTARG ;;
65+
n) volumeName=$OPTARG ;;
66+
r) region=$OPTARG ;;
67+
e) endpoint_url="--endpoint-url $OPTARG" ;;
6968
s) size=$OPTARG
7069
if ! [[ $size =~ $intergerRegex ]]; then
7170
echo "Error, size must be an integer." 1>&2
7271
usage
7372
fi
7473
;;
75-
v) volumeStyle=$OPTARG
76-
;;
77-
a) aggregateOption='"AggregateConfiguration":{"Aggregates":["'$OPTARG'"]},'
78-
;;
79-
w) waitForCompletion=true
80-
;;
81-
*) usage
82-
;;
74+
v) volumeStyle=$OPTARG ;;
75+
a) aggregateOption='"AggregateConfiguration":{"Aggregates":["'$OPTARG'"]},' ;;
76+
w) waitForCompletion=true ;;
77+
*) usage ;;
8378
esac
8479
done
8580
#
@@ -95,7 +90,7 @@ if [ $volumeStyle != "FLEXVOL" -a $volumeStyle != "FLEXGROUP" ]; then
9590
usage
9691
fi
9792

98-
aws fsx create-volume --volume-type ONTAP --name $volumeName --ontap-configuration '{
93+
aws fsx create-volume --volume-type ONTAP $endpoint_url --name $volumeName --ontap-configuration '{
9994
"JunctionPath": "/'$volumeName'",
10095
"SecurityStyle": "UNIX",
10196
"SizeInMegabytes" : '$size',
@@ -119,7 +114,7 @@ else
119114
if [ "$waitForCompletion" == "true" ]; then
120115
i=0
121116
while [ $i -lt $maxIterations ]; do
122-
aws fsx describe-volumes --volume-ids $volumeId --region=$region --output=json > $tmpout 2>&1
117+
aws fsx describe-volumes $endpoint_url --volume-ids $volumeId --region=$region --output=json > $tmpout 2>&1
123118
status=$(jq -r .Volumes[0].Lifecycle $tmpout 2> /dev/null)
124119
if [ $status == "CREATED" ]; then
125120
printf "\nVolume '$volumeName'($volumeId) has been created.\n"

Management-Utilities/fsx-ontap-aws-cli-scripts/delete_fsxn_filesystem

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
################################################################################
2828
usage () {
2929
cat 1>&2 <<EOF
30-
Usage: $(basename $0) [-f fileSystemName] [-r region] [-i fileSystemID] [-b] [-w]
30+
Usage: $(basename $0) [-f fileSystemName] [-r region] [-i fileSystemID] [-b] [-w] [-e endpoint_url]
3131
Where:
3232
fileSystemName: Is the name of the file system you want to delete. This option is mutually exclusive to the -i option.
3333
fileSystemID: Is the file system id of the file system you want to delete. This option is mutually exclusive to the -f option.
3434
region: Is the AWS region where the FSxN filesystem resides.
3535
-b: enable final backup. Otherwise, it is skipped.
3636
-w: Wait for the file system to be deleted before returning.
37+
endpoint_url: Is the endpoint url to use when connecting to the AWS API.
3738
EOF
3839
exit 1
3940
}
@@ -88,7 +89,7 @@ enableBackup=false
8889
waitForCompletion=false
8990
#
9091
# Process command line arguments.
91-
while getopts "hwbr:f:i:" option; do
92+
while getopts "hwbr:f:i:e:" option; do
9293
case $option in
9394
f) fileSystemName=$OPTARG
9495
;;
@@ -100,6 +101,9 @@ while getopts "hwbr:f:i:" option; do
100101
;;
101102
w) waitForCompletion=true
102103
;;
104+
e) endpoint_url="--endpoint-url $OPTARG"
105+
endpoint_arg="-e $OPTARG"
106+
;;
103107
*) usage
104108
;;
105109
esac
@@ -124,7 +128,7 @@ fi
124128
#
125129
# Get the file system id based on the name.
126130
if [ -z "$fsid" ]; then
127-
fsid=($(aws fsx describe-file-systems --region=$region --output=json 2> $tmpout | jq -r '.FileSystems[] | if((.Tags[] | select(.Key == "Name") .Value) == "'"${fileSystemName}"'") then .FileSystemId else empty end' 2> /dev/null))
131+
fsid=($(aws fsx describe-file-systems $endpoint_url --region=$region --output=json 2> $tmpout | jq -r '.FileSystems[] | if((.Tags[] | select(.Key == "Name") .Value) == "'"${fileSystemName}"'") then .FileSystemId else empty end' 2> /dev/null))
128132

129133
if [ ${#fsid[*]} -gt 1 ]; then
130134
echo "Error, more than one file system matched the file system name '$fileSystemName'." 1>&2
@@ -140,7 +144,7 @@ if [ -z "$fsid" ]; then
140144
else
141145
#
142146
# Get the file system name based on the fsid.
143-
aws fsx describe-file-systems --file-system-ids $fsid --region=$region --output=json > $tmpout 2>&1
147+
aws fsx describe-file-systems $endpoint_url --file-system-ids $fsid --region=$region --output=json > $tmpout 2>&1
144148
if [ $? -ne 0 ]; then
145149
echo "Error, failed to get the file system name based on the ID ($fsid)." 1>&2
146150
cat $tmpout 1>&2
@@ -155,15 +159,15 @@ else
155159
fi
156160
#
157161
# Create a JSON file with all the SVMs associated with the file system.
158-
aws fsx describe-storage-virtual-machines --region=$region --output=json --filters Name=file-system-id,Values=$fsid > $svmsFile 2>&1
162+
aws fsx describe-storage-virtual-machines $endpoint_url --region=$region --output=json --filters Name=file-system-id,Values=$fsid > $svmsFile 2>&1
159163
if [ $? -ne 0 ]; then
160164
echo "Error, failed to get the list of SVMs." 1>&2
161165
cat $svmsFile 1>&2
162166
exit 1
163167
fi
164168
#
165169
# Create a JSON file with all the FSXN volumes associated with the file system.
166-
aws fsx describe-volumes --region=$region --output=json --filters Name=file-system-id,Values=$fsid > $volumesFile 2>&1
170+
aws fsx describe-volumes --region=$region $endpoint_url --output=json --filters Name=file-system-id,Values=$fsid > $volumesFile 2>&1
167171
if [ $? -ne 0 ]; then
168172
echo "Error, failed to get the list of volumes." 1>&2
169173
cat $volumesFile 1>&2
@@ -188,15 +192,15 @@ svms=($(jq -r '.StorageVirtualMachines[] | select(.FileSystemId == "'$fsId'") |
188192
#
189193
# First delete all the SVMs. The 'delete_fsxn_svm' script will delete all the volumes associated with the SVM.
190194
for svmId in ${svms[*]}; do
191-
delete_fsxn_svm -n -w $enableBackup -i $svmId -r $region
195+
delete_fsxn_svm -n -w $enableBackup -i $svmId -r $region $endpoint_arg
192196
if [ $? -ne 0 ]; then
193197
echo "Error, failed to delete the SVM with SVM ID '$svmId'." 1>&2
194198
exit 1
195199
fi
196200
done
197201
#
198202
# Now that all the volumes and all the SVMs have been deleted, we can delete the filesystem.
199-
aws fsx delete-file-system --file-system-id $fsid --output=json --region=$region > $tmpout 2>&1
203+
aws fsx delete-file-system $endpoint_url --file-system-id $fsid --output=json --region=$region > $tmpout 2>&1
200204
if [ $? != "0" ]; then
201205
printf "\nError, failed to delete file system.\n" 1>&2
202206
cat $tmpout 1>&2
@@ -208,7 +212,7 @@ else
208212
if [ $waitForCompletion == "true" ]; then
209213
i=0
210214
while [ $i -lt $MaxIterations ]; do
211-
aws fsx describe-file-systems --file-system-ids $fsid --output=json --region=$region > $tmpout 2>&1
215+
aws fsx describe-file-systems $endpoint_url --file-system-ids $fsid --output=json --region=$region > $tmpout 2>&1
212216
if [ $? -eq 0 ]; then
213217
status=$(jq -r '.FileSystems[0].Lifecycle' $tmpout 2> /dev/null)
214218
if [ "$status" != "DELETING" -a "$status" != "PENDING" ]; then

Management-Utilities/fsx-ontap-aws-cli-scripts/delete_fsxn_svm

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@
2323
################################################################################
2424
usage () {
2525
cat 1>&2 <<EOF
26-
Usage: $(basename $0) -i svmID [-r region] [-w] [-n] [-b]
26+
Usage: $(basename $0) -i svmID [-r region] [-w] [-n] [-b] [-e endpoint_url]
2727
Where:
2828
svmID: Is the ID of the storage virtual machine you want to delete.
2929
region: Is the AWS region where the SVM resides.
3030
-w: Wait for the delete to complete before returning.
3131
-n: No query. Do not ask for confirmation before deleting the SVM.
3232
-b: Enable final backup of the volumes before deleting the volumes. Otherwise, the volumes are deleted without a backup.
33+
endpoint_url: Is the endpoint url to use when connecting to the AWS API.
3334
EOF
3435
exit 1
3536
}
@@ -57,7 +58,7 @@ noQuery=false
5758
enableBackup=false
5859
#
5960
# Process command line arguments.
60-
while getopts "hbi:wnr:" option; do
61+
while getopts "hbi:wnr:e:" option; do
6162
case $option in
6263
i) svmID=$OPTARG
6364
;;
@@ -69,6 +70,9 @@ while getopts "hbi:wnr:" option; do
6970
;;
7071
b) enableBackup=true
7172
;;
73+
e) endpoint_url="--endpoint-url $OPTARG"
74+
endpoint_arg="-e $OPTARG"
75+
;;
7276
*) usage
7377
;;
7478
esac
@@ -98,7 +102,7 @@ MaxIterations=120
98102
SleepTime=5
99103
#
100104
# Get the list of volumes associated with the SVM.
101-
aws fsx describe-volumes --region=$region --output=json --filters Name=storage-virtual-machine-id,Values=$svmID > $volumesFile 2>&1
105+
aws fsx describe-volumes $endpoint_url --region=$region --output=json --filters Name=storage-virtual-machine-id,Values=$svmID > $volumesFile 2>&1
102106
if [ $? -ne 0 ]; then
103107
echo "Error, failed to get the list of volumes for SVM: $svmID." 1>&2
104108
cat $volumesFile 1>&2
@@ -144,7 +148,7 @@ if [ ! -z "${volumes[*]}" ]; then
144148
maxNumRunning=1 # Only do one initially, if it completes successfully, then do the rest concurrently.
145149
printf "\nDeleting all the volumes associated with ${svmID}.\n"
146150
while [ $i -lt $numVolumes ]; do
147-
delete_fsxn_volume -r $region -w -q -i ${volumes[$i]} $enableBackup &
151+
delete_fsxn_volume -r $region -w -q -i ${volumes[$i]} $enableBackup $endpoint_arg &
148152
let i+=1
149153
let numRunning+=1
150154
printf "\rTotal number of volumes to delete: ${numVolumes}. Number of deletes currently running: ${numRunning}. Number waiting to be started: $((numVolumes-i)). "
@@ -189,7 +193,7 @@ if [ ! -z "${volumes[*]}" ]; then
189193
fi
190194
#
191195
# Now that all the volumes have been deleted, delete the storage virtual machine.
192-
aws fsx delete-storage-virtual-machine --region=$region --storage-virtual-machine-id $svmID > $tmpout 2>&1
196+
aws fsx delete-storage-virtual-machine $endpoint_url --region=$region --storage-virtual-machine-id $svmID > $tmpout 2>&1
193197

194198
if [ $? != "0" ]; then
195199
echo "Failed to delete storage virtual machine." 1>&2
@@ -204,7 +208,7 @@ else
204208
if [ $waitForDelete == "true" ]; then
205209
i=0
206210
while [ $i -lt $MaxIterations ]; do
207-
aws fsx describe-storage-virtual-machines --storage-virtual-machine-ids $svmID --output=json --region=$region > $tmpout 2>&1
211+
aws fsx describe-storage-virtual-machines $endpoint_url --storage-virtual-machine-ids $svmID --output=json --region=$region > $tmpout 2>&1
208212
if [ $? -eq 0 ]; then
209213
status=$(jq -r '.StorageVirtualMachines[0].Lifecycle' $tmpout 2> /dev/null)
210214
if [ "$status" != "DELETING" -a "$status" != "PENDING" ]; then

Management-Utilities/fsx-ontap-aws-cli-scripts/delete_fsxn_volume

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
################################################################################
2121
usage () {
2222
cat 1>&2 <<EOF
23-
Usage: $(basename $0) -i volumeID [-r region] [-b] [-w]
23+
Usage: $(basename $0) -i volumeID [-r region] [-b] [-w] [-e endpoint_url]
2424
where
2525
volumeID: is the ID of the volume to delete.
2626
region: is the AWS region where the FSxN filesystem resides.
2727
-b: enable final backup. Otherwise it is skipped.
2828
-w: wait for the volume to be deleted before returning.
29+
endpoint_url: Is the endpoint url to use when connecting to the AWS API.
2930
EOF
3031
exit 1
3132
}
@@ -44,7 +45,7 @@ waitForS3ApDelete () {
4445
# Wait for the s3ap to be deleted.
4546
i=0
4647
while [ $i -lt $MaxIterations ]; do
47-
aws fsx describe-s3-access-point-attachments --names $s3ApName --output=json --region=$region > $tmpout 2>&1
48+
aws fsx describe-s3-access-point-attachments $endpoint_url --names $s3ApName --output=json --region=$region > $tmpout 2>&1
4849
if [ $? -eq 0 ]; then
4950
status=$(jq -r .S3AccessPointAttachments[0].Lifecycle $tmpout 2> /dev/null)
5051
if [ "$status" != "DELETING" -a "$status" != "PENDING" ]; then
@@ -84,7 +85,7 @@ waitForVolumeDelete () {
8485
# Wait for the volume to be deleted.
8586
i=0
8687
while [ $i -lt $MaxIterations ]; do
87-
aws fsx describe-volumes --volume-ids $volumeId --output=json --region=$region > $tmpout 2>&1
88+
aws fsx describe-volumes $endpoint_url --volume-ids $volumeId --output=json --region=$region > $tmpout 2>&1
8889
if [ $? -eq 0 ]; then
8990
status=$(jq -r .Volumes[0].Lifecycle $tmpout 2> /dev/null)
9091
if [ "$status" != "DELETING" -a "$status" != "PENDING" ]; then
@@ -125,7 +126,7 @@ waitForCompletion=false
125126
quiet=false
126127
#
127128
# Process command line arguments.
128-
while getopts "qhwbi:r:" option; do
129+
while getopts "qhwbi:r:e:" option; do
129130
case $option in
130131
r) region="$OPTARG"
131132
;;
@@ -137,6 +138,8 @@ while getopts "qhwbi:r:" option; do
137138
;;
138139
q) quiet=true
139140
;;
141+
e) endpoint_url="--endpoint-url $OPTARG"
142+
;;
140143
*) usage
141144
;;
142145
esac
@@ -155,11 +158,11 @@ if [ -z "$volumeId" ]; then
155158
usage
156159
fi
157160

158-
aws fsx describe-s3-access-point-attachments --filter "Name=volume-id,Values=$volumeId" --region=$region --output=json > $tmpout 2>&1
161+
aws fsx describe-s3-access-point-attachments $endpoint_url --filter "Name=volume-id,Values=$volumeId" --region=$region --output=json > $tmpout 2>&1
159162
if [ "$(jq -r '.S3AccessPointAttachments | length' $tmpout 2>&1)" != "0" ]; then
160163
while read s3apName; do
161164
[ $quiet != "true" ] && printf "S3 Access Point '$s3apName' is being deleted." 1>&2
162-
aws fsx detach-and-delete-s3-access-point --name $s3apName --region=$region --output=json > $tmpout 2>&1
165+
aws fsx detach-and-delete-s3-access-point $endpoint_url --name $s3apName --region=$region --output=json > $tmpout 2>&1
163166
if waitForS3ApDelete $s3apName $volumeId; then
164167
:
165168
else
@@ -169,7 +172,7 @@ if [ "$(jq -r '.S3AccessPointAttachments | length' $tmpout 2>&1)" != "0" ]; then
169172
done < <(jq -r '.S3AccessPointAttachments[] | .S3AccessPoint.ResourceARN | split("/")[1]' $tmpout 2>/dev/null)
170173
fi
171174

172-
aws fsx delete-volume --volume-id $volumeId --region=$region --output=json --ontap-configuration '{"SkipFinalBackup": '$skipBackup'}' --output=json > $tmpout 2>&1
175+
aws fsx delete-volume $endpoint_url --volume-id $volumeId --region=$region --output=json --ontap-configuration '{"SkipFinalBackup": '$skipBackup'}' --output=json > $tmpout 2>&1
173176

174177
if [ $? != "0" ]; then
175178
echo "Failed to delete volume." 1>&2

0 commit comments

Comments
 (0)