Skip to content

Commit 967013e

Browse files
committed
Added support for listing on-prem file systems.
1 parent 5ff2fdb commit 967013e

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

Management-Utilities/Workload-Factory-API-Samples/list_filesystems

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh tokon is required to
8484
required_options["BLUEXP_ACCOUNT_ID"]='Error: A BlueXP account ID is required to run this script.
8585
You can get the list of accounts you have access to by running the "list_bluexp_accts" script
8686
found in this GitHub repository: https://github.com/NetApp/FSx-ONTAP-samples-scripts/tree/main/Management-Utilities/Workload-Factory-API-Samples\n\n'
87-
required_options["CREDENTIALS_ID"]='Error: The ID of the credentials to delete is required.
87+
required_options["CREDENTIALS_ID"]='Error: The ID of the credentials to use to list the file systems is required.
8888
You can get a list of credentials by running the "list_credentials" script
8989
found in this GitHub repository: https://github.com/NetApp/FSx-ONTAP-samples-scripts/tree/main/Management-Utilities/Workload-Factory-API-Samples\n\n'
9090
required_options["AWS_REGION"]='Error: The AWS region where the file system is located is required.\n\n'
@@ -129,4 +129,28 @@ while [ "$nextToken" != "null" ]; do
129129
fi
130130
nextToken=$(jq -r '.nextToken' $tmpout)
131131
done
132+
133+
jq_query='.items[] | .clusterUuid + "," + .name + ",N/A,On-Prem," + if(.connected) then "AVAILABLE" else "UNKNOWN" end'
134+
run_curl GET "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/onprem/v1/onprems" $tmpout $tmperr
135+
if jq -r "$jq_query" $tmpout >> $tmpout2 2> $tmperr; then
136+
:
137+
else
138+
echo "Error: Failed to parse the output from the API." >&2
139+
cat $tmperr >&2
140+
exit 1
141+
fi
142+
#
143+
# Check to see if there are more.
144+
nextToken=$(jq -r '.nextToken' $tmpout)
145+
while [ "$nextToken" != "null" ]; do
146+
run_curl GET "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/onprem/v1/onprems?${nextToken}" $tmpout $tmperr
147+
if jq -r "$jq_query" $tmpout >> $tmpout2 2> $tmperr; then
148+
:
149+
else
150+
echo "Error: Failed to parse the output from the API." >&2
151+
cat $tmperr >&2
152+
exit 1
153+
fi
154+
nextToken=$(jq -r '.nextToken' $tmpout)
155+
done
132156
sort -t, -f -k 2,2 $tmpout2 | column -t -s, -N ID,Name,Region,Deployment_Type,Status

0 commit comments

Comments
 (0)