Skip to content
Merged
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
30 changes: 18 additions & 12 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
* @kcantrel
#
# Set the owner for all the individual samples, if the owner is known and they want to continue to maintain the sample:
/CloudFormation/deploy-fsx-ontap/ @kcantrel
/Ansible/fsx_inventory_report/ @kcantrel
/Ansible/snapmirror_report/ @kcantrel
/Infrastructure_as_Code/CloudFormation/deploy-fsx-ontap/ @kcantrel
/Infrastructure_as_Code/CloudFormation/Export-FSxN-CloudFormation/ @kcantrel
/Infrastructure_as_Code/CloudFormation/NetApp-FSxN-Custom-Resources-Samples/ @kcantrel
/Infrastructure_as_Code/Ansible/fsx_inventory_report/ @kcantrel
/Infrastructure_as_Code/Ansible/snapmirror_report/ @kcantrel
/Infrastructure_as_Code/Ansible/Volume_Management/ @kcantrel
/Infrastructure_as_Code/Terraform/Miscellaneous/ @kcantrel
/Infrastructure_as_Code/Terraform/deploy-fsx-ontap-sqlserver/ @varunrai
/Infrastructure_as_Code/Terraform/deploy-fsx-ontap-fileshare-access/ @varunrai
/Infrastructure_as_Code/Terraform/deploy-fsx-ontap/ @kcantrel
/Infrastructure_as_Code/Terraform/fsxn-replicate/ @nichollri
/EKS/FSxN-as-PVC-for-EKS/ @mickeysh
/EKS/Backup-EKS-Applications-with-Trident-Protect/ @kcantrel
/EKS/PV-Migrate-with-Trident-Protect/ @kcantrel
Expand All @@ -17,12 +25,10 @@
/Management-Utilities/fsxn-rotate-secret/ @kcantrel
/Management-Utilities/warm_performance_tier/ @kcantrel
/Management-Utilities/Workload-Factory-API-Samples/ @kcantrel
/Monitoring/CloudWatch-FSx/ @kcantrel
/Monitoring/LUN-monitoring/ @kcantrel
/Monitoring/auto-add-cw-alarms/ @kcantrel
/Monitoring/monitor-ontap-services/ @kcantrel
/Monitoring/ingest_nas_audit_logs_into_cloudwatch/ @kcantrel
/Terraform/deploy-fsx-ontap-sqlserver/ @varunrai
/Terraform/deploy-fsx-ontap-fileshare-access/ @varunrai
/Terraform/deploy-fsx-ontap/ @kcantrel
/Terraform/fsxn-replicate/ @nichollri
#
# All the monitoring samples have been moved to their own repo.
#/Monitoring/CloudWatch-FSx/ @kcantrel
#/Monitoring/LUN-monitoring/ @kcantrel
#/Monitoring/auto-add-cw-alarms/ @kcantrel
#/Monitoring/monitor-ontap-services/ @kcantrel
#/Monitoring/ingest_nas_audit_logs_into_cloudwatch/ @kcantrel
22 changes: 18 additions & 4 deletions Management-Utilities/Workload-Factory-API-Samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,40 @@ If you do create a new script, please consider contributing it back to this repo
| [bluexp_organization_add](bluexp_organization_add) | This adds a new BlueXP organization (a.k.a. account). |
| [bluexp_organization_delete](bluexp_organization_delete) | This deletes a BlueXP organization (a.k.a. account). |
| [bluexp_organization_rename](bluexp_organization_rename) | This renames a BlueXP organization (a.k.a. account). |
| [credentials_delete](credentials_delete) | This deletes a Workload Factory credential. |
| [bluexp_organization_member_add](bluexp_organization_member_add) | This adds a member to a BlueXP organization (a.k.a. account). |
| [bluexp_organization_member_delete](bluexp_organization_member_delete) | This deletes a member from a BlueXP organization (a.k.a. account). |
| [cicd_clones_create](cicd_clones_create) | This creates a clone in the specified CI/CD project. |
| [cicd_clones_delete](cicd_clones_delete) | This deletes a clone in the specified CI/CD project. |
| [cicd_project_create](cicd_project_create) | This creates a new CI/CD project. |
| [cicd_project_delete](cicd_project_delete) | This deletes a CI/CD project. |
| [credentials_create](credentials_create) | This create a Workload Factory credential. |
| [credentials_delete](credentials_delete) | This deletes a Workload Factory credential. |
| [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_details](get_latency_details) | Get the specific details of a latency event. |
| [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. |
| [link_disassociate](link_disassociate) | This disassociates a Workload Factory Link with a specified FSx for ONTAP file system. |
| [link_register](link_register) | This registers a Lambda function as a Workload Factory Link. |
| [list_bluexp_accts](list_bluexp_accts) | This list all the BlueXP accounts (a.k.a. organizations) that you have access to. |
| [list_bluexp_connectors](list_bluexp_connectors) | This list all the BlueXP connectors that you have access to. |
| [list_bluexp_members](list_bluexp_members) | This list all members of a provided BlueXP account. |
| [list_bluexp_organization_members](list_bluexp_organization_members) | This list all members of a provided BlueXP organization. |
| [list_bluexp_roles](list_bluexp_roles) | This list all the BlueXP roles that you have access to. |
| [list_bluexp_workspaces](list_bluexp_workspaces) | This list all the BlueXP workspaces that you have access to. |
| [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_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_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. |
| [list_svms](list_svms) | This lists all the SVMs that are associated with the specified file system. |
| [list_volumes](list_volumes) | This lists all the volumes that are associated with the specified file system. |
| [list_volume_cifs_shares](list_volume_cifs_shares) | This lists cifs shares associated with a volume in the specified file system. |
| [list_volumes](list_volumes) | This lists all the volumes that are associated with the specified file system. |
| [show_fsxn_credentials](show_fsxn_credentials) | This shows the credentials that Workload Factory has stored for the specified FSx for ONTAP file system. |
| [snapmirror_break](snapmirror_break) | This breaks the SnapMirror relationship for the specified relationship. |
| [snapmirror_create](snapmirror_create) | This creates a SnapMirror relationship between the specified source volume and destination SVM. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
################################################################################
usage () {
cat 1>&2 <<EOF
Usage: $(basename $0) -t REFRESH_TOKEN -o ORGANIZATION_NAME
Usage: $(basename $0) -t REFRESH_TOKEN -o ORGANIZATION_NAME [-e ENDPOINT] [-b BEARER_TOKEN] [-g]

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_NAME - Is the name of the organization to create.
ENDPOINT - Is the BlueXP API endpoint to use. The default is api.bluexp.netapp.com.
BEARER_TOKEN - Is an access token that can be used instead of a refresh token. If you
provide a bearer token, the script will not attempt to obtain a new
access token using the refresh token.
-g - If specified the account will be created in the GovCloud region.

Instead of passing parameters on the command line, you can set the following
environment variables:
Expand Down Expand Up @@ -46,21 +51,29 @@ fi
. "$wf_utils"
#
# Parse the command line options.
while getopts "ht:o:" opt; do
: "${ENDPOINT:=api.bluexp.netapp.com}"
GovCloud=false
while getopts "ht:o:e:b:g" opt; do
case ${opt} in
t) REFRESH_TOKEN=$OPTARG ;;
o) ORGANIZATION_NAME=$OPTARG ;;
e) ENDPOINT="$OPTARG" ;;
b) BEARER_TOKEN="$OPTARG" ;;
g) GovCloud=true ;;
*) 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_NAME"]='Error: You must provide the name of the organization you want to create.\n\n'

check_required_options

if [ -z "$REFRESH_TOKEN" -a -z "$BEARER_TOKEN" ]; then
echo "Error: You must provide either a refresh token or a bearer token." >&2
usage
fi
#
# Check that the required commands are available.
for cmd in jq curl; do
Expand All @@ -71,13 +84,19 @@ for cmd in jq curl; do
done
#
# Get an access token.
token=$(get_token)
if [ -z "$BEARER_TOKEN" ]; then
token=$(get_token)
else
token=$BEARER_TOKEN
fi

if [ -z "$token" ]; then
echo "Failed to get a token."
exit 1
fi
#
# Add the organization to the BlueXP workspace.
echo -n "Creating organization ${ORGANIZATION_NAME}..."
run_curl "POST" "$token" "https://api.bluexp.netapp.com/tenancy/account/$ORGANIZATION_NAME" $tmpout $tmperr '{"name": "'$ORGANIZATION_NAME'", "resourceType": "organization", "type": "application/vnd.netapp.bxp.resource", "version": "1.0"}' 'application/json'
#run_curl "POST" "$token" "https://$ENDPOINT/tenancy/account/$ORGANIZATION_NAME" $tmpout $tmperr '{"name": "'$ORGANIZATION_NAME'", "resourceType": "organization", "type": "application/vnd.netapp.bxp.resource", "version": "1.0"}' 'application/json'
run_curl "POST" "$token" "https://$ENDPOINT/tenancy/account/$ORGANIZATION_NAME" $tmpout $tmperr '{"isSaasDisabled": '$GovCloud'}' 'application/json'
echo "Done."
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
#!/bin/bash
#
# This script deletes an organization from a BlueXP account.
# This script deletes an BlueXP organization.
#
################################################################################
# Display usage information then exits the script.
################################################################################
usage () {
cat 1>&2 <<EOF
Usage: $(basename $0) -t REFRESH_TOKEN -o ORGANIZATION_ID
This script deletes an BlueXP organization.

Usage: $(basename $0) -t REFRESH_TOKEN -o ORGANIZATION_ID [-e ENDPOINT] [-b BEARER_TOKEN]

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.
ORGANIZATION_ID - Is the BlueXP Acct ID of the organization to delete.
You can get a list of organizations you have access to by running
the "list_bluexp_accts" script
ENDPOINT - The BlueXP API endpoint to use. Default is api.bluexp.netapp.com
BEARER_TOKEN - An optional access token that can be used instead of a refresh token.
If this parameter is provided, the script will use it directly instead of
trying to obtain an access token using the refresh token.

Instead of passing parameters on the command line, you can set the following
environment variables:
Expand Down Expand Up @@ -46,23 +54,31 @@ fi
. "$wf_utils"
#
# Parse the command line options.
while getopts "ht:o:" opt; do
: "${ENDPOINT:=api.bluexp.netapp.com}"
while getopts "ht:o:b:e:" opt; do
case ${opt} in
t) REFRESH_TOKEN=$OPTARG ;;
o) ORGANIZATION_ID=$OPTARG ;;
e) ENDPOINT=$OPTARG ;;
b) BEARER_TOKEN=$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.
#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 ID 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'

check_required_options

if [ -z "$REFRESH_TOKEN" -a -z "$BEARER_TOKEN" ]; then
echo "Error: You must provide either a refresh token or a bearer token to run this script." >&2
usage
fi
#
# Check that the required commands are available.
for cmd in jq curl; do
Expand All @@ -73,12 +89,17 @@ for cmd in jq curl; do
done
#
# Get an access token.
token=$(get_token)
if [ -z "$BEARER_TOKEN" ]; then
token=$(get_token)
else
token="$BEARER_TOKEN"
fi

if [ -z "$token" ]; then
echo "Failed to get a token."
exit 1
fi
#
echo -n "Deleting organization ${ORGANIZATION_ID}..."
run_curl "DELETE" "$token" "https://api.bluexp.netapp.com/v1/management/organizations/$ORGANIZATION_ID" $tmpout $tmperr
run_curl "DELETE" "$token" "https://$ENDPOINT/tenancy/account/$ORGANIZATION_ID" $tmpout $tmperr
echo "Done."
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/bash
#
# This script adds a user to an BlueXP organization.
#
################################################################################
# Display usage information then exits the script.
################################################################################
usage () {
cat 1>&2 <<EOF
This script adds a user to an BlueXP organization.

Usage: $(basename $0) -t REFRESH_TOKEN -o ORGANIZATION_ID -r ROLE_ID -E email_address [-e ENDPOINT] [-b BEARER_TOKEN]

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 add the user to. You can get
a list of organizations by running the list_bluexp_acct script.
ROLE_ID - Is the ID of the role to assign to the user. You can get a list of
roles by running the list_bluexp_roles script.
email_address - Is the email address of the user to add to the organization.
ENDPOINT - Is the BlueXP API endpoint to use. The default is api.bluexp.netapp.com.
BEARER_TOKEN - Is an access token that can be used instead of a refresh token. If you
provide a bearer token, the script will not attempt to obtain a new
access token using the refresh token.

Instead of passing parameters on the command line, you can set the following
environment variables:

export REFRESH_TOKEN=<REFRESH_TOKEN>
ORGANIZATION_ID=<ORGANIZATION_ID>
EOF
exit 1
}

################################################################################
# Main logic starts here.
################################################################################
tmpout=$(mktemp /tmp/add_organization_to_bluexp-out.XXXXXX)
tmperr=$(mktemp /tmp/add_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.
: "${ENDPOINT:=api.bluexp.netapp.com}"
while getopts "ht:o:e:b:r:E:" opt; do
case ${opt} in
t) REFRESH_TOKEN=$OPTARG ;;
o) ORGANIZATION_ID=$OPTARG ;;
r) ROLE_ID=$OPTARG ;;
E) emailAddress=$OPTARG ;;
e) ENDPOINT="$OPTARG" ;;
b) BEARER_TOKEN="$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["ORGANIZATION_ID"]='Error: You must provide the ID of the organization you want to add the user to.\n\n'
required_options["ROLE_ID"]='Error: You must provide the ID of the role you want to assign to the user.\n\n'
required_options["emailAddress"]='Error: You must provide the email address of the user you want to add.\n\n'

check_required_options

if [ -z "$REFRESH_TOKEN" -a -z "$BEARER_TOKEN" ]; then
echo "Error: You must provide either a refresh token or a bearer token." >&2
usage
fi
#
# 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.
if [ -z "$BEARER_TOKEN" ]; then
token=$(get_token)
else
token=$BEARER_TOKEN
fi

if [ -z "$token" ]; then
echo "Failed to get a token."
exit 1
fi
#
# This uses the same API that the console uses.
run_curl "POST" "$token" "https://$ENDPOINT/v1/management/organizations/$ORGANIZATION_ID/roles/$ROLE_ID/users" $tmpout $tmperr '{"type":"application/vnd.netapp.bxp.userbulk","users":[{"emailId": "'$emailAddress'"}], "version":"1.0"}' 'application/json'
echo "Done."
Loading
Loading