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 _cmd=$(printf 'N="%s"; CLOUDSDK_ACTIVE_CONFIG_NAME=dust-personal; echo $N; ' $1) _cmd+='{ echo "Instances"; gcloud compute instances list --filter="name:$N"; } ' _cmd+='&& { echo "Networks"; gcloud compute networks list --filter="name:$N"; } ' _cmd+='&& {gcloud compute networks subnets list --filter="name:$N"} ' _cmd+='&& {gcloud compute disks list --filter="name:$N"}' _cmd='{ }' [ $# -ge 2 ] && _cmd="watch -n${2} '$_cmd'" echo $_cmd } # printf '\n\n'; gcp_get_stack 'dragonheart' 5 function gcp_region() { gcloud config get-value compute/region 2> /dev/null }