Skip to content

Commit 4662747

Browse files
authored
Merge branch 'main' into add_cf_to_auto_alarm
2 parents 39e4af0 + eb8b6e5 commit 4662747

File tree

12 files changed

+661
-309
lines changed

12 files changed

+661
-309
lines changed

.github/CODEOWNERS

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# Set a "catch-all" owner. Should be set to the current active admin for the repo.
3+
* @kcantrel
4+
#
5+
# Set the owner for all the individual samples, if the owner is known and they want to continue to maintain the sample:
6+
/AI/GenAI-ChatBot-application-sample/ @cbenbass
7+
/CloudFormation/deploy-fsx-ontap/ @kcantrel
8+
/EKS/FSxN-as-PVC-for-EKS/ @mickeysh
9+
/Management-Utilities/auto_create_sm_relationships/ @kcantrel
10+
/Management-Utilities/auto_set_fsxn_auto_grow/ @kcantrel
11+
/Management-Utilities/fsx-ontap-aws-cli-scripts/ @kcantrel
12+
/Management-Utilities/fsxn-rotate-secret/ @kcantrel
13+
/Management-Utilities/warm_performance_tier/ @kcantrel
14+
/Monitoring/CloudWatch-FSx/ @LirazRom10
15+
/Monitoring/LUN-monitoring/ @LirazRom10
16+
/Monitoring/auto-add-cw-alarms/ @kcantrel
17+
/Monitoring/monitor-ontap-services/ @kcantrel
18+
/Terraform/deploy-fsx-ontap-sqlserver/ @varunrai
19+
/Terraform/deploy-fsx-ontap-fileshare-access/ @varunrai
20+
/Terraform/deploy-fsx-ontap/ @kcantrel

Management-Utilities/fsx-ontap-aws-cli-scripts/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ Before running the UNIX based scripts, make sure the following package is instal
1414

1515
| Script | Description |
1616
|:------------------------|:----------------|
17-
|create_fsxn_filesystem | Creates a new FSx for NetApp ONTAP file-system |
18-
|create_fsxn_svm | Creates a new Storage Virtual Server (svm) in a soecific FSx ONTAP filesystem |
17+
|create_fsxn_filesystem | Creates a new FSx for NetApp ONTAP file system. |
18+
|create_fsxn_svm | Creates a new Storage Virtual Server (SVM) in a specified FSx for ONTAP file system. |
1919
|create_fsxn_volume | Creates a new volume under a specified SVM. |
20-
|list_fsx_filesystems | List all the FSx for NetApp ONTAP filesystems that the user has access to. |
21-
|list_fsx_filesystems.ps1 | List all the FSx for NetApp ONTAP filesystems that the user has access to, written in PowerShell. |
20+
|list_fsx_filesystems | List all the FSx for NetApp ONTAP file systems that the user has access to. |
21+
|list_fsx_filesystems.ps1 | List all the FSx for NetApp ONTAP file systems that the user has access to, written in PowerShell. |
2222
|list_fsxn_volumes | List all the FSx for NetApp ONTAP volumes that the user has access to. |
2323
|list_fsxn_svms | List all the storage virtual machines that the user access to. |
24-
|list_aws_subnets | List all the aws subnets. |
25-
|list_aws_vpcs | List all the aws vpcs. |
26-
|delete_fsxn_filesystem | Deletes an FSx for NetApp ONTAP filesystem. |
27-
|delete_fsxn_svm | Deletes an svm. |
28-
|delete_fsxn_volume | Deletes a volume. |
24+
|list_aws_subnets | List all the AWS subnets. |
25+
|list_aws_vpcs | List all the AWS VPCs. |
26+
|delete_fsxn_filesystem | Deletes a specified FSx for ONTAP file system. Including all the SVMs and volumes on it. |
27+
|delete_fsxn_svm | Deletes a specified SVM. Including all the volumes assigned to it. |
28+
|delete_fsxn_volume | Deletes a specified volume. |
2929

3030

3131
## Author Information

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

Lines changed: 159 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +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]
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.
35+
-wait: Forces the script to wait until the file system is created before returning.
3436
EOF
3537
exit 1
3638
}
@@ -40,21 +42,56 @@ EOF
4042
################################################################################
4143
tmpout=/tmp/fsx_fs_create.$$
4244
trap 'rm -f $tmpout' exit
45+
#
46+
# Set the maximum number of times to check that the file system was created.
47+
# Multiple it by the SleepTime set below to the total amount of time allowed.
48+
MaxIterations=180
49+
#
50+
# Set the number of seconds to wait between checks that the file system
51+
# has been created.
52+
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)
4358

44-
if which jq aws > /dev/null 2>&1; then
45-
:
46-
else
47-
echo "Error, both the 'aws' and 'jq' commands are required to run this script." 1>&2
48-
exit 1
49-
fi
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+
}
76+
77+
for cmd in jq aws; do
78+
if which $cmd > /dev/null 2>&1; then
79+
:
80+
else
81+
echo "Error, the '$cmd' is required to run this script." 1>&2
82+
exit 1
83+
fi
84+
done
5085
#
5186
# Set some defaults.
5287
size=1024
5388
throughput=128
5489
region=$(aws configure list | egrep '^.*egion ' | awk '{print $2}')
5590
securityGroupOption=""
5691
endpointips=""
57-
azType="MULTI_AZ_1"
92+
availType=multi
93+
numPairs=1
94+
waitForCompletion=false
5895
#
5996
# Process command line arguments.
6097
while [ ! -z "$1" ]; do
@@ -66,13 +103,10 @@ while [ ! -z "$1" ]; do
66103
shift
67104
;;
68105
-size|--size) size="$2"
69-
if ! [[ "$size" =~ '^[0-9]+$' ]]; then
106+
if ! [[ "$size" =~ $integerRegEx ]]; then
70107
echo "-size must be an integer."
71108
usage
72109
fi
73-
if [ "$size" -le 1024 ]; then
74-
usage
75-
fi
76110
shift
77111
;;
78112
-subnetid1|--subnetid1) subnetID1="$2"
@@ -85,31 +119,34 @@ while [ ! -z "$1" ]; do
85119
shift
86120
;;
87121
-type|--type)
88-
if [ "$(echo $2 | tr [A-Z] [a-z])" == "single" ]; then
89-
azType="SINGLE_AZ_1"
90-
elif [ "$(echo $2 | tr [A-Z] [a-z])" == "multi" ]; then
91-
azType="MULTI_AZ_1"
92-
else
93-
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
94125
usage
95126
fi
96127
shift
97128
;;
98129
-throughput|--throughput) throughput="$2"
99-
if ! [[ "$throughput" =~ '^[0-9]+$' ]]; then
130+
if ! [[ "$throughput" =~ $integerRegEx ]]; then
100131
echo "-throughput must be an integer."
101132
usage
102133
fi
103-
if [ "$througput" != "128" -a "$througput" != "256" -a "$throughput" != "512" -a "$throughput" != "1024" -a "$throughput" != "2048" -a "$throughput" != "4096" ]; then
104-
echo "-throughput must be 128 or 256 or 512 or 1024 or 2048 or 4096."
105-
usage
106-
fi
107134
shift
108135
;;
109136
-endpointiprange|--endpointiprange)
110137
endpointips='"EndpointIpAddressRange": "'$2'",'
111138
shift
112139
;;
140+
-numberpairs|--numberpairs) numPairs="$2"
141+
if ! [[ "$numPairs" =~ $integerRegEx ]]; then
142+
echo "-numPairs must be an integer."
143+
usage
144+
fi
145+
shift
146+
;;
147+
-wait|--wait)
148+
waitForCompletion=true
149+
;;
113150
-h|-help|--help)
114151
usage
115152
;;
@@ -119,16 +156,44 @@ while [ ! -z "$1" ]; do
119156
esac
120157
shift
121158
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
122182
#
123183
# Ensure all the required parameters have been provided.
124-
if [ -z "$fileSystemName" -o -z "$subnetID1" -o "$azType" == "MULTI_AZ_1" -a -z "$subnetID2" ]; then
125-
echo "Missing arguments." 1>&2
184+
if [ -z "$fileSystemName" ]; then
185+
echo "Error, you must specify a file system name." 1>&2
186+
usage
187+
fi
188+
189+
if [ -z "$subnetID1" -o "$azType" == "MULTI_AZ_1" -a -z "$subnetID2" -o "$azType" == "MULTI_AZ_2" -a -z "$subnetID2" ]; then
190+
echo "Error, you must specify only subnetID1 for a single availability zone deployments or both subnetID1 and subnetID2 for a multi availability zone deployments." 1>&2
126191
usage
127-
exit 1
128192
fi
129-
if [ $azType == "SINGLE_AZ_1" ]; then
193+
194+
if [[ $azType == *"SINGLE_AZ"* ]]; then
130195
if [ ! -z "$endpointips" ]; then
131-
echo "Error, you can not specify Endpoint IP address range when deploying in a single availability zone." 1>&2
196+
echo "Error, you cannot specify Endpoint IP address range when deploying in a single availability zone." 1>&2
132197
exit 1
133198
fi
134199

@@ -138,24 +203,82 @@ if [ $azType == "SINGLE_AZ_1" ]; then
138203
fi
139204
fi
140205

141-
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 '{
206+
if [ $numPairs -gt 1 ]; then
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+
212+
if [ $azType != "SINGLE_AZ_2" ]; then
213+
echo "Error, you can only specify more than one HA pair with a single availability zone deployment." 1>&2
214+
usage
215+
fi
216+
fi
217+
218+
minSize=$((1024*numPairs))
219+
if [ $size -lt $minSize ]; then
220+
echo "Error, the size must be at least $minSize for $numPairs HA pairs. In other words 1024 per HA pair." 1>&2
221+
usage
222+
fi
223+
224+
echo 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 '{
142225
"PreferredSubnetId": "'$subnetID1'",
143226
'$endpointips'
144227
"DeploymentType": "'$azType'",
145-
"ThroughputCapacity": '$throughput'}' --region=$region > $tmpout 2>&1
146-
228+
"HAPairs": '$numPairs',
229+
"ThroughputCapacityPerHAPair": '$throughput'}' --region=$region
230+
# "ThroughputCapacityPerHAPair": '$throughput'}' --region=$region > $tmpout 2>&1
231+
exit
147232
if [ $? != "0" ]; then
148233
echo "Failed to create FSxN file system." 1>&2
149234
cat $tmpout 1>&2
150235
exit 1
151236
else
152237
status=$(jq -r .FileSystem.Lifecycle $tmpout 2> /dev/null)
153238
if [ "$status" == "CREATING" -o "$status" == "PENDING" ]; then
154-
echo "File system '$fileSystemName' ($(jq -r .FileSystem.FileSystemId $tmpout)) is being created."
155-
exit 0
239+
fsid=$(jq -r .FileSystem.FileSystemId $tmpout)
240+
printf "File system '$fileSystemName' ($fsid) is being created."
241+
if [ $waitForCompletion == "true" ]; then
242+
i=0
243+
while [ $i -lt $MaxIterations ]; do
244+
aws fsx describe-file-systems --file-system-ids $fsid --output=json --region=$region > $tmpout 2>&1
245+
if [ $? -eq 0 ]; then
246+
status=$(jq -r '.FileSystems[0].Lifecycle' $tmpout 2> /dev/null)
247+
if [ "$status" == "AVAILABLE" ]; then
248+
printf "\nFile system '$fileSystemName' ($fsid) has been created.\n"
249+
break
250+
fi
251+
if [ "$status" != "CREATING" -a "$status" != "PENDING" ]; then
252+
printf "\nError, failed to create the file system. Status = $status\n" 1>&2
253+
reason="$(jq -r '.FileSystems[0].LifecycleTransitionReason.Message' $tmpout 2> /dev/null)"
254+
if [ ! -z "$reason" ]; then
255+
echo "Reason: $reason" 1>&2
256+
else
257+
cat $tmpout 1>&2
258+
fi
259+
exit 1
260+
fi
261+
printf "."
262+
else
263+
printf "\nError, failed to get the file system status.\n" 1>&2
264+
cat $tmpout 1>&2
265+
exit 1
266+
fi
267+
sleep $SleepTime
268+
let i+=1
269+
done
270+
if [ $i -ge $MaxIterations ]; then
271+
printf "\nFailed to create file system('$fsid'). Taking too long.\n" 1>&2
272+
exit 1
273+
fi
274+
exit 0
275+
else
276+
echo
277+
fi
156278
else
157279
echo "Unknown status '$status'. Complete output returned from the AWS api:" 1>&2
158280
cat $tmpout 1>&2
159281
exit 1
160282
fi
161283
fi
284+
exit 0

0 commit comments

Comments
 (0)