-
Notifications
You must be signed in to change notification settings - Fork 7
Add more wf api samples #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
05b46c9
Updated a help message.
kcantrel 757ab62
Added route table and endpoint support.
kcantrel bf086a7
Added CI/CD and EDA Project APIs samples.
kcantrel 0c7ce8a
Add CI/CD and EDA Project support.
kcantrel c8bd50b
Added route table and endpoint support.
kcantrel 79c2225
Add CI/CD and EDA Project samples
kcantrel 1716caf
Added endpoint support.
kcantrel d588e9b
Updated an error message.
kcantrel ba3378d
Added a new list_snapshots script.
kcantrel ff19281
Made the cicd_clones_create script retreive the volume from the proje…
kcantrel ebe2f57
Made the cicd_clones_create script retreive the volume from the proje…
kcantrel 3f6ebc5
Added more scripts; updated the volume_cifs_create_share to allow you…
kcantrel 4992d33
Added new scripts
kcantrel dab420e
Fixed a typo
kcantrel 481b1c7
Added scripts to display latency events
kcantrel 01968aa
Added scripts to display latency events
kcantrel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
Management-Utilities/Workload-Factory-API-Samples/bluexp_organization_rename
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| #!/bin/bash | ||
| # | ||
| # This script renamees an BlueXP organization. | ||
| # | ||
| ################################################################################ | ||
| # Display usage information then exists the script. | ||
| ################################################################################ | ||
| usage () { | ||
| cat 1>&2 <<EOF | ||
| Usage: $(basename $0) -t REFRESH_TOKEN -o ORGANIZATION_ID -n NEW_NAME | ||
|
|
||
| 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 | ||
| ORGANIZATION_ID - Is the Id of the organization to delete. | ||
| NEW_NAME - The new name of the organization. | ||
|
|
||
| Instead of passing parameters on the command line, you can set the following | ||
| environment variables: | ||
|
|
||
| export REFRESH_TOKEN=<REFRESH_TOKEN> | ||
| EOF | ||
| exit 1 | ||
| } | ||
|
|
||
| ################################################################################ | ||
| # Main logic starts here. | ||
| ################################################################################ | ||
| tmpout=$(mktemp /tmp/delete_organization_to_bluexp-out.XXXXXX) | ||
| tmperr=$(mktemp /tmp/delete_organization_to_bluexp-err.XXXXXX) | ||
| trap 'rm -f $tmpout $tmperr' exit | ||
| # | ||
| # Source the wf_utils file. | ||
| wf_utils=$(command -v wf_utils) | ||
| if [ -z "$wf_utils" ]; then | ||
| if [ ! -x "./wf_utils" ]; then | ||
| cat >&2 <<EOF | ||
| Error: The 'wf_utils' script was not found in the current directory or in the command search path. | ||
| It is required to run this script. You can download it from: | ||
| https://github.com/NetApp/FSx-ONTAP-samples-scripts/tree/main/Management-Utilities/Workload-Factory-API-Samples | ||
| EOF | ||
| exit 1 | ||
| else | ||
| wf_utils=./wf_utils | ||
| fi | ||
| fi | ||
| . "$wf_utils" | ||
| # | ||
| # Parse the command line options. | ||
| while getopts "ht:o:n:" opt; do | ||
| case ${opt} in | ||
| t) REFRESH_TOKEN=$OPTARG ;; | ||
| o) ORGANIZATION_ID=$OPTARG ;; | ||
| n) NEW_NAME=$OPTARG ;; | ||
| *) usage ;; | ||
| esac | ||
| done | ||
| # | ||
| # Declare an array of required options and the error message to display if they are not set. | ||
| declare -A required_options | ||
| required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh token is required to run this script. It can be obtained from this web page: | ||
| https://services.cloud.netapp.com/refresh-token\n\n' | ||
| required_options["ORGANIZATION_ID"]='Error: You must provide the name of the organization you want to delete. | ||
| You can get the list of organization 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' | ||
| requiredd_options["NEW_NAME"]='Error: You must provide the new name of the organization.\n\n' | ||
|
kcantrel marked this conversation as resolved.
Outdated
|
||
|
|
||
| check_required_options | ||
| # | ||
| # Check that the required commands are available. | ||
| for cmd in jq curl; do | ||
| if ! command -v $cmd &> /dev/null; then | ||
| echo "Error: The required command '$cmd' was not found. Please install it." >&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
| # | ||
| # Get an access token. | ||
| token=$(get_token) | ||
| if [ -z "$token" ]; then | ||
| echo "Failed to get a token." | ||
| exit 1 | ||
| fi | ||
| # | ||
| # Get the type and version. | ||
| run_curl "GET" "$token" "https://api.bluexp.netapp.com/v1/management/organizations/$ORGANIZATION_ID" $tmpout $tmperr | ||
| org_type=$(jq -r '.type' $tmpout) | ||
| org_version=$(jq -r '.version' $tmpout) | ||
| # | ||
| # Set the new name of the organization. | ||
| run_curl "PATCH" "$token" "https://api.bluexp.netapp.com/v1/management/organizations/$ORGANIZATION_ID" $tmpout $tmperr '{"name":"'$NEW_NAME'","type":"'$org_type'","version":"'$org_version'"}' | ||
124 changes: 124 additions & 0 deletions
124
Management-Utilities/Workload-Factory-API-Samples/cicd_clones_create
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| #!/bin/bash | ||
| # | ||
| ################################################################################ | ||
| # This script is used to create a EDA CI/CD clone. | ||
| # | ||
| # It is dependent on the 'wf_utils' file that is included in this repo. That | ||
| # file contains the 'get_token' function that is used to obtain a valid | ||
| # access token that is needed to run the Workload Factory APIs. The file needs | ||
| # to either be in the command search path or in the current directory. | ||
| ################################################################################ | ||
|
|
||
| ################################################################################ | ||
| # This function just prints the usage of this script and exits the program. | ||
| ################################################################################ | ||
| usage() { | ||
| cat >&2 <<EOF | ||
| This script is used to create a EDA CI/CD clone. | ||
|
|
||
| Usage: $(basename $0) -t refresh_token -a blueXP_account_ID -p project_id -n clone_name [-s snapshot_name] | ||
|
|
||
| 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. Run 'list_bluexp_accts' to get a | ||
| list of accounts you have access to. | ||
| project_id - is the ID of the EDA CI/CD project to list clones for. Run 'list_cicd_projects' to get a | ||
| list of projects you have access to. | ||
| clone_name - is the the name you want to assign to the clone. | ||
| snapshot_name - is the name of the snapshot to use as the source for the clone. | ||
| If not specified, the clone will be created from the volume's current state. | ||
| You can get a list of snapshots for the volume by running the 'list_snapshotst' script. | ||
|
|
||
| Instead of passing parameters on the command line, you can set the | ||
| following environment variables: | ||
|
|
||
| export REFRESH_TOKEN=<refresh_token> | ||
| export BLUEXP_ACCOUNT_ID=<blueXP_account_ID> | ||
| export PROJECT_ID=<project_id> | ||
| EOF | ||
| exit 1 | ||
| } | ||
|
|
||
| ################################################################################ | ||
| # Main logic starts here. | ||
| ################################################################################ | ||
| tmpout=$(mktemp /tmp/list_volumes-out.XXXXXX) | ||
| tmpout2=$(mktemp /tmp/list_volumes-out2.XXXXXX) | ||
| tmperr=$(mktemp /tmp/list_volumes-err.XXXXXX) | ||
| trap 'rm -f $tmpout $tmpout2 $tmperr' exit | ||
| # | ||
| # Source the wf_utils file. | ||
| wf_utils=$(command -v wf_utils) | ||
| if [ -z "$wf_utils" ]; then | ||
| if [ ! -x "./wf_utils" ]; then | ||
| cat >&2 <<EOF | ||
| Error: The 'wf_utils' script was not found in the current directory or in the command search path. | ||
| It is required to run this script. You can download it from: | ||
| https://github.com/NetApp/FSx-ONTAP-samples-scripts/tree/main/Management-Utilities/Workload-Factory-API-Samples | ||
| EOF | ||
| exit 1 | ||
| else | ||
| wf_utils=./wf_utils | ||
| fi | ||
| fi | ||
| . "$wf_utils" | ||
| # | ||
| # Process command line arguments. | ||
| SNAPSHOT_NAME="" | ||
| while getopts "ht:a:p:v:n:s:" opt; do | ||
| case $opt in | ||
| t) REFRESH_TOKEN="$OPTARG" ;; | ||
| a) BLUEXP_ACCOUNT_ID="$OPTARG" ;; | ||
| p) PROJECT_ID="$OPTARG" ;; | ||
| n) CLONE_NAME="$OPTARG" ;; | ||
| s) SNAPSHOT_NAME='"snapshotName": "'$OPTARG'",' ;; | ||
| *) usage ;; | ||
| esac | ||
| done | ||
| # | ||
| # Declare an array of required options and the error message to display if they are not set. | ||
| declare -A required_options | ||
| required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh tokon is required to run this script. It can be obtain from this web page: | ||
| https://services.cloud.netapp.com/refresh-token\n\n' | ||
| 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["PROJECT_ID"]='Error: The EDA CI/CD project ID is required to run this script. | ||
| You can get a list of projects you have access to by running the "list_cicd_projects" 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["CLONE_NAME"]='Error: The name of the clone to create is required to run this script.\n\n' | ||
|
|
||
| check_required_options | ||
| # | ||
| # Check that the required commands are available. | ||
| for cmd in jq curl; do | ||
| if ! command -v $cmd &> /dev/null; then | ||
| echo "Error: The required command '$cmd' not found. Please install it." >&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| token=$(get_token) | ||
| if [ -z "$token" ]; then | ||
| echo "Error: Failed to obtain an access token. Exiting." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| URL="https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/builders/v1/projects" | ||
| run_curl GET "$token" "$URL" $tmpout $tmperr | ||
| VOLUME_ID=$(jq -r '.items[] | select(.projectId == "'$PROJECT_ID'") | .volumeId' $tmpout) | ||
| if [ -z "$VOLUME_ID" ]; then | ||
| echo "Error: Failed to obtain the volume ID for the project. Exiting." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| body='{ | ||
| "cloneName": "'$CLONE_NAME'", | ||
| '$SNAPSHOT_NAME' | ||
| "parentVolumeId": "'$VOLUME_ID'" | ||
| }' | ||
|
|
||
| URL="https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/builders/v1/projects/${PROJECT_ID}/operations/clone" | ||
| run_curl POST "$token" "$URL" $tmpout $tmperr "$body" | ||
| echo "The CI/CD clone $CLONE_NAME was created and is mountable at $(jq -r '.mountPoints[0].mountPoint' $tmpout)." |
108 changes: 108 additions & 0 deletions
108
Management-Utilities/Workload-Factory-API-Samples/cicd_clones_delete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| #!/bin/bash | ||
| # | ||
| ################################################################################ | ||
| # This script is used to delete a EDA CI/CD clone. | ||
| # | ||
| # It is dependent on the 'wf_utils' file that is included in this repo. That | ||
| # file contains the 'get_token' function that is used to obtain a valid | ||
| # access token that is needed to run the Workload Factory APIs. The file needs | ||
| # to either be in the command search path or in the current directory. | ||
| ################################################################################ | ||
|
|
||
| ################################################################################ | ||
| # This function just prints the usage of this script and exits the program. | ||
| ################################################################################ | ||
| usage() { | ||
| cat >&2 <<EOF | ||
| This script is used to delete a EDA CI/CD clone. | ||
|
|
||
| Usage: $(basename $0) -t refresh_token -a blueXP_account_ID -p project_id -v clone_volume_id | ||
|
|
||
| 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. Run 'list_bluexp_accts' to get a | ||
| list of accounts you have access to. | ||
| project_id - is the ID of the EDA CI/CD project to list clones for. Run 'list_cicd_projects' to get a | ||
| list of projects you have access to. | ||
| clone_volume_id - is the ID of the volume that was created when the clone was provided that you want to delete. | ||
| Run 'list_cicd_clones' to get the ID of the clone volumes. | ||
|
|
||
| Instead of passing parameters on the command line, you can set the | ||
| following environment variables: | ||
|
|
||
| export REFRESH_TOKEN=<refresh_token> | ||
| export BLUEXP_ACCOUNT_ID=<blueXP_account_ID> | ||
| export PROJECT_ID=<project_id> | ||
| EOF | ||
| exit 1 | ||
| } | ||
|
|
||
| ################################################################################ | ||
| # Main logic starts here. | ||
| ################################################################################ | ||
| tmpout=$(mktemp /tmp/list_volumes-out.XXXXXX) | ||
| tmpout2=$(mktemp /tmp/list_volumes-out2.XXXXXX) | ||
| tmperr=$(mktemp /tmp/list_volumes-err.XXXXXX) | ||
| trap 'rm -f $tmpout $tmpout2 $tmperr' exit | ||
| # | ||
| # Source the wf_utils file. | ||
| wf_utils=$(command -v wf_utils) | ||
| if [ -z "$wf_utils" ]; then | ||
| if [ ! -x "./wf_utils" ]; then | ||
| cat >&2 <<EOF | ||
| Error: The 'wf_utils' script was not found in the current directory or in the command search path. | ||
| It is required to run this script. You can download it from: | ||
| https://github.com/NetApp/FSx-ONTAP-samples-scripts/tree/main/Management-Utilities/Workload-Factory-API-Samples | ||
| EOF | ||
| exit 1 | ||
| else | ||
| wf_utils=./wf_utils | ||
| fi | ||
| fi | ||
| . "$wf_utils" | ||
| # | ||
| # Process command line arguments. | ||
| while getopts "ht:a:p:v:" opt; do | ||
| case $opt in | ||
| t) REFRESH_TOKEN="$OPTARG" ;; | ||
| a) BLUEXP_ACCOUNT_ID="$OPTARG" ;; | ||
| p) PROJECT_ID="$OPTARG" ;; | ||
| v) CLONE_VOLUME_ID="$OPTARG" ;; | ||
| *) usage ;; | ||
| esac | ||
| done | ||
| # | ||
| # Declare an array of required options and the error message to display if they are not set. | ||
| declare -A required_options | ||
| required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh tokon is required to run this script. It can be obtain from this web page: | ||
| https://services.cloud.netapp.com/refresh-token\n\n' | ||
| 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["PROJECT_ID"]='Error: The EDA CI/CD project ID is required to run this script. | ||
| You can get a list of projects you have access to by running the "list_cicd_projects" 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["CLONE_VOLUME_ID"]='Error: The ID of the clone volume to delete is required to run this script. | ||
| You can get a list of clone volumes by running the "list_cicd_clones" script | ||
| found in this GitHub repository: https://github.com/NetApp/FSx-ONTAP-samples-scripts/tree/main/Management-Utilities/Workload-Factory-API-Samples\n\n' | ||
|
|
||
| check_required_options | ||
| # | ||
| # Check that the required commands are available. | ||
| for cmd in jq curl; do | ||
| if ! command -v $cmd &> /dev/null; then | ||
| echo "Error: The required command '$cmd' not found. Please install it." >&2 | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| token=$(get_token) | ||
| if [ -z "$token" ]; then | ||
| echo "Error: Failed to obtain an access token. Exiting." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| URL="https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/builders/v1/projects/${PROJECT_ID}/operations/clones/${CLONE_VOLUME_ID}" | ||
| run_curl DELETE "$token" "$URL" $tmpout $tmperr | ||
| echo "The CI/CD clone $CLONE_VOLUME_ID was deleted." |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.