function gcp_project() { gcloud config get-value core/project 2> /dev/null } function gcp_get_project_id() { gcloud projects list \ --filter="$1" \ --format="value(project_id)" \ 2> /dev/null } function gcp_get_project_number() { gcloud projects list \ --filter="project_id:$1" \ --format='value(project_number)' \ 2> /dev/null } function gcp_get_regions() { gcloud compute regions list --format="value(name)" } function gcp_get_region_quotas() { region_arr_list=( $(gcloud compute regions list --format="value(name)") ) for region in ${region_arr_list[@]}; do echo -e $region\\\t$(gcloud compute regions describe $region --format="table(quotas:format='table(metric,limit,usage)')" | grep PREEMPTIBLE_CPUS ) done #for region in {us-central1,us-east1,us-east4,us-west1,us-west2,us-west3,us-west4}; do # echo -e $region\\\t$(gcloud compute regions describe $region --format="table(quotas:format='table(metric,limit,usage)')" | grep PREEMPTIBLE_CPUS ) #done } function gcp_get_stack() { local N="${1:-$(basename $PWD)}" local _cmd="{ $(printf "%s " \ "N='$N'; CLOUDSDK_ACTIVE_CONFIG_NAME=dust-personal; echo 'Listing $N stack:'; " \ '{ gcloud compute networks list --filter="name:$N" | ' "sed s/^/Networks.:\ /g ; } " \ '&& { gcloud compute networks subnets list --filter="name:$N" | ' "sed s/^/Subnets..:\ /g ; } " \ '&& { gcloud compute disks list --filter="name:$N" | ' "sed s/^/Disks....:\ /g ; } " \ '&& { gcloud compute instances list --filter="name:$N" | ' "sed s/^/Instances:\ /g ; } " \ ) ;}" [ $# -ge 2 ] && _cmd="watch -n${2} '$_cmd'" [[ -n ${SZ_DEBUG} ]] && printf "Executing: \n\t$_cmd\n\n" eval $_cmd } # printf '\n\n'; gcp_get_stack 'dragonheart' 5 function gcp_region() { gcloud config get-value compute/region 2> /dev/null }