InstanceGroupManager

InstanceGroupManager

A managed instance group uses an instance template to create a group of identical instances. You control a managed instance group as a single entity.

Constructor

new InstanceGroupManager(zone, name)

Parameters:
Name Type Description
zone Zone
name string
See:
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

Members

id :string

Methods

abandonInstances(vms, callback)

Flags the specified instances to be removed from the managed instance group.

Parameters:
Name Type Description
vms VM | Array.<VM>

VM instances to abandon from this instance group manager.

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

operation Operation

An operation object that can be used to check the status of the request.

apiResponse object

The full API response.

See:
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

const vms = [
  gce.zone('us-central1-a').vm('http-server'),
  gce.zone('us-central1-a').vm('https-server')
];

instanceGroupManager.abandonInstances(vms, function(err, operation, apiResponse) {
  // `operation` is an Operation object that can be used to check the status
  // of the request.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.abandonInstances(vms).then(function(data) {
  const operation = data[0];
  const apiResponse = data[1];
});

deleteInstances(vms, callback)

Flags the specified instances in the managed instance group for immediate deletion.

Parameters:
Name Type Description
vms VM | Array.<VM>

VM instances to delete from this instance group manager.

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

operation Operation

An operation object that can be used to check the status of the request.

apiResponse object

The full API response.

See:
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

const vms = [
  gce.zone('us-central1-a').vm('http-server'),
  gce.zone('us-central1-a').vm('https-server')
];

instanceGroupManager.deleteInstances(vms, function(err, operation, apiResponse) {
  // `operation` is an Operation object that can be used to check the status
  // of the request.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.deleteInstances(vms).then(function(data) {
  const operation = data[0];
  const apiResponse = data[1];
});

exists(callback)

Check if the instance group manager exists.

Parameters:
Name Type Description
callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

exists boolean

Whether the instance group manager exists or not.

Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

instanceGroupManager.exists(function(err, exists) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.exists().then(function(data) {
  const exists = data[0];
});

get(optionsopt)

Get an instance group manager if it exists.

You may optionally use this to "get or create" an object by providing an object with autoCreate set to true. Any extra configuration that is normally required for the create method must be contained within this object as well.

Parameters:
Name Type Attributes Description
options options <optional>

Configuration object.

Properties
Name Type Description
autoCreate boolean

Automatically create the object if it does not exist. Default: false

Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

instanceGroupManager.get(function(err, instanceGroupManager, apiResponse) {
  // `instanceGroupManager` is an InstanceGroupManager object.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.get().then(function(data) {
  const instanceGroupManager = data[0];
  const apiResponse = data[1];
});

getManagedInstances(optionsopt, callback)

Get a list of managed VM instances in this instance group manager.

Parameters:
Name Type Attributes Description
options object <optional>

Instance search options.

Properties
Name Type Description
autoPaginate boolean

Have pagination handled automatically. Default: true.

filter string

Search filter in the format of {name} {comparison} {filterString}. - name: the name of the field to compare - comparison: the comparison operator, eq (equal) or ne (not equal) - filterString: the string to filter to. For string fields, this can be a regular expression.

maxApiCalls number

Maximum number of API calls to make.

maxResults number

Maximum number of VMs to return.

pageToken string

A previously-returned page token representing part of the larger set of results to view.

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

vms Array.<VM>

VM objects from this instance group.

apiResponse object

The full API response.

See:
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

instanceGroupManager.getManagedInstances(function(err, vms) {
  // `vms` is an array of `VM` objects.
});

//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, vms, nextQuery, apiResponse) {
  if (nextQuery) {
    // More results exist.
    instanceGroupManager.getManagedInstances(nextQuery, callback);
  }
}

instanceGroupManager.getManagedInstances({
  autoPaginate: false
}, callback);

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.getManagedInstances().then(function(data) {
  const vms = data[0];
});

getMetadata(callbackopt)

Get the instance group manager's metadata.

Parameters:
Name Type Attributes Description
callback function <optional>

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

metadata object

The instance group manager's metadata.

apiResponse object

The full API response.

See:
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

instanceGroupManager.getMetadata(function(err, metadata, apiResponse) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.getMetadata().then(function(data) {
  const metadata = data[0];
  const apiResponse = data[1];
});

resize(size, callback)

Resizes the managed instance group.

Parameters:
Name Type Description
size number

The number of running instances that the managed instance group should maintain at any given time.

callback function

The callback function.

Properties
Name Type Attributes Description
err error <nullable>

An error returned while making this request.

operation Operation

An operation object that can be used to check the status of the request.

apiResponse object

The full API response.

See:
Example
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

instanceGroupManager.resize(2, function(err, operation, apiResponse) {
  // `operation` is an Operation object that can be used to check the status
  // of the request.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.resize(2).then(function(data) {
  const operation = data[0];
  const apiResponse = data[1];
});