Google-cloud-node: Create images

Created on 6 Oct 2016  路  3Comments  路  Source: googleapis/google-cloud-node

I'm attempting to automate our deployment process for compute engine, but I don't see any way to create images with this module. Is it possible?

Looking at the compute engine docs, it seems like it should be.

question compute

Most helpful comment

We currently don't support the Image API, however as a temporary workaround I think you can use Compute#request to make the request.

var compute = gcloud.compute();

compute.request({
  method: 'POST',
  uri: '/global/images',
  json: {
    name: 'image-name',
    rawDisk: {
      source: 'storage-path'
    }
  }
}, function(err, resp) {
  if (err) {
    // request error
  }

  var operation = compute.operation(resp.name);

  operation.on('complete', function() {
    // image is created
  });

  operation.on('error', function() {
    // error occured
  });
});

All 3 comments

We currently don't support the Image API, however as a temporary workaround I think you can use Compute#request to make the request.

var compute = gcloud.compute();

compute.request({
  method: 'POST',
  uri: '/global/images',
  json: {
    name: 'image-name',
    rawDisk: {
      source: 'storage-path'
    }
  }
}, function(err, resp) {
  if (err) {
    // request error
  }

  var operation = compute.operation(resp.name);

  operation.on('complete', function() {
    // image is created
  });

  operation.on('error', function() {
    // error occured
  });
});

Thanks for writing up that code @callmehiphop. That should indeed work.

We have an issue tracking all of the missing APIs from GCE that we still have to implement: #1073. Help is very welcome :)

@callmehiphop thanks for this!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sabrehagen picture sabrehagen  路  4Comments

bamapookie picture bamapookie  路  5Comments

stephenplusplus picture stephenplusplus  路  3Comments

charly37 picture charly37  路  3Comments

nicolasgarnier picture nicolasgarnier  路  4Comments