Skip to content

Instantly share code, notes, and snippets.

@Chan9390
Created May 10, 2019 15:09
Show Gist options
  • Save Chan9390/e639997ad577d1f7499fa1adf5d50857 to your computer and use it in GitHub Desktop.
Save Chan9390/e639997ad577d1f7499fa1adf5d50857 to your computer and use it in GitHub Desktop.

Revisions

  1. Chan9390 created this gist May 10, 2019.
    9 changes: 9 additions & 0 deletions get_gcp_vm_os.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    echo Project Name,Disk Name,Source Image
    for projectname in `gcloud projects list --format json | jq -r '.[].projectId'`; do
    gcloud compute disks list -q --project $projectname --format json | \
    jq -r '.[] | ["\(.name)", "\(.sourceImage)"] | @tsv' | \
    while IFS=$'\t' read -r diskname sourceimage; do
    os=`echo $sourceimage | awk -F "/" '{print $NF}'`;
    echo $projectname,$diskname,$os;
    done;
    done