0

I want to create a Google Compute Engine instance using the Python api. In particular, I want the source image to be Ubuntu 14.04.

In the doc, it is written to specify the json body of the request as follows:

{
  "name": "example-instance",
  "machineType": "zones/us-central1-f/machineTypes/f1-micro"
  "networkInterfaces": [{
    "accessConfigs": [{
      "type": "ONE_TO_ONE_NAT",
      "name": "External NAT"
     }],
    "network": "global/networks/default"
  }],
  "disks": [{
     "autoDelete": "true",
     "boot": "true",
     "type": "PERSISTENT",
     "initializeParams": {
        "sourceImage": "projects/debian-cloud/global/images/v20150818"
     }
   }]
}

How can I modify the sourceImage parameter value so that it points to the ubuntu 14.04 image? Indeed, the syntax "projects/debian-cloud/global/images/v20150818" is too specific to understand how to use it for other public images.

1 Answer 1

1

I am guessing you're referring to these docs (source code) which use the following URL format:

"projects/debian-cloud/global/images/debian-7-wheezy-v20150320"

The pattern here is:

"projects/${PROJECT}/global/images/${IMAGE}"

You can find the available images via:

$ gcloud compute images list

which will show you output similar to the following:

NAME                                PROJECT            ALIAS              DEPRECATED STATUS
centos-6-v20151104                  centos-cloud       centos-6                      READY
centos-7-v20151104                  centos-cloud       centos-7                      READY
coreos-alpha-891-0-0-v20151211      coreos-cloud                                     READY
coreos-beta-877-1-0-v20151202       coreos-cloud                                     READY
coreos-stable-835-9-0-v20151208     coreos-cloud       coreos                        READY
backports-debian-7-wheezy-v20151104 debian-cloud       debian-7-backports            READY
debian-7-wheezy-v20151104           debian-cloud       debian-7                      READY
debian-8-jessie-v20151104           debian-cloud       debian-8                      READY
container-vm-v20151103              google-containers  container-vm                  READY
opensuse-13-1-v20150822             opensuse-cloud     opensuse-13                   READY
opensuse-13-2-v20150511             opensuse-cloud     opensuse-13                   READY
opensuse-leap-42-1-v20151124        opensuse-cloud                                   READY
rhel-6-v20151104                    rhel-cloud         rhel-6                        READY
rhel-7-v20151104                    rhel-cloud         rhel-7                        READY
sles-11-sp4-v20150714               suse-cloud         sles-11                       READY
sles-12-sp1-v20151215               suse-cloud         sles-12                       READY
ubuntu-1204-precise-v20151119       ubuntu-os-cloud    ubuntu-12-04                  READY
ubuntu-1404-trusty-v20151113        ubuntu-os-cloud    ubuntu-14-04                  READY
ubuntu-1504-vivid-v20151120         ubuntu-os-cloud    ubuntu-15-04                  READY
ubuntu-1510-wily-v20151114          ubuntu-os-cloud                                  READY
windows-server-2008-r2-dc-v20151006 windows-cloud      windows-2008-r2               READY
windows-server-2012-r2-dc-v20151006 windows-cloud      windows-2012-r2               READY

So in the case of Ubuntu 14.04, the image path would be:

"projects/ubuntu-os-cloud/global/images/ubuntu-1404-trusty-v20151113"

You can also find out more metadata about an image via:

$ gcloud compute images describe --project ubuntu-os-cloud ubuntu-1404-trusty-20151113

and the selfLink attribute in the output will provide a full URL to the image.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.