Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Management-Utilities/Workload-Factory-API-Samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ If you do create a new script, please consider contributing it back to this repo
| [eda_project_config_create](eda_project_config_create) | This creates a new EDA project configuration. |
| [eda_project_config_delete](eda_project_config_delete) | This deletes a EDA project configuration. |
| [fsxn_credentials_set](fsxn_credentials_set) | This sets the credentials for a specified FSx for ONTAP file system. |
| [get_latency_configuration](get_latency_configuration) | Get the latency configuration for the BlueXP account. |
| [get_latency_metrics](get_latency_metrics) | Get the specific details of a latency event. |
| [link_associate](link_associate) | This associates a Workload Factory Link with a specified FSx for ONTAP file system. |
| [link_delete](link_delete) | This deletes a Workload Factory Link. |
Expand All @@ -68,9 +67,10 @@ If you do create a new script, please consider contributing it back to this repo
| [list_cicd_clones](list_cicd_clones) | This lists all the clones that you have access to in the specified CI/CD project. |
| [list_cicd_projects](list_cicd_projects) | This lists all the CI/CD projects that you have access to. |
| [list_credentials](list_credentials) | This lists all the Workload Factory credentials that you have access to. |
| [list_eda_latency_config](list_eda_latency_config) | Get the latency configuration for the BlueXP account. |
| [list_eda_project_config](list_eda_project_config) | This lists the EDA project configuration. |
| [list_filesystems](list_filesystems) | This lists all the FSx for ONTAP file systems that you have access to in the specified AWS region. |
| [list_latency_events](list_latency_events) | This lists all the latnecy events associated with the BlueXP account. |
| [list_eda_latency_events](list_eda_latency_events) | This lists all the latnecy events associated with the BlueXP account. |
| [list_links](list_links) | This lists all the Workload Factory Links that you have access to. |
| [list_snapmirrors](list_snapmirrors) | This lists all the SnapMirror relationships that are associated with the specified file system. |
| [list_snapshots](list_snapshots) | This lists all the snapshots that are associated with the specified volumes. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ usage() {
cat >&2 <<EOF
This script lists all the Workload Factory credentials you has access to.

Usage: $(basename $0) -t refresh_token -a blueXP_account_ID [-o]
Usage: $(basename $0) -t refresh_token -a blueXP_account_ID [-o] [-j]

Where: refresh_token - Is a refresh token used to obtain an access token needed
to run the Workload Factory APIs. You can obtain a refresh
token by going to https://services.cloud.netapp.com/refresh-token
blueXP_account_ID - is the BlueXP account ID. You can find all the accounts
you have access to by running the "list_bluexp_accts" script
-o means to also show the ONTAP credentials
-j means to output the results in JSON format instead of a table.

Instead of passing parameters on the command line, you can set the
following environment variables:
Expand Down Expand Up @@ -59,12 +60,14 @@ fi
. "$wf_utils"
#
# Set defaults.
raw=false
filter="filter=$(urlencode "type eq 'AWS_ASSUME_ROLE'")"
while getopts "ht:a:o" opt; do
while getopts "ht:a:oj" opt; do
case $opt in
t) REFRESH_TOKEN="$OPTARG" ;;
a) BLUEXP_ACCOUNT_ID="$OPTARG" ;;
o) filter="";; # No filter, list all credentials.
j) raw=true ;;
*) usage ;;
esac
done
Expand Down Expand Up @@ -93,29 +96,39 @@ if [ -z "$token" ]; then
exit 1
fi

jq_query='.items[] | if(.type == "ONTAP") then "\(if(.metadata.fileSystemId == null) then .metadata.onPremId else .metadata.fileSystemId end) \(.type) \(.metadata.userName) \(.id) \(.numAssociatedResources)" else "\(.metadata.name) \(.type) \(.credentials | split(":") | .[4]) \(.id) \(.numAssociatedResources)" end'
jq_query='.items[] | if(.type == "ONTAP") then "\(if(.metadata.fileSystemId != null) then .metadata.fileSystemId else if(.metadata.onPremId != null) then .metadata.onPremId else empty end end) \(.type) \(.metadata.userName) \(.id) \(.numAssociatedResources)" else "\(if(.metadata.name != null) then .metadata.name else "N/A" end) \(.type) \( if(.credentials != null) then .credentials | split(":") | .[4] else "N/A" end) \(.id) \(.numAssociatedResources)" end'

run_curl GET "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/credentials/v1/credentials?$filter" $tmpout $tmperr
if jq -r "$jq_query" $tmpout > $tmpout2 2> $tmperr; then
:
if [ $raw == "true" ]; then
cat $tmpout
else
echo "Failed to parse the output from the API."
cat $tmperr >&2
exit 1
if jq -r "$jq_query" $tmpout > $tmpout2 2> $tmperr; then
:
else
echo "Failed to parse the output from the API."
cat $tmperr >&2
exit 1
fi
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}/credentials/v1/credentials?nextToken=$nextToken" $tmpout $tmperr
if jq -r "$jq_query" $tmpout >> $tmpout2 2> $tmperr; then
:
if [ $raw == "true" ]; then
cat $tmpout
else
echo "Failed to parse the output from the API."
cat $tmperr >&2
exit 1
if jq -r "$jq_query" $tmpout >> $tmpout2 2> $tmperr; then
:
else
echo "Failed to parse the output from the API."
cat $tmperr >&2
exit 1
fi
fi
nextToken=$(jq -r '.nextToken' $tmpout)
done

sort -f -k 2,2 -k 1,1 $tmpout2 | column -t -N "Name,Type,Account,ID,Number Associated Resources"
if [ $raw != "true" ]; then
sort -f -k 2,2 -k 1,1 $tmpout2 | column -t -N "Name,Type,Account,ID,Number Associated Resources"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ echo "Default Latency Configuration:"
sort -f $tmpout2 | column -s, -t -R 4,5,6,7 -N "Account ID,Created By,Status,Warning Read Threshold,Warning Write Threshold,Critical Read Threshold,Critical Write Threshold"
#
# Now get the latency configuration for each volume.
if [ $(jq -r '.config.filesystems | length' $tmpout) == "0" ]; then
exit
fi
jq_query='.config.filesystems | to_entries | .[] | .key + " " + (.value | to_entries | .[] | .key + " " + (.value.warning.readLatency.latencyThresholdMs | tostring) + " " + (.value.warning.writeLatency.latencyThresholdMs | tostring) + " " + (.value.critical.readLatency.latencyThresholdMs | tostring) + " " + (.value.critical.writeLatency.latencyThresholdMs | tostring) + " ")'
if jq -r "$jq_query" $tmpout > $tmpout2 2> $tmperr; then
:
Expand Down
Loading