Skip to content
Merged
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 latency 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 @@ -10,7 +10,7 @@
################################################################################
usage () {
cat 1>&2 <<EOF
Usage: $(basename $0) -t REFRESH_TOKEN -a blueXP_BLUE_ACCOUNT_ID -c CREDENTIALS_ID -r aws_AWS_REGION -f FILESYSTEM_ID -C CONNECTOR_ID -w WORKSPACE_ID -s SECRET_NAME -u USERNAME -p PASSWORD [-P]
Usage: $(basename $0) -t REFRESH_TOKEN -a blueXP_BLUE_ACCOUNT_ID -c CREDENTIALS_ID -r AWS_REGION -f FILESYSTEM_ID -C CONNECTOR_ID -w WORKSPACE_ID [-s SECRET_NAME] [-u USERNAME] [-p PASSWORD] [-P]

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
Expand All @@ -19,15 +19,15 @@ Where: REFRESH_TOKEN - Is a refresh token used to obtain an access token needed
list of accounts you have access to
CREDENTIALS_ID - is the Workload Factory credentials ID for the AWS account. Run
'list_credentials' to get a list of credentials you have access to
aws_AWS_REGION - is the AWS AWS_REGION where the FSx file systems are located
AWS_REGION - is the AWS AWS_REGION where the FSx file systems are located
FILESYSTEM_ID - is the AWS file system ID of the FSx file system where the volume resides
CONNECTOR_ID - The BlueXP connector ID. Run 'list_bluexp_connectors' to get a list
of connectors you have access to
WORKSPACE_ID - The BlueXP workspace ID. Run 'list_bluexp_workspaces' to get a list of workspaces
you have access to.
SECRET_NAME - The name of the secret that holds the credentials to assoicate with the FSxN.
USERNAME - The username to set the password for (defaults to fsxadmin if not specified).
PASSWORD - The password to set for the username.
SECRET_NAME - The name of the secret that holds the credentials to assoicate with the FSxN. Not needed if a username and password are provided.
USERNAME - The username to set the password for (defaults to fsxadmin if not specified). Not needed if a secret is provided.
PASSWORD - The password to set for the username. Not needed if a secret is provided.
-P - Means to just try to set the password.

Instead of passing parameters on the command line, you can set the following
Expand All @@ -36,7 +36,7 @@ environment variables:
export REFRESH_TOKEN=<REFRESH_TOKEN>
export BLUEXP_BLUE_ACCOUNT_ID=<blueXP_BLUE_ACCOUNT_ID>
export CREDENTIALS_ID=<CREDENTIALS_ID>
export AWS_AWS_REGION=<aws_AWS_REGION>
export AWS_REGION=<AWS_REGION>
export USERNAME=<username>
export PASSWORD=<password>

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,47 @@ 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'
Comment thread
kcantrel marked this conversation as resolved.

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
if jq -r . $tmpout 2>&1 > /dev/null ; then
:
else
cat $tmpout
fi
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
if jq -r . $tmpout 2>&1 > /dev/null ; then
:
else
cat $tmpout
fi
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
Loading