From d8a29c2463e840e99a2587f0f205cab536ec0fa4 Mon Sep 17 00:00:00 2001 From: Keith Cantrell Date: Fri, 18 Apr 2025 17:29:44 -0500 Subject: [PATCH 1/2] Removed some debug statements. --- .../fsx-ontap-aws-cli-scripts/create_fsxn_filesystem | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Management-Utilities/fsx-ontap-aws-cli-scripts/create_fsxn_filesystem b/Management-Utilities/fsx-ontap-aws-cli-scripts/create_fsxn_filesystem index 3a339017..df91d5fb 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/create_fsxn_filesystem +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/create_fsxn_filesystem @@ -221,14 +221,13 @@ if [ $size -lt $minSize ]; then usage fi -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 '{ +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 '{ "PreferredSubnetId": "'$subnetID1'", '$endpointips' "DeploymentType": "'$azType'", "HAPairs": '$numPairs', - "ThroughputCapacityPerHAPair": '$throughput'}' --region=$region -# "ThroughputCapacityPerHAPair": '$throughput'}' --region=$region > $tmpout 2>&1 -exit + "ThroughputCapacityPerHAPair": '$throughput'}' --region=$region > $tmpout 2>&1 + if [ $? != "0" ]; then echo "Failed to create FSxN file system." 1>&2 cat $tmpout 1>&2 From af9bcfbb85926f2f527193a7f670dc5be9404bf2 Mon Sep 17 00:00:00 2001 From: Keith Cantrell Date: Wed, 30 Apr 2025 11:07:05 -0500 Subject: [PATCH 2/2] Added a -p option to include management and NAS IP address. --- .../fsx-ontap-aws-cli-scripts/list_fsxn_svms | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms index a5c199fd..66dcfa20 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms @@ -18,6 +18,7 @@ # o Region # o File system ID # o File System Name - optional +# o The managment and NAS IP address of the SVM - optional # o SVM ID # o SVM Name ################################################################################ @@ -27,9 +28,10 @@ ################################################################################ usage () { cat 1>&2 < /dev/null | jq -r '.FileSystems[] | if((.Tags[] | select(.Key == "Name") .Value) == "'"${fileSystemName}"'") then .FileSystemId else empty end' 2> /dev/null) - if [ -z "$fileSystemID" ]; then - echo "Error, failed to find a file system with the name '$fileSystemName'. Maybe in a different region?" 1>&2 - exit 1 - fi -fi # # Loop on all the regions. for region in ${regions[*]}; do + if [ ! -z "$fileSystemName" ]; then + fileSystemID=$(aws fsx describe-file-systems --output=json --region=$region 2> /dev/null | jq -r '.FileSystems[] | if((.Tags[] | select(.Key == "Name") .Value) == "'"${fileSystemName}"'") then .FileSystemId else empty end' 2> /dev/null) + if [ -z "$fileSystemID" ]; then + if [ "$allRegions" != "true" ]; then + echo "Error, failed to find a file system with the name '$fileSystemName'. Maybe in a different region?" 1>&2 + exit 1 + else + # + # If there isn't a file system with that name in this region, then just skip region. + continue + fi + fi + fi + if [ -z "$fileSystemID" ]; then - aws fsx describe-storage-virtual-machines --region=$region | jq -r '.StorageVirtualMachines[] | .FileSystemId + "," + .StorageVirtualMachineId + "," + .Name' | sort > $tmpout + filter="" + else + filter="--filter Name=file-system-id,Values=$fileSystemID" + fi + aws fsx describe-storage-virtual-machines --region=$region $filter | jq -r '.StorageVirtualMachines[] | "\(.FileSystemId),\(.StorageVirtualMachineId),\(.Endpoints.Nfs.IpAddresses[0]),\(.Name)"' | sort > $tmpout + if [ $includeIp == "true" ]; then + ipFmt="%16s" + ipHeader="IP" else - aws fsx describe-storage-virtual-machines --region=$region | jq -r '.StorageVirtualMachines[] | if(.FileSystemId == "'$fileSystemID'") then .FileSystemId + "," + .StorageVirtualMachineId + "," + .Name else empty end' | sort > $tmpout + ipFmt="%0s" + ipHeader="" fi if [ $includeFsName == "true" ]; then aws fsx describe-file-systems --region=$region | jq -r '.FileSystems[] | .FileSystemId + "," + (.Tags[] | select(.Key == "Name") .Value)' > $tmpout2 - awk -F, -v region=$region 'BEGIN {first=1; maxNameLen=0; while(getline < "'$tmpout2'") {fss[$1]=$2; if(length($2) > maxNameLen) {maxNameLen=length($2)}}; maxNameLen +=2; formatStr="%12s %20s%-"maxNameLen"s %23s %s\n"}; {if(first) {printf "\n"; printf formatStr, "Region", "FileSystem ID", "(Name)", "SVM ID", "SVM Name"; first=0}; name="("fss[$1]")"; printf formatStr, region, $1, name, $2, $3}' < $tmpout + awk -F, -v region=$region -v ipFmt=$ipFmt -v ipHeader=$ipHeader 'BEGIN {first=1; maxNameLen=0; while(getline < "'$tmpout2'") {fss[$1]=$2; if(length($2) > maxNameLen) {maxNameLen=length($2)}}; maxNameLen +=2; formatStr="%12s %20s%-"maxNameLen"s %23s "ipFmt" %s\n"}; {if(first) {printf "\n"; printf formatStr, "Region", "FileSystem ID", "(Name)", "SVM ID", ipHeader, "SVM Name"; first=0}; if(ipHeader != "IP") {ip=""} else {ip=$3}; name="("fss[$1]")"; printf formatStr, region, $1, name, $2, ip, $4}' < $tmpout else - awk -F, -v region=$region 'BEGIN {first=1; formatStr="%12s %23s %23s %s\n"}; {if(first) {printf "\n"; printf formatStr, "Region", "FileSystem ID", "SVM ID", "SVM Name"; first=0}; printf formatStr, region, $1, $2, $3}' < $tmpout + awk -F, -v region=$region -v ipFmt=$ipFmt -v ipHeader=$ipHeader 'BEGIN {first=1; formatStr="%12s %23s %23s "ipFmt" %s\n"}; {if(first) {printf "\n"; printf formatStr, "Region", "FileSystem ID", "SVM ID", ipHeader, "SVM Name"; first=0}; if(ipHeader != "IP") {ip=""} else {ip=$3}; printf formatStr, region, $1, $2, ip, $4}' < $tmpout fi done