# salt.cloud.clouds.gce

Copyright 2013 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

> http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

## Google Compute Engine Module

The Google Compute Engine module. This module interfaces with Google Compute Engine (GCE). To authenticate to GCE, you will need to create a Service Account. To set up Service Account Authentication, follow the Google Compute Engine Setup instructions.

### Example Provider Configuration

    my-gce-config:
      # The Google Cloud Platform Project ID
      project: "my-project-id"
      # The Service Account client ID
      service_account_email_address: 1234567890@developer.gserviceaccount.com
      # The location of the private key (PEM format)
      service_account_private_key: /home/erjohnso/PRIVKEY.pem
      driver: gce
      # Specify whether to use public or private IP for deploy script.
      # Valid options are:
      #     private_ips - The salt-master is also hosted with GCE
      #     public_ips - The salt-master is hosted outside of GCE
      ssh_interface: public_ips

maintainer:

  Eric Johnson <erjohnso@google.com>

maintainer:

  Russell Tolle <russ.tolle@gmail.com>

depends:

  libcloud >= 1.0.0

salt.cloud.clouds.gce.attach_disk(name=None, kwargs=None, call=None)

  Attach an existing disk to an existing instance.

  CLI Example:

      salt-cloud -a attach_disk myinstance disk_name=mydisk mode=READ_WRITE

salt.cloud.clouds.gce.attach_lb(kwargs=None, call=None)

  Add an existing node/member to an existing load-balancer configuration.

  CLI Example:

      salt-cloud -f attach_lb gce name=lb member=myinstance

salt.cloud.clouds.gce.avail_images(conn=None)

  Return a dict of all available VM images on the cloud provider with relevant data.

  Note that for GCE, there are custom images within the project, but the generic images are in other projects. This returns a dict of images in the project plus images in well-known public projects that provide supported images, as listed on this page: https://cloud.google.com/compute/docs/operating-systems/

  If image names overlap, the image in the current project is used.

salt.cloud.clouds.gce.avail_locations(conn=None, call=None)

  Return a dict of all available VM locations on the cloud provider with relevant data

salt.cloud.clouds.gce.avail_sizes(conn=None)

  Return a dict of available instances sizes (a.k.a machine types) and convert them to something more serializable.

salt.cloud.clouds.gce.create(vm_=None, call=None)

  Create a single GCE instance from a data dict.

salt.cloud.clouds.gce.create_address(kwargs=None, call=None)

  Create a static address in a region.

  CLI Example:

      salt-cloud -f create_address gce name=my-ip region=us-central1 address=IP

salt.cloud.clouds.gce.create_attach_volumes(name, kwargs, call=None)

  New in version 2017.7.0.

  Create and attach multiple volumes to a node. The 'volumes' and 'node' arguments are required, where 'node' is a libcloud node, and 'volumes' is a list of maps, where each map contains:

  size

    The size of the new disk in GB. Required.

  type

    The disk type, either pd-standard or pd-ssd. Optional, defaults to pd-standard.

  image

    An image to use for this new disk. Optional.

  snapshot

    A snapshot to use for this new disk. Optional.

  auto_delete

    An option(bool) to keep or remove the disk upon instance deletion. Optional, defaults to False.

  Volumes are attached in the order in which they are given, thus on a new node the first volume will be /dev/sdb, the second /dev/sdc, and so on.

salt.cloud.clouds.gce.create_disk(kwargs=None, call=None)

  Create a new persistent disk. Must specify disk_name and location, and optionally can specify 'disk_type' as pd-standard or pd-ssd, which defaults to pd-standard. Can also specify an image or snapshot but if neither of those are specified, a size (in GB) is required.

  CLI Example:

      salt-cloud -f create_disk gce disk_name=pd size=300 location=us-central1-b

salt.cloud.clouds.gce.create_fwrule(kwargs=None, call=None)

  Create a GCE firewall rule. The 'default' network is used if not specified.

  CLI Example:

      salt-cloud -f create_fwrule gce name=allow-http allow=tcp:80

salt.cloud.clouds.gce.create_hc(kwargs=None, call=None)

  Create an HTTP health check configuration.

  CLI Example:

      salt-cloud -f create_hc gce name=hc path=/healthy port=80

salt.cloud.clouds.gce.create_lb(kwargs=None, call=None)

  Create a load-balancer configuration.

  CLI Example:

      salt-cloud -f create_lb gce name=lb region=us-central1 ports=80

salt.cloud.clouds.gce.create_network(kwargs=None, call=None)

  Changed in version 2017.7.0.

  Create a GCE network. Must specify name and cidr.

  CLI Example:

      salt-cloud -f create_network gce name=mynet cidr=10.10.10.0/24 mode=legacy description=optional
      salt-cloud -f create_network gce name=mynet description=optional

salt.cloud.clouds.gce.create_snapshot(kwargs=None, call=None)

  Create a new disk snapshot. Must specify name and disk_name.

  CLI Example:

      salt-cloud -f create_snapshot gce name=snap1 disk_name=pd

salt.cloud.clouds.gce.create_subnetwork(kwargs=None, call=None)

  New in version 2017.7.0.

  Create a GCE Subnetwork. Must specify name, cidr, network, and region.

  CLI Example:

      salt-cloud -f create_subnetwork gce name=mysubnet network=mynet1 region=us-west1 cidr=10.0.0.0/24 description=optional

salt.cloud.clouds.gce.delete_address(kwargs=None, call=None)

  Permanently delete a static address.

  CLI Example:

      salt-cloud -f delete_address gce name=my-ip

salt.cloud.clouds.gce.delete_disk(kwargs=None, call=None)

  Permanently delete a persistent disk.

  CLI Example:

      salt-cloud -f delete_disk gce disk_name=pd

salt.cloud.clouds.gce.delete_fwrule(kwargs=None, call=None)

  Permanently delete a firewall rule.

  CLI Example:

      salt-cloud -f delete_fwrule gce name=allow-http

salt.cloud.clouds.gce.delete_hc(kwargs=None, call=None)

  Permanently delete a health check.

  CLI Example:

      salt-cloud -f delete_hc gce name=hc

salt.cloud.clouds.gce.delete_lb(kwargs=None, call=None)

  Permanently delete a load-balancer.

  CLI Example:

      salt-cloud -f delete_lb gce name=lb

salt.cloud.clouds.gce.delete_network(kwargs=None, call=None)

  Permanently delete a network.

  CLI Example:

      salt-cloud -f delete_network gce name=mynet

salt.cloud.clouds.gce.delete_snapshot(kwargs=None, call=None)

  Permanently delete a disk snapshot.

  CLI Example:

      salt-cloud -f delete_snapshot gce name=disk-snap-1

salt.cloud.clouds.gce.delete_subnetwork(kwargs=None, call=None)

  New in version 2017.7.0.

  Delete a GCE Subnetwork. Must specify name and region.

  CLI Example:

      salt-cloud -f delete_subnetwork gce name=mysubnet network=mynet1 region=us-west1

salt.cloud.clouds.gce.destroy(vm_name, call=None)

  Call 'destroy' on the instance. Can be called with "-a destroy" or -d

  CLI Example:

      salt-cloud -a destroy myinstance1 myinstance2 ...
      salt-cloud -d myinstance1 myinstance2 ...

salt.cloud.clouds.gce.detach_disk(name=None, kwargs=None, call=None)

  Detach a disk from an instance.

  CLI Example:

      salt-cloud -a detach_disk myinstance disk_name=mydisk

salt.cloud.clouds.gce.detach_lb(kwargs=None, call=None)

  Remove an existing node/member from an existing load-balancer configuration.

  CLI Example:

      salt-cloud -f detach_lb gce name=lb member=myinstance

salt.cloud.clouds.gce.get_configured_provider()

  Return the first configured instance.

salt.cloud.clouds.gce.get_conn()

  Return a conn object for the passed VM data

salt.cloud.clouds.gce.get_dependencies()

  Warn if dependencies aren't met.

salt.cloud.clouds.gce.get_lb_conn(gce_driver=None)

  Return a load-balancer conn object

salt.cloud.clouds.gce.list_nodes(conn=None, call=None)

  Return a list of the VMs that are on the provider

salt.cloud.clouds.gce.list_nodes_full(conn=None, call=None)

  Return a list of the VMs that are on the provider, with all fields

salt.cloud.clouds.gce.list_nodes_select(conn=None, call=None)

  Return a list of the VMs that are on the provider, with select fields

salt.cloud.clouds.gce.reboot(vm_name, call=None)

  Call GCE 'reset' on the instance.

  CLI Example:

      salt-cloud -a reboot myinstance

salt.cloud.clouds.gce.request_instance(vm_)

  Request a single GCE instance from a data dict.

  Changed in version 2017.7.0.

salt.cloud.clouds.gce.script(vm_)

  Return the script deployment object

salt.cloud.clouds.gce.show_address(kwargs=None, call=None)

  Show the details of an existing static address.

  CLI Example:

      salt-cloud -f show_address gce name=mysnapshot region=us-central1

salt.cloud.clouds.gce.show_disk(name=None, kwargs=None, call=None)

  Show the details of an existing disk.

  CLI Example:

      salt-cloud -a show_disk myinstance disk_name=mydisk
      salt-cloud -f show_disk gce disk_name=mydisk

salt.cloud.clouds.gce.show_fwrule(kwargs=None, call=None)

  Show the details of an existing firewall rule.

  CLI Example:

      salt-cloud -f show_fwrule gce name=allow-http

salt.cloud.clouds.gce.show_hc(kwargs=None, call=None)

  Show the details of an existing health check.

  CLI Example:

      salt-cloud -f show_hc gce name=hc

salt.cloud.clouds.gce.show_instance(vm_name, call=None)

  Show the details of the existing instance.

salt.cloud.clouds.gce.show_lb(kwargs=None, call=None)

  Show the details of an existing load-balancer.

  CLI Example:

      salt-cloud -f show_lb gce name=lb

salt.cloud.clouds.gce.show_network(kwargs=None, call=None)

  Show the details of an existing network.

  CLI Example:

      salt-cloud -f show_network gce name=mynet

salt.cloud.clouds.gce.show_pricing(kwargs=None, call=None)

  Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources.

  New in version 2015.8.0.

  CLI Examples:

      salt-cloud -f show_pricing my-gce-config profile=my-profile

salt.cloud.clouds.gce.show_snapshot(kwargs=None, call=None)

  Show the details of an existing snapshot.

  CLI Example:

      salt-cloud -f show_snapshot gce name=mysnapshot

salt.cloud.clouds.gce.show_subnetwork(kwargs=None, call=None)

  New in version 2017.7.0.

  Show details of an existing GCE Subnetwork. Must specify name and region.

  CLI Example:

      salt-cloud -f show_subnetwork gce name=mysubnet region=us-west1

salt.cloud.clouds.gce.start(vm_name, call=None)

  Call GCE 'start on the instance.

  New in version 2017.7.0.

  CLI Example:

      salt-cloud -a start myinstance

salt.cloud.clouds.gce.stop(vm_name, call=None)

  Call GCE 'stop' on the instance.

  New in version 2017.7.0.

  CLI Example:

      salt-cloud -a stop myinstance

salt.cloud.clouds.gce.update_pricing(kwargs=None, call=None)

  Download most recent pricing information from GCE and save locally

  CLI Examples:

      salt-cloud -f update_pricing my-gce-config

  New in version 2015.8.0.