github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/config/scripts/get_resource_availability.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright (c) 2020, 2021, Oracle and/or its affiliates.
     4  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     5  #
     6  
     7  if [ "$#" -ne 2 ]; then
     8      echo "Please specify the service and limit name"
     9      exit 1
    10  fi
    11  
    12  service_name=$1
    13  limit_name=$2
    14  
    15  if [ -z "${TF_VAR_compartment_id}" ] ; then
    16      echo "TF_VAR_compartment_id env var must be set!'"
    17      exit 1
    18  fi
    19  
    20  if [ -z "${TF_VAR_region}" ] ; then
    21      echo "TF_VAR_region env var must be set!'"
    22      exit 1
    23  fi
    24  
    25  set -o pipefail
    26  
    27  count=$(oci limits resource-availability get -c ${TF_VAR_compartment_id} --region ${TF_VAR_region} --service-name ${service_name} --limit-name ${limit_name} | jq ".data | .[\"available\"]")
    28  
    29  status_code=$?
    30  if [ ${status_code:-1} -eq 0 ]; then
    31    # OCI CLI query succeeded
    32    echo $count
    33  else
    34    # OCI CLI generated an error exit code
    35    echo "Error invoking OCI CLI to obtain resource availability of VCNs"
    36    exit 1
    37  fi
    38