Skip to content

Commit 83c82fe

Browse files
committed
Added support for Gen2 and Scale-Out.
1 parent 8beac45 commit 83c82fe

File tree

3 files changed

+126
-38
lines changed

3 files changed

+126
-38
lines changed

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

Lines changed: 90 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@
2020
################################################################################
2121
usage () {
2222
cat 1>&2 <<EOF
23-
Usage: $(basename $0) -name fileSystemName -subnetID1 subnetID1 -subnetID2 subnetID2 [-region region] [-type availability] [-size size] [-security-group-id securityGroupID] [-throughput throughput] [-endpointIPrange CIDR] [-wait]
23+
Usage: $(basename $0) -name fileSystemName -subnetID1 subnetID1 -subnetID2 subnetID2 [-region region] [-type availability] [-size size] [-security-group-id securityGroupID] [-throughput throughput] [-numberPairs numberPairs] [-endpointIPrange CIDR] [-wait]
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.
2727
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.
2929
region: Is the AWS region where the FSxN file system will reside.
30-
availability: Specifies whether the HA pair should be spread across 'single' or 'multiple' availability zones. Valid settings are 'Single' or 'Multi' (default).
31-
size: Is size, in gigabytes, you want the file system to be. Minimum and the default is 1024.
32-
throughput: Is the throughput capacity you the file system to have. Valid numbers are 128, 256, 512, 1024, 2048, and 4096. Default is 128.
30+
availability: Specifies whether the HA pair should be spread across 'single' or 'multiple' availability zones. Valid settings are 'single' or 'multi' (default).
31+
size: Is size, in gigabytes, you want the file system to be. Minimum is 1024 per number of HA pairs. Default is 1024.
32+
throughput: Is the throughput capacity you the file system to have. Valid Gen1 numbers are 128, 256, 512, 1024, 2048, and 4096. Valid Gen2 numbers are 384, 768, 1536, 3072, and 6144. Default is 128.
33+
numberPairs: Is the number of HA pairs you want the file system to have. Can only be greater than 1 with throupghput numbers of 1536, 3072, and 6144. Default is 1.
3334
CIDR: Is an address range that the system management, and data access, IPs will be allocated from. It is only allowed for multi availability zone deployments.
34-
--wait: Forces the script to wait until the file system is created before returning.
35+
-wait: Forces the script to wait until the file system is created before returning.
3536
EOF
3637
exit 1
3738
}
@@ -49,6 +50,29 @@ MaxIterations=180
4950
# Set the number of seconds to wait between checks that the file system
5051
# has been created.
5152
SleepTime=15
53+
#
54+
# Possible throughput values
55+
throughputValuesGen1=(128 256 512 1024 2048 4096)
56+
throughputValuesGen2=(384 768 1536 3072 6144)
57+
throughputValuesMultiHAPairs=(1536 3072 6144)
58+
59+
integerRegex='^[0-9]+$'
60+
61+
################################################################################
62+
# This function is used to see if the first value passed is in one of the
63+
# other parameters passed.
64+
################################################################################
65+
is_in(){
66+
67+
local value=$1
68+
shift
69+
for i in $@; do
70+
if [ $i == $value ]; then
71+
return 0
72+
fi
73+
done
74+
return 1
75+
}
5276

5377
for cmd in jq aws; do
5478
if which $cmd > /dev/null 2>&1; then
@@ -65,7 +89,8 @@ throughput=128
6589
region=$(aws configure list | egrep '^.*egion ' | awk '{print $2}')
6690
securityGroupOption=""
6791
endpointips=""
68-
azType="MULTI_AZ_1"
92+
availType=multi
93+
numPairs=1
6994
waitForCompletion=false
7095
#
7196
# Process command line arguments.
@@ -78,13 +103,10 @@ while [ ! -z "$1" ]; do
78103
shift
79104
;;
80105
-size|--size) size="$2"
81-
if ! [[ "$size" =~ '^[0-9]+$' ]]; then
106+
if ! [[ "$size" =~ $integerRegEx ]]; then
82107
echo "-size must be an integer."
83108
usage
84109
fi
85-
if [ "$size" -le 1024 ]; then
86-
usage
87-
fi
88110
shift
89111
;;
90112
-subnetid1|--subnetid1) subnetID1="$2"
@@ -97,31 +119,31 @@ while [ ! -z "$1" ]; do
97119
shift
98120
;;
99121
-type|--type)
100-
if [ "$(echo $2 | tr [A-Z] [a-z])" == "single" ]; then
101-
azType="SINGLE_AZ_1"
102-
elif [ "$(echo $2 | tr [A-Z] [a-z])" == "multi" ]; then
103-
azType="MULTI_AZ_1"
104-
else
105-
echo "Error, known availability type '$2'."
122+
availType=$2
123+
if [ $availType != "single" -a $availType != "multi" ]; then
124+
echo "-type must be 'single' or 'multi'." 1>&2
106125
usage
107126
fi
108127
shift
109128
;;
110129
-throughput|--throughput) throughput="$2"
111-
if ! [[ "$throughput" =~ '^[0-9]+$' ]]; then
130+
if ! [[ "$throughput" =~ $integerRegEx ]]; then
112131
echo "-throughput must be an integer."
113132
usage
114133
fi
115-
if [ "$througput" != "128" -a "$througput" != "256" -a "$throughput" != "512" -a "$throughput" != "1024" -a "$throughput" != "2048" -a "$throughput" != "4096" ]; then
116-
echo "-throughput must be 128 or 256 or 512 or 1024 or 2048 or 4096."
117-
usage
118-
fi
119134
shift
120135
;;
121136
-endpointiprange|--endpointiprange)
122137
endpointips='"EndpointIpAddressRange": "'$2'",'
123138
shift
124139
;;
140+
-numberpairs|--numberpairs) numPairs="$2"
141+
if ! [[ "$numPairs" =~ $integerRegEx ]]; then
142+
echo "-numPairs must be an integer."
143+
usage
144+
fi
145+
shift
146+
;;
125147
-wait|--wait)
126148
waitForCompletion=true
127149
;;
@@ -134,16 +156,39 @@ while [ ! -z "$1" ]; do
134156
esac
135157
shift
136158
done
159+
160+
if is_in "$throughput" ${throughputValuesGen1[@]}; then
161+
if [ $availType="single" ]; then
162+
azType="SINGLE_AZ_1"
163+
elif [ $availType="multi" ]; then
164+
azType="MULTI_AZ_1"
165+
else
166+
echo "Error, unknown availability type '$availType'."
167+
usage
168+
fi
169+
elif is_in "$throughput" ${throughputValuesGen2[@]}; then
170+
if [ $availType="single" ]; then
171+
azType="SINGLE_AZ_2"
172+
elif [ $availType="multi" ]; then
173+
azType="MULTI_AZ_2"
174+
else
175+
echo "Error, unknown availability type '$availType'."
176+
usage
177+
fi
178+
else
179+
echo "Error, unsupported throughput value '$throughput'."
180+
usage
181+
fi
137182
#
138183
# Ensure all the required parameters have been provided.
139-
if [ -z "$fileSystemName" -o -z "$subnetID1" -o "$azType" == "MULTI_AZ_1" -a -z "$subnetID2" ]; then
184+
if [ -z "$fileSystemName" -o -z "$subnetID1" -o "$azType" == "MULTI_AZ_1" -a -z "$subnetID2" -o "$azType" == "MULTI_AZ_2" -a -z "$subnetID2" ]; then
140185
echo "Missing arguments." 1>&2
141186
usage
142-
exit 1
143187
fi
144-
if [ $azType == "SINGLE_AZ_1" ]; then
188+
189+
if [[ $azType == *"SINGLE_AZ"* ]]; then
145190
if [ ! -z "$endpointips" ]; then
146-
echo "Error, you can not specify Endpoint IP address range when deploying in a single availability zone." 1>&2
191+
echo "Error, you cannot specify Endpoint IP address range when deploying in a single availability zone." 1>&2
147192
exit 1
148193
fi
149194

@@ -153,11 +198,30 @@ if [ $azType == "SINGLE_AZ_1" ]; then
153198
fi
154199
fi
155200

201+
if [ $numPairs -gt 1 ]; then
202+
if [ $azType != "SINGLE_AZ_2" ]; then
203+
echo "Error, you can only specify more than one HA pair with a single availability zone deployment." 1>&2
204+
usage
205+
fi
206+
207+
if ! is_in "$throughput" ${throughputValuesMultiHAPairs[@]}; then
208+
echo "Error, you can only specify more than one HA pair with throughput values of 1536, 3072, and 6144." 1>&2
209+
usage
210+
fi
211+
fi
212+
213+
minSize=$((1024*numPairs))
214+
if [ $size -lt $minSize ]; then
215+
echo "Error, the size must be at least $minSize for $numPairs HA pairs. In other words 1024 per HA pair." 1>&2
216+
usage
217+
fi
218+
156219
aws fsx create-file-system --output=json --file-system-type ONTAP --storage-capacity $size --subnet-ids $subnetID1 $subnetID2 --storage-type SSD --tags "Key=Name,Value=$fileSystemName" $securityGroupOption --ontap-configuration '{
157220
"PreferredSubnetId": "'$subnetID1'",
158221
'$endpointips'
159222
"DeploymentType": "'$azType'",
160-
"ThroughputCapacity": '$throughput'}' --region=$region > $tmpout 2>&1
223+
"HAPairs": '$numPairs',
224+
"ThroughputCapacityPerHAPair": '$throughput'}' --region=$region > $tmpout 2>&1
161225

162226
if [ $? != "0" ]; then
163227
echo "Failed to create FSxN file system." 1>&2

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

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
################################################################################
2222
usage () {
2323
cat 1>&2 <<EOF
24-
Usage: $(basename $0) -i svmID -n volumeName [-r region] [-s size] [-w]
24+
Usage: $(basename $0) -i svmID -n volumeName [-r region] [-s size] [-v volumeStyle] [-a aggregate] [-w]
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.
2828
region: is the AWS region where the FSxN filesystem resides.
2929
size: is size, in megabytes, you want the filesystem. Default is 20.
30+
volumeStyle: Is the style of the volume. Either FlexVol or FlexGroup. Default is flexvol.
31+
aggregate: is the name of the aggregate you want the volume put on. Required for FlexVol volumes on Scale-Out deployments. Default is aggr1.
3032
-w : wait for the volume to be created before returning.
3133
EOF
3234
exit 1
@@ -46,13 +48,17 @@ maxIterations=24
4648
# Set the number of seconds to wait between checks that a volume and/or SVM has been deleted.
4749
sleepTime=5
4850
#
51+
intergerRegex='^[0-9]+$'
52+
#
4953
# Set some defaults.
5054
size=20
5155
region=$(aws configure list | egrep '^.*egion ' | awk '{print $2}')
5256
waitForCompletion=false
57+
volumeStyle="flexvol"
58+
aggregateOption=""
5359
#
5460
# Process command line arguments.
55-
while getopts "hi:n:r:s:w" option; do
61+
while getopts "ha:i:n:r:s:v:w" option; do
5662
case $option in
5763
i) svmId=$OPTARG
5864
;;
@@ -61,6 +67,14 @@ while getopts "hi:n:r:s:w" option; do
6167
r) region=$OPTARG
6268
;;
6369
s) size=$OPTARG
70+
if ! [[ $size =~ $intergerRegex ]]; then
71+
echo "Error, size must be an integer." 1>&2
72+
usage
73+
fi
74+
;;
75+
v) volumeStyle=$OPTARG
76+
;;
77+
a) aggregateOption='"AggregateConfiguration":{"Aggregates":["'$OPTARG'"]},'
6478
;;
6579
w) waitForCompletion=true
6680
;;
@@ -75,15 +89,23 @@ if [ -z "$volumeName" -o -z "$svmId" ]; then
7589
usage
7690
fi
7791

78-
aws fsx create-volume --volume-type ONTAP --name $volumeName --ontap-configuration "{
79-
\"JunctionPath\": \"/$volumeName\",
80-
\"SecurityStyle\": \"UNIX\",
81-
\"SizeInMegabytes\" : $size,
82-
\"StorageEfficiencyEnabled\": true,
83-
\"StorageVirtualMachineId\": \"$svmId\",
84-
\"TieringPolicy\" : {\"CoolingPeriod\": 31, \"Name\": \"SNAPSHOT_ONLY\"},
85-
\"OntapVolumeType\": \"RW\",
86-
\"SnapshotPolicy\": \"default\"}" --region=$region --output=json > $tmpout 2>&1
92+
volumeStyle=$(echo $volumeStyle | tr '[a-z] ' '[A-Z]')
93+
if [ $volumeStyle != "FLEXVOL" -a $volumeStyle != "FLEXGROUP" ]; then
94+
echo "Error, volume style must be either FlexVol or FlexGroup." 1>&2
95+
usage
96+
fi
97+
98+
aws fsx create-volume --volume-type ONTAP --name $volumeName --ontap-configuration '{
99+
"JunctionPath": "/'$volumeName'",
100+
"SecurityStyle": "UNIX",
101+
"SizeInMegabytes" : '$size',
102+
"StorageEfficiencyEnabled": true,
103+
"StorageVirtualMachineId": "'$svmId'",
104+
"TieringPolicy" : {"CoolingPeriod": 31, "Name": "SNAPSHOT_ONLY"},
105+
"OntapVolumeType": "RW",
106+
"VolumeStyle": "'$volumeStyle'",
107+
'$aggregateOption'
108+
"SnapshotPolicy": "default"}' --region=$region --output=json > $tmpout 2>&1
87109

88110
if [ $? != "0" ]; then
89111
echo "Failed to create the FSxN volume." 1>&2
@@ -93,7 +115,7 @@ else
93115
status=$(jq -r .Volume.Lifecycle $tmpout 2> /dev/null)
94116
if [ "$status" == "CREATING" -o "$status" == "PENDING" ]; then
95117
volumeId=$(jq -r .Volume.VolumeId $tmpout)
96-
printf "FSxN volume '$volumeName'($volumeId) is being created."
118+
printf "Volume '$volumeName'($volumeId) is being created."
97119
if [ "$waitForCompletion" == "true" ]; then
98120
i=0
99121
while [ $i -lt $maxIterations ]; do

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ else
129129
exit 1
130130
fi
131131
[ $quiet != "true" ] && printf "\n"
132+
else
133+
[ $quiet != "true" ] && printf "\n"
132134
fi
133135
else
134136
echo "Unknown status '$status'. Complete output returned from the AWS api:" 1>&2

0 commit comments

Comments
 (0)