From 7bf6c47a7fe9b1b4631fe7fc2552fad7984b66e3 Mon Sep 17 00:00:00 2001 From: Keith Cantrell Date: Fri, 30 Oct 2026 12:15:54 -0500 Subject: [PATCH 1/7] Fixed an issue that was caused by AWS adding duplicate regions to it regional table. --- .../list_fsxn_filesystems | 28 +++++++++++++++++-- .../fsx-ontap-aws-cli-scripts/list_fsxn_svms | 28 +++++++++++++++++-- .../list_fsxn_volumes | 28 +++++++++++++++++-- 3 files changed, 75 insertions(+), 9 deletions(-) diff --git a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems index 7a9682b0..3757f364 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems @@ -87,6 +87,25 @@ start_watchdog () { fi } +################################################################################ +# The following function echos "true" if the first argument is found in the +# second argument, which is a space separated list of values. Otherwise +# it echos "false". +################################################################################ +inArray() { + + region=$1 + regions="$2" + for r in $regions; do + if [ "$r" == "$region" ]; then + echo "true" + return 1 + fi + done + echo "false" + return 0 +} + ################################################################################ # This function is used to get the list of file systems for the region passed # as the first argument. @@ -267,7 +286,7 @@ showStatus=false showARN=false showBackup=false region=$(aws configure get region) -excludeRegions="none" +: ${excludeRegions:="none"} maxTime=20 # # Process command line arguments. @@ -332,7 +351,10 @@ if [ "$allRegions" == "true" ]; then allFsxnRegions=$(curl -s https://api.regional-table.region-services.aws.a2z.com/index.json | jq -r '.prices[] | select(.attributes."aws:serviceName" == "Amazon FSx for NetApp ONTAP") .attributes."aws:region"' | egrep -v "$excludeRegions") for reg in $allEndabledRegions; do for fsxnReg in $allFsxnRegions; do - if [ $reg == $fsxnReg ]; then + # + # Since for some crazy reason AWS decided to add duplicate entries in their + # regional table, we need to make sure we don't add duplicates to our list of regions. + if [ $reg == $fsxnReg -a $(inArray $reg "${regions[*]}") == "false" ]; then regions+=($reg) fi done @@ -379,7 +401,7 @@ for region in ${regions[*]}; do done while [ ${#pids[@]} -gt 0 ]; do - wait -n -p pid "${!pids[@]}" + wait -n -p pid "${!pids[@]}" > /dev/null 2>&1 if [ $? -ne 127 ]; then cat $tmpdir/${pids[$pid]}.out 2> /dev/null unset pids[$pid] 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 27091787..f6c64104 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms @@ -69,6 +69,25 @@ start_watchdog () { fi } +################################################################################ +# The following function echos "true" if the first argument is found in the +# second argument, which is a space separated list of values. Otherwise +# it echos "false". +################################################################################ +inArray() { + + region=$1 + regions="$2" + for r in $regions; do + if [ "$r" == "$region" ]; then + echo "true" + return 1 + fi + done + echo "false" + return 0 +} + ################################################################################ # This function will list all the SVMs in the specified region. ################################################################################ @@ -135,7 +154,7 @@ allRegions=false includeFsName=false includeIp=false region=$(aws configure get region) -excludeRegions="none" +: ${excludeRegions:="none"} maxTime=20 while getopts "haX:nr:i:f:pe:t:" option; do case "$option" in @@ -176,7 +195,10 @@ if [ "$allRegions" = "true" ]; then allFsxnRegions=$(curl -s https://api.regional-table.region-services.aws.a2z.com/index.json | jq -r '.prices[] | select(.attributes."aws:serviceName" == "Amazon FSx for NetApp ONTAP") .attributes."aws:region"' | egrep -v "$excludeRegions") for reg in $allEndabledRegions; do for fsxnReg in $allFsxnRegions; do - if [ $reg == $fsxnReg ]; then + # + # Since for some crazy reason AWS decided to add duplicate entries in their + # regional table, we need to make sure we don't add duplicates to our list of regions. + if [ $reg == $fsxnReg -a $(inArray $reg "${regions[*]}") == "false" ]; then regions+=($reg) fi done @@ -198,7 +220,7 @@ for region in ${regions[*]}; do done while [ ${#pids[@]} -gt 0 ]; do - wait -n -p pid "${!pids[@]}" + wait -n -p pid "${!pids[@]}" > /dev/null 2>&1 if [ $? -ne 127 ]; then cat $tmpdir/${pids[$pid]}.out 2> /dev/null unset pids[$pid] diff --git a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes index af879214..4a8d1180 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes @@ -78,6 +78,25 @@ start_watchdog () { fi } +################################################################################ +# The following function echos "true" if the first argument is found in the +# second argument, which is a space separated list of values. Otherwise +# it echos "false". +################################################################################ +inArray() { + + region=$1 + regions="$2" + for r in $regions; do + if [ "$r" == "$region" ]; then + echo "true" + return 1 + fi + done + echo "false" + return 0 +} + ################################################################################ # This function will get the list of volumes for a given region. ################################################################################ @@ -211,7 +230,7 @@ fi # # Process command line arguments. allRegions=false -excludeRegions="none" +: ${excludeRegions:="none"} region=$(aws configure get region) includeFsName=false excludeRoot=false @@ -274,7 +293,10 @@ if [ "$allRegions" = "true" ]; then allFsxnRegions=$(curl -s https://api.regional-table.region-services.aws.a2z.com/index.json | jq -r '.prices[] | select(.attributes."aws:serviceName" == "Amazon FSx for NetApp ONTAP") .attributes."aws:region"' | egrep -v $excludeRegions) for reg in $allEndabledRegions; do for fsxnReg in $allFsxnRegions; do - if [ $reg == $fsxnReg ]; then + # + # Since for some crazy reason AWS decided to add duplicate entries in their + # regional table, we need to make sure we don't add duplicates to our list of regions. + if [ $reg == $fsxnReg -a $(inArray $reg "${regions[*]}") == "false" ]; then regions+=($reg) fi done @@ -296,7 +318,7 @@ for region in ${regions[*]}; do done while [ ${#pids[@]} -gt 0 ]; do - wait -n -p pid "${!pids[@]}" + wait -n -p pid "${!pids[@]}" > /dev/null 2>&1 if [ $? -ne 127 ]; then cat $tmpdir/${pids[$pid]}.out 2> /dev/null unset pids[$pid] From 7d65c152d9c8207bd0f6bafb99bc5ab3f116554d Mon Sep 17 00:00:00 2001 From: Keith Cantrell Date: Mon, 2 Nov 2026 07:22:39 -0600 Subject: [PATCH 2/7] Fixed an issue caused by AWS having duplicate regions in its region table. --- .../fsx-ontap-aws-cli-scripts/list_fsxn_filesystems | 2 +- Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms | 2 +- .../fsx-ontap-aws-cli-scripts/list_fsxn_volumes | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems index 3757f364..5a24974c 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems @@ -354,7 +354,7 @@ if [ "$allRegions" == "true" ]; then # # Since for some crazy reason AWS decided to add duplicate entries in their # regional table, we need to make sure we don't add duplicates to our list of regions. - if [ $reg == $fsxnReg -a $(inArray $reg "${regions[*]}") == "false" ]; then + if [[ $reg == $fsxnReg && $(inArray $reg "${regions[*]}") == "false" ]]; then regions+=($reg) fi done 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 f6c64104..5341f3ae 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms @@ -198,7 +198,7 @@ if [ "$allRegions" = "true" ]; then # # Since for some crazy reason AWS decided to add duplicate entries in their # regional table, we need to make sure we don't add duplicates to our list of regions. - if [ $reg == $fsxnReg -a $(inArray $reg "${regions[*]}") == "false" ]; then + if [[ $reg == $fsxnReg && $(inArray $reg "${regions[*]}") == "false" ]]; then regions+=($reg) fi done diff --git a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes index 4a8d1180..fe3d2a58 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes @@ -296,7 +296,7 @@ if [ "$allRegions" = "true" ]; then # # Since for some crazy reason AWS decided to add duplicate entries in their # regional table, we need to make sure we don't add duplicates to our list of regions. - if [ $reg == $fsxnReg -a $(inArray $reg "${regions[*]}") == "false" ]; then + if [[ $reg == $fsxnReg && $(inArray $reg "${regions[*]}") == "false" ]]; then regions+=($reg) fi done From ccd90d511d6496662cdaf754d63cd92d9a80e92f Mon Sep 17 00:00:00 2001 From: Keith Cantrell Date: Mon, 9 Nov 2026 07:06:54 -0600 Subject: [PATCH 3/7] Removed an unused CLI option. --- .../Workload-Factory-API-Samples/show_fsxn_credentials | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Management-Utilities/Workload-Factory-API-Samples/show_fsxn_credentials b/Management-Utilities/Workload-Factory-API-Samples/show_fsxn_credentials index 6cd202d2..bb33a756 100755 --- a/Management-Utilities/Workload-Factory-API-Samples/show_fsxn_credentials +++ b/Management-Utilities/Workload-Factory-API-Samples/show_fsxn_credentials @@ -15,7 +15,7 @@ usage() { cat >&2 < Date: Mon, 9 Nov 2026 08:52:13 -0600 Subject: [PATCH 4/7] Fixed an issue caused by AWS having duplicate regions in its region table. --- .../fsx-ontap-aws-cli-scripts/list_fsxn_filesystems | 2 +- Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms | 2 +- .../fsx-ontap-aws-cli-scripts/list_fsxn_volumes | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems index 5a24974c..10b35480 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems @@ -354,7 +354,7 @@ if [ "$allRegions" == "true" ]; then # # Since for some crazy reason AWS decided to add duplicate entries in their # regional table, we need to make sure we don't add duplicates to our list of regions. - if [[ $reg == $fsxnReg && $(inArray $reg "${regions[*]}") == "false" ]]; then + if [ $reg == $fsxnReg] && [ $(inArray $reg "${regions[*]}") == "false" ]; then regions+=($reg) fi done 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 5341f3ae..d7e00455 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_svms @@ -198,7 +198,7 @@ if [ "$allRegions" = "true" ]; then # # Since for some crazy reason AWS decided to add duplicate entries in their # regional table, we need to make sure we don't add duplicates to our list of regions. - if [[ $reg == $fsxnReg && $(inArray $reg "${regions[*]}") == "false" ]]; then + if [ $reg == $fsxnReg ] && [ $(inArray $reg "${regions[*]}") == "false" ]; then regions+=($reg) fi done diff --git a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes index fe3d2a58..6350457c 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_volumes @@ -296,7 +296,7 @@ if [ "$allRegions" = "true" ]; then # # Since for some crazy reason AWS decided to add duplicate entries in their # regional table, we need to make sure we don't add duplicates to our list of regions. - if [[ $reg == $fsxnReg && $(inArray $reg "${regions[*]}") == "false" ]]; then + if [ $reg == $fsxnReg ] && [ $(inArray $reg "${regions[*]}") == "false" ]; then regions+=($reg) fi done From 79dcc4a33f811a7f5628e79050e7e9e2ecaaea35 Mon Sep 17 00:00:00 2001 From: Keith Cantrell Date: Mon, 9 Nov 2026 09:16:21 -0600 Subject: [PATCH 5/7] Fixed an issue caused by AWS having duplicate regions in its region table. --- .../fsx-ontap-aws-cli-scripts/list_fsxn_filesystems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems index 10b35480..9853eb47 100755 --- a/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems +++ b/Management-Utilities/fsx-ontap-aws-cli-scripts/list_fsxn_filesystems @@ -354,7 +354,7 @@ if [ "$allRegions" == "true" ]; then # # Since for some crazy reason AWS decided to add duplicate entries in their # regional table, we need to make sure we don't add duplicates to our list of regions. - if [ $reg == $fsxnReg] && [ $(inArray $reg "${regions[*]}") == "false" ]; then + if [ $reg == $fsxnReg ] && [ $(inArray $reg "${regions[*]}") == "false" ]; then regions+=($reg) fi done From 14c4b182a66c98d72a886d2c33bd2d258bf8152e Mon Sep 17 00:00:00 2001 From: Keith Cantrell Date: Mon, 9 Nov 2026 12:34:27 -0600 Subject: [PATCH 6/7] Changed it to use the "discovery" API that list all the FSxN in all regions assoicated with any credential. --- .../list_filesystems | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/Management-Utilities/Workload-Factory-API-Samples/list_filesystems b/Management-Utilities/Workload-Factory-API-Samples/list_filesystems index a2e59f14..17230c0e 100755 --- a/Management-Utilities/Workload-Factory-API-Samples/list_filesystems +++ b/Management-Utilities/Workload-Factory-API-Samples/list_filesystems @@ -25,10 +25,11 @@ Where: refresh_token - Is a refresh token used to obtain an access token needed token by going to https://services.cloud.netapp.com/refresh-token blueXP_account_ID - is the BlueXP account ID. Run 'list_bluexp_accts' to get a list of accounts you have access to. - credentials_ID - is the Workload Factory credentials ID for the AWS account. + credentials_ID - Limit the list to only the file systems that are associated with + the specified credentials ID. Run 'list_credentials' to get a list of Workload Factory credentials you have access to. - aws_region - is the AWS region where you want the list of FSx file system from. + aws_region - Limit the list to only the file systems in the specified AWS region. Instead of passing parameters on the command line, you can set the following environment variables: @@ -84,10 +85,6 @@ required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh tokon is required to required_options["BLUEXP_ACCOUNT_ID"]='Error: A BlueXP account ID is required to run this script. You can get the list of accounts you have access to by running the "list_bluexp_accts" script found in this GitHub repository: https://github.com/NetApp/FSx-ONTAP-samples-scripts/tree/main/Management-Utilities/Workload-Factory-API-Samples\n\n' -required_options["CREDENTIALS_ID"]='Error: The Workload Factory credentials ID used to list resources is required to run this script. -You can get a list of credentials by running the "list_credentials" script -found in this GitHub repository: https://github.com/NetApp/FSx-ONTAP-samples-scripts/tree/main/Management-Utilities/Workload-Factory-API-Samples\n\n' -required_options["AWS_REGION"]='Error: The AWS region where the file system is located is required.\n\n' check_required_options # @@ -106,8 +103,19 @@ if [ -z "$token" ]; then exit 1 fi -jq_query='.items[] | "\(.id),\(.name),\(.region),\(.deploymentType),\(.status.status)"' -run_curl GET "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/fsx/v2/credentials/${CREDENTIALS_ID}/regions/${AWS_REGION}/file-systems" $tmpout $tmperr +jq_query='.items[] | "\(.id),\(.name),\(.region),\(.deploymentType),\(.status.status)," + (.credentialsIds | join(" "))' +if [ ! -z "$AWS_REGION" ]; then + regionPayload='"regions":["'"$AWS_REGION"'"]' +else + regionPayload='' +fi +if [ ! -z "$CREDENTIALS_ID" ]; then + credentialsPayload='"credentialsIds":["'"$CREDENTIALS_ID"'"]' +else + credentialsPayload='' +fi +payload="{${regionPayload}${regionPayload:+,}${credentialsPayload}}" +run_curl POST "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/fsx/v2/file-systems/discovery" $tmpout $tmperr "$payload" if jq -r "$jq_query" $tmpout > $tmpout2 2> $tmperr; then : else @@ -119,7 +127,7 @@ fi # Check to see if there are more. nextToken=$(jq -r '.nextToken' $tmpout) while [ "$nextToken" != "null" ]; do - run_curl GET "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/fsx/v2/credentials/${CREDENTIALS_ID}/regions/${AWS_REGION}/file-systems?nextToken=${nextToken}" $tmpout $tmperr + run_curl POST "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/fsx/v2/file-systems/discovery?nextToken=${nextToken}" $tmpout $tmperr "$payload" if jq -r "$jq_query" $tmpout >> $tmpout2 2> $tmperr; then : else @@ -129,9 +137,11 @@ while [ "$nextToken" != "null" ]; do fi nextToken=$(jq -r '.nextToken' $tmpout) done - -jq_query='.items[] | .clusterUuid + "," + .name + ",N/A,On-Prem," + if(.connected) then "AVAILABLE" else "UNKNOWN" end' +# +# Check to see if there are any on-prem systems. +jq_query='.items[] | .clusterUuid + "," + .name + ",N/A,On-Prem," + if(.connected) then "AVAILABLE," else "UNKNOWN," end + .credentialId' run_curl GET "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/onprem/v1/onprems" $tmpout $tmperr +cp $tmpout output if jq -r "$jq_query" $tmpout >> $tmpout2 2> $tmperr; then : else @@ -153,4 +163,4 @@ while [ "$nextToken" != "null" ]; do fi nextToken=$(jq -r '.nextToken' $tmpout) done -sort -t, -f -k 2,2 $tmpout2 | column -t -s, -N ID,Name,Region,Deployment_Type,Status +sort -t, -f -k 2,2 $tmpout2 | column -t -s, -N ID,Name,Region,Deployment_Type,Status,Credential_IDs From 87f2ff364f12f2c454e365084e8bd3f8c7cfb26c Mon Sep 17 00:00:00 2001 From: Keith Cantrell Date: Tue, 10 Nov 2026 09:24:15 -0600 Subject: [PATCH 7/7] Changed it to use the discovery API that list all the FSxN in all regions assoicated with any credential. --- .../Workload-Factory-API-Samples/list_filesystems | 1 - 1 file changed, 1 deletion(-) diff --git a/Management-Utilities/Workload-Factory-API-Samples/list_filesystems b/Management-Utilities/Workload-Factory-API-Samples/list_filesystems index 17230c0e..c94fece5 100755 --- a/Management-Utilities/Workload-Factory-API-Samples/list_filesystems +++ b/Management-Utilities/Workload-Factory-API-Samples/list_filesystems @@ -141,7 +141,6 @@ done # Check to see if there are any on-prem systems. jq_query='.items[] | .clusterUuid + "," + .name + ",N/A,On-Prem," + if(.connected) then "AVAILABLE," else "UNKNOWN," end + .credentialId' run_curl GET "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/onprem/v1/onprems" $tmpout $tmperr -cp $tmpout output if jq -r "$jq_query" $tmpout >> $tmpout2 2> $tmperr; then : else