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

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>
depends:libcloud >= 0.14.1
salt.cloud.clouds.gce.attach_disk(name=None, kwargs=None, call=None)

Attach an existing disk to an existing instance.

命令行接口CLI 范例:

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 范例:

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)

返回一个字典,包含所有在云服务商可用的VM路径和相关数据

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 范例:

salt-cloud -f create_address gce name=my-ip region=us-central1 address=IP
salt.cloud.clouds.gce.create_disk(kwargs=None, call=None)

Create a new persistent disk. Must specify disk_name and location. Can also specify an image or snapshot but if neither of those are specified, a size (in GB) is required.

命令行接口CLI 范例:

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 范例:

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 范例:

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 范例:

salt-cloud -f create_lb gce name=lb region=us-central1 ports=80
salt.cloud.clouds.gce.create_network(kwargs=None, call=None)

Create a GCE network.

命令行接口CLI 范例:

salt-cloud -f create_network gce name=mynet cidr=10.10.10.0/24
salt.cloud.clouds.gce.create_snapshot(kwargs=None, call=None)

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

命令行接口CLI 范例:

salt-cloud -f create_snapshot gce name=snap1 disk_name=pd
salt.cloud.clouds.gce.delete_address(kwargs=None, call=None)

Permanently delete a static address.

命令行接口CLI 范例:

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 范例:

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 范例:

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 范例:

salt-cloud -f delete_hc gce name=hc
salt.cloud.clouds.gce.delete_lb(kwargs=None, call=None)

Permanently delete a load-balancer.

命令行接口CLI 范例:

salt-cloud -f delete_lb gce name=lb
salt.cloud.clouds.gce.delete_network(kwargs=None, call=None)

Permanently delete a network.

命令行接口CLI 范例:

salt-cloud -f delete_network gce name=mynet
salt.cloud.clouds.gce.delete_snapshot(kwargs=None, call=None)

Permanently delete a disk snapshot.

命令行接口CLI 范例:

salt-cloud -f delete_snapshot gce name=disk-snap-1
salt.cloud.clouds.gce.destroy(vm_name, call=None)

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

命令行接口CLI 范例:

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 范例:

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 范例:

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 范例:

salt-cloud -a reboot myinstance
salt.cloud.clouds.gce.request_instance(vm_)

Request a single GCE instance from a data dict.

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 范例:

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 范例:

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 范例:

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 范例:

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 范例:

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 范例:

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.

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 范例:

salt-cloud -f show_snapshot gce name=mysnapshot
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

2015.8.0 新版功能.