%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/thread-self/root/lib/python2.7/site-packages/salt/cloud/clouds/
Upload File :
Create Path :
Current File : //proc/thread-self/root/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZdZy�ddlZddlmZddlmZddlmZddlmZddlmZmZeej�ed	�kr2ddlZej j!j"d
�ne#Z$Wn#e%k
r^ej&�Ze'Z$nXddl(m)Z)ddl*m+Z+ddl,Z-ddl.Z-ddl/Z-ddl0j1Z1dd
l2Tddl3m4Z4e	j5e6�Z7dZ8dZ9dZ:e)e;e<��Z;e)e=e<��Z=e)e>e<��Z>e)e?e<��Z?e)e@e<��Z@e)eAe<��ZAejBd�ZCd�ZDd�ZEd�ZFdd�ZGd�ZHd�ZId�ZJd�ZKd�ZLd�ZMdd�ZNdd�ZOdd�ZPd �ZQd!�ZRd"�ZSd#�ZTd$�ZUd%�ZVd&�ZWd'�ZXd(�ZYd)�ZZd*�Z[d+�Z\d,�Z]ddd-�Z^ddd.�Z_ddd/�Z`ddd0�Zaddd1�Zbddd2�Zcddd3�Zdddd4�Zeddd5�Zfddd6�Zgddd7�Zhddd8�Ziddd9�Zjddd:�Zkddd;�Zlddd<�Zmddd=�Znddd>�Zoddd?�Zpddd@�ZqdddA�ZrdddB�ZsdddC�ZtdddD�ZuddddE�ZvdddF�ZwddddG�ZxddddH�ZyddI�ZzddJ�Z{ddK�Z|ddL�Z>ddM�Z}dN�Z~dddO�ZdddP�Z�dddQ�Z�dS(Ru�
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 :ref:`gce_setup` instructions.

Example Provider Configuration
------------------------------

.. code-block:: yaml

    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
i(tabsolute_importtprint_functiontunicode_literalsN(tliteral_eval(tLooseVersion(tProvider(t
get_driver(tResourceInUseErrortResourceNotFoundErroru1.4.0u/etc/ssl/certs/YaST-CA.pem(tnamespaced_function(tsix(t*(tSaltCloudSystemExitugceu
salt-cloudu0.2.0u'^(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)$cC@s�t�tkrtSt�tkr&tSx{tjtd�D]f\}}d|krXq:n|d}tjj|d�}|r:t	j
jj||�tkr:tSq:Wt
S(uI
    Set up the libcloud functions and check for GCE configurations.
    u	providersugceuservice_account_private_key(tget_configured_providertFalsetget_dependenciesR
t	iteritemst__opts__tostpatht
expandusertsalttutilstcloudtcheck_key_path_and_modet__virtualname__(tprovidertdetailst
parameterstpathname((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt__virtual__ys 
		cC@stjttpdd�S(u/
    Return the first configured instance.
    ugceuprojectuservice_account_email_addressuservice_account_private_key(uprojectuservice_account_email_addressuservice_account_private_key(tconfigtis_provider_configuredRt__active_provider_name__(((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyR
�s	cC@s@tr)tjddt�tjd�ntjtitd6�S(u*
    Warn if dependencies aren't met.
    u!Failure when importing LibCloud: texc_infouFNote: The libcloud dependency is called 'apache-libcloud' on PyPi/pip.ulibcloud(tLIBCLOUD_IMPORT_ERRORtlogterrorRtcheck_driver_dependenciesRtHAS_LIBCLOUD(((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyR�scC@s+|std��nttj�d|�S(u,
    Return a load-balancer conn object
    u*Missing gce_driver for get_lb_conn method.t
gce_driver(Rt
get_driver_lbtProvider_lbtGCE(R(((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytget_lb_conn�scC@s�ttj�}t�}tjd|t�}tjd|t�}tjd|t�}|||d|�}|jjdj	t
t��|S(u5
    Return a conn object for the passed VM data
    uprojectuservice_account_email_addressuservice_account_private_keytprojectu{0}/{1}(RRR+R
Rtget_cloud_config_valueRt
connectiontuser_agent_appendtformatt_UA_PRODUCTt_UA_VERSION(tdriverRR-temailtprivate_keytgce((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytget_conn�s			
cC@si}|j|j�|S(uG
    Convert the libcloud object into something more serializable.
    (tupdatet__dict__(titemtret((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt_expand_item�scC@s�i}|j|j�y|dd=Wntk
r8nX|dd}i|dd<|ddj|j�d|kr�|d=nd|ddkr�|ddd=n|S(uL
    Convert the libcloud Node object into something more serializable.
    uextrau	boot_diskuzoneudriver(R9R:t	Exception(tnodeR<tzone((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt_expand_node�s

cC@sNi}|j|j�|dd}i|dd<|ddj|j�|S(uN
    Convert the libcloud Volume object into something more serializable.
    uextrauzone(R9R:(tdiskR<R@((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt_expand_disk�scC@s.i}|j|j�|jj|dd<|S(uR
    Convert the libcloud GCEAddress object into something more serializable.
    uextrauzone(R9R:tregiontname(taddyR<((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt_expand_address�sc
C@s=i}|j|j�|dd}g|dd<x)|D]!}|ddjt|��q9W|dd}|ddj}|ddj}i|dd<|ddj|j�|j|ddd<|j|ddd<|dd}|ddj}|ddj}|ddj}|ddjj	}	i|dd<|ddj|j�t|�|ddd<g|ddd<x-|D]%}
|dddjt
|
��q�Wg|ddd<x*|D]"}|dddj|j�q�Wg|dddd<x.|	D]&}|ddddj|j�qW|S(uU
    Convert the libcloud load-balancer object into something more serializable.
    uextrauhealthchecksuforwarding_ruleu
targetpooluregionunodesuzones(R9R:tappendR=t
targetpoolRDREthealthcheckstnodestzonesRA(
tlbR<thcR;tfwrttptregRKRDRLtnthcitz((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt_expand_balancers>

#
 
$cC@sQ|dkrtd��nt�}t|j|��}td|tt�|S(u4
    Show the details of the existing instance.
    uactionu<The show_instance action must be called with -a or --action.ucloud.cache_node(RR8RAtex_get_nodet	__utils__R!R(tvm_nametcalltconnR?((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt
show_instance*s	cC@s�|st�}n|jd�}g}xb|D]Z}|jd}i|jd<|jdj|j�i}|j|j�|j|�q.W|S(u
    Return a dict of available instances sizes (a.k.a machine types) and
    convert them to something more serializable.
    ualluzone(R8t
list_sizestextraR9R:RH(RZt	raw_sizestsizestsizeR@tmtype((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytavail_sizes8s


c	C@s�|st�}ng}d}x$|D]}|j|j|��q%W|j|j��i}xa|D]Y}i||j<xCt|�D]5}|jd
�r�q�nt||�||j|<q�WqeW|S(u�
    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.
    ucentos-clouducoreos-cloududebian-cloudugoogle-containersuopensuse-cloudu
rhel-cloudu
suse-clouduubuntu-os-cloudu
windows-cloudu_(	ucentos-clouducoreos-cloududebian-cloudugoogle-containersuopensuse-cloudu
rhel-cloudu
suse-clouduubuntu-os-cloudu
windows-cloud(R8textendtlist_imagesREtdirt
startswithtgetattr(RZt
all_imagestpublic_image_projectsR-R<timgtattr((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytavail_imagesKs"



"cC@s.tjd|tdddt�}|j|�S(u_
    The get_image for GCE allows partial name matching and returns a
    libcloud object.
    uimagetdefaultudebian-7t
search_global(RR.RRtex_get_image(RZtvm_Rj((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt__get_imageuscC@s"tjd|t�}|j|�S(u5
    Need to override libcloud to find the zone.
    ulocation(RR.Rtex_get_zone(RZRptlocation((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt__get_locationscC@s:tjd|tdddt�}|j|t||��S(uP
    Need to override libcloud to find the machine type in the proper zone.
    usizeRmu
n1-standard-1Rn(RR.RRtex_get_sizeRt(RZRpR`((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt
__get_size�scC@sotjd|tdddt�}yt|�}Wntk
rJd}nX|sbt|t�rkd}n|S(u
    Get configured tags.
    utagsRmu[]RnN(	RR.RRRR>tNonet
isinstancetlist(Rpttttags((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt
__get_tags�s

	cC@s�tjd|tdddt�}yt|�}Wntk
rJd
}nX|sbt|t�r�iidd6|dd6gd	6}n\|d|d<g}x8t	j
|�D]'\}}|ji|d6|d6�q�Wi|d	6}|S(u?
    Get configured metadata and add 'salt-cloud-profile'.
    umetadataRmu{}Rnusalt-cloud-profileukeyuprofileuvalueuitemsN(RR.RRRR>RwRxtdictR
RRH(Rptmdtmetadatatitemstktv((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt__get_metadata�s"


cC@spt|�dks"|ddkrB|jd}tjd|�n|jd}tjd|�|ri|S|jS(uR
    Return public IP, private IP, or hostname for the libcloud 'node' object
    uprivate_ipsuexternal_ipiuSalt node data. Private_ip: %suSalt node data. Public_ip: %sN(t__get_ssh_interfaceRwtprivate_ipsR$tinfot
public_ipsRE(R?Rpt
ip_address((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt
__get_host�s"

cC@s.tjd|tdddt�}|j|�S(uA
    Return a GCE libcloud network object with matching name
    unetworkRmudefaultRn(RR.RRtex_get_network(RZRptnetwork((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt
__get_network�scC@stjd|tdt�}|S(u$
    Get configured subnetwork.
    u
subnetworkRn(RR.RR(Rpt
ex_subnetwork((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt__get_subnetwork�s	cC@s;t||�}dj|jjd�d �}|j|�S(uA
    Return a GCE libcloud region object with matching name.
    u-i(RttjoinREtsplitt
ex_get_region(RZRpRsRD((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt__get_region�scC@stjd|tdddt�S(uj
    Return the ssh_interface type to connect to. Either 'public_ips' (default)
    or 'private_ips'.
    u
ssh_interfaceRmu
public_ipsRn(RR.RR(Rp((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyR��scC@sky|j||�}WnNtk
rfi|d6|d6}t|d�}|j|d|d�}nX|S(un
    Reuse or create a static IP address.
    Returns a native GCEAddress construct to use with libcloud.
    unameuregionufunction(tex_get_addressRtcreate_address(RZRERDRFtaddr_kwargstnew_addy((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt__create_orget_address�s

cC@sAi}g}|jd�}x�|D]�}|jd�}|dj�dkritdj|d���nt|�dks�|dj�dkr�g||d<q"|d|kr�|dg||d<q"||dj|d�q"WxC|D];}i|d	6}||r|||d
<n|j|�q�Wtjd|�|S(
uQ
    Convert firewall rule allowed user-string to specified REST API format.
    u,u:iutcpuudpuicmpu4Unsupported protocol {0}. Must be tcp, udp, or icmp.iu
IPProtocoluportsu$firewall allowed protocols/ports: %s(utcpuudpuicmp(R�tlowerRR1tlenRHR$tdebug(tallowtseen_protost
allow_dictt	protocolstptpairsR�td((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt_parse_allows*

(


cC@sUtjd|tdtjd��}tjd|tdtjjd��}||fS(u)
    Get configured SSH credentials.
    ussh_usernameRmuUSERussh_keyfileu~/.ssh/google_compute_engine(RR.RRtgetenvRR(Rptssh_usertssh_key((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt__get_ssh_credentials0sc
C@sg|dkrtd��n|s.d|kr?tjd�tS|jdd�}|jdd�}|dkr�|dkr�tjd�tS|d}|jd	d�}t�}td
ddd
di|d6|d6|d	6|d6dtddtd�|j	||||�}td
ddddi|d6|d6|d	6|d6dtddtd�t
|�S(u;
    ... versionchanged:: 2017.7.0
    Create a GCE network. Must specify name and cidr.

    CLI Example:

    .. code-block:: bash

        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
    ufunctionuAThe create_network function must be called with -f or --function.unameu1A name must be specified when creating a network.umodeulegacyucidruFA network CIDR range must be specified when creating a legacy network.udescriptionucloud.fire_eventueventucreating networkusalt/cloud/net/creatingtargstsock_dirusock_dirt	transportu	transportucreated networkusalt/cloud/net/createdN(RR$R%RtgetRwR8RWRtex_create_networkR=(tkwargsRYtmodetcidrREtdescRZR�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytcreate_network<sP
	



cC@s|dkrtd��n|s.d|kr?tjd�tS|d}t�}tddddd	i|d6d
tddtd
�y|j|j|��}Wn0t	k
r�}tjd||dt
j�tSXtddddd	i|d6d
tddtd
�|S(u�
    Permanently delete a network.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f delete_network gce name=mynet
    ufunctionuAThe delete_network function must be called with -f or --function.unameu1A name must be specified when deleting a network.ucloud.fire_eventueventudeleting networkusalt/cloud/net/deletingR�R�usock_dirR�u	transportu*Nework %s was not found. Exception was: %stexc_info_on_logleveludeleted networkusalt/cloud/net/deleted(RR$R%RR8RWRtex_destroy_networkR�RtloggingtDEBUG(R�RYRERZtresulttexc((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytdelete_networksD

	



cC@s_|dkrtd��n|s.d|kr?tjd�tSt�}t|j|d��S(u�
    Show the details of an existing network.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f show_network gce name=mynet
    ufunctionu?The show_network function must be called with -f or --function.unameuMust specify name of network.(RR$R%RR8R=R�(R�RYRZ((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytshow_network�s
	c	C@s�|dkrtd��n|s.d|kr?tjd�tSd|kr\tjd�tSd|krytjd�tSd	|kr�tjd
�tS|d}|d}|d}|d	}|jdd�}t�}tdd
dddi|d6|d6|d6|d	6|d6dt	ddt	d�|j
|||||�}tdd
dddi|d6|d6|d6|d	6|d6dt	ddt	d�t|�S(u
    ... versionadded:: 2017.7.0
    Create a GCE Subnetwork. Must specify name, cidr, network, and region.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_subnetwork gce name=mysubnet network=mynet1 region=us-west1 cidr=10.0.0.0/24 description=optional
    ufunctionuDThe create_subnetwork function must be called with -f or --function.unameuMust specify name of subnet.unetworku4Must specify name of network to create subnet under.ucidru>A network CIDR range must be specified when creating a subnet.uregionu6A region must be specified when creating a subnetwork.udescriptionucloud.fire_eventueventucreate subnetworkusalt/cloud/subnet/creatingR�R�usock_dirR�u	transportucreated subnetworkusalt/cloud/subnet/createdN(RR$R%RterrrorR�RwR8RWRtex_create_subnetworkR=(	R�RYRER�R�RDR�RZtsubnet((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytcreate_subnetwork�sf



	



cC@s>|dkrtd��n|s.d|kr?tjd�tSd|kr\tjd�tS|d}|d}t�}tddd	d
di|d6|d6dtd
dtd�y|j||�}Wn0tk
r�}tjd||dt	j
�tSXtdddddi|d6|d6dtd
dtd�|S(u�
    ... versionadded:: 2017.7.0
    Delete a GCE Subnetwork. Must specify name and region.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f delete_subnetwork gce name=mysubnet network=mynet1 region=us-west1
    ufunctionu@The delete_subnet function must be called with -f or --function.unameuMust specify name of subnet.uregionuMust specify region of subnet.ucloud.fire_eventueventudeleting subnetworkusalt/cloud/subnet/deletingR�R�usock_dirR�u	transportu.Subnetwork %s was not found. Exception was: %sR�udeleted subnetworkusalt/cloud/subnet/deleted(RR$R%RR8RWRtex_destroy_subnetworkRR�R�(R�RYRERDRZR�R�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytdelete_subnetwork$sP

	



cC@s�|dkrtd��n|s.d|kr?tjd�tSd|kr\tjd�tS|d}|d}t�}t|j||��S(u�
    ... versionadded:: 2017.7.0
    Show details of an existing GCE Subnetwork. Must specify name and region.

    CLI Example:

    .. code-block:: bash

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

    ufunctionuBThe show_subnetwork function must be called with -f or --function.unameuMust specify name of subnet.uregionuMust specify region of subnet.(RR$R%RR8R=tex_get_subnetwork(R�RYRERDRZ((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytshow_subnetworkgs

	c
C@s�|dkrtd��n|s.d|kr?tjd�tSd|kr\tjd�tS|d}|jdd�}t|d�}|jd	d
�}|jdd�}|jdd�}|r�|jd
�}n|r�|jd
�}n|r|jd
�}nt�}t	dddddi|d6|d6|dd6dt
ddt
d�|j||d|d|d|d|�}	t	dddddi|d6|d6|dd6dt
ddt
d�t|	�S(u�
    Create a GCE firewall rule. The 'default' network is used if not specified.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_fwrule gce name=allow-http allow=tcp:80
    ufunctionu@The create_fwrule function must be called with -f or --function.unameu7A name must be specified when creating a firewall rule.uallowu4Must use "allow" to specify allowed protocols/ports.unetworkudefaultu	src_rangeu	0.0.0.0/0usrc_tagsudst_tagsu,ucloud.fire_eventueventucreate firewallusalt/cloud/firewall/creatingR�R�usock_dirR�u	transportR�t
source_rangestsource_tagsttarget_tagsucreated firewallusalt/cloud/firewall/createdN(
RR$R%RR�R�RwR�R8RWRtex_create_firewallR=(
R�RYREtnetwork_nameR�t	src_rangetsrc_tagstdst_tagsRZtfwrule((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt
create_fwrule�sf

	
		
cC@s|dkrtd��n|s.d|kr?tjd�tS|d}t�}tddddd	i|d6d
tddtd
�y|j|j|��}Wn0t	k
r�}tjd||dt
j�tSXtddddd	i|d6d
tddtd
�|S(u�
    Permanently delete a firewall rule.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f delete_fwrule gce name=allow-http
    ufunctionu@The delete_fwrule function must be called with -f or --function.unameu7A name must be specified when deleting a firewall rule.ucloud.fire_eventueventudelete firewallusalt/cloud/firewall/deletingR�R�usock_dirR�u	transportu(Rule %s was not found. Exception was: %sR�udeleted firewallusalt/cloud/firewall/deleted(RR$R%RR8RWRtex_destroy_firewalltex_get_firewallRR�R�(R�RYRERZR�R�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt
delete_fwrule�sD

	



cC@s_|dkrtd��n|s.d|kr?tjd�tSt�}t|j|d��S(u�
    Show the details of an existing firewall rule.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f show_fwrule gce name=allow-http
    ufunctionu>The show_fwrule function must be called with -f or --function.unameuMust specify name of network.(RR$R%RR8R=R�(R�RYRZ((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytshow_fwrules
	cC@s�|dkrtd��n|s.d|kr?tjd�tS|d}|jdd�}|jdd�}|jdd�}|jdd�}|jd	d�}|jd
d�}|jdd�}	t�}
tdd
dddi|d6|d6|d6|d6|d6|d	6|d
6|	d6dtddtd�|
j	|d|d|d|d|d|d|d|	�}tdd
dddi|d6|d6|d6|d6|d6|d	6|d
6|	d6dtddtd�t
|�S(u�
    Create an HTTP health check configuration.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_hc gce name=hc path=/healthy port=80
    ufunctionu<The create_hc function must be called with -f or --function.unameu6A name must be specified when creating a health check.uhostupathuportuintervalutimeoutuunhealthy_thresholduhealthy_thresholducloud.fire_eventueventucreate health_checkusalt/cloud/healthcheck/creatingR�R�usock_dirR�u	transportthostRtporttintervalttimeouttunhealthy_thresholdthealthy_thresholducreated health_checkusalt/cloud/healthcheck/createdN(RR$R%RR�RwR8RWRtex_create_healthcheckR=(R�RYRER�RR�R�R�R�R�RZRN((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt	create_hc*sf

	

	

cC@s|dkrtd��n|s.d|kr?tjd�tS|d}t�}tddddd	i|d6d
tddtd
�y|j|j|��}Wn0t	k
r�}tjd||dt
j�tSXtddddd	i|d6d
tddtd
�|S(u�
    Permanently delete a health check.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f delete_hc gce name=hc
    ufunctionu<The delete_hc function must be called with -f or --function.unameu6A name must be specified when deleting a health check.ucloud.fire_eventueventudelete health_checkusalt/cloud/healthcheck/deletingR�R�usock_dirR�u	transportu0Health check %s was not found. Exception was: %sR�udeleted health_checkusalt/cloud/healthcheck/deleted(RR$R%RR8RWRtex_destroy_healthchecktex_get_healthcheckRR�R�(R�RYRERZR�R�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt	delete_hcvsD

	



cC@s_|dkrtd��n|s.d|kr?tjd�tSt�}t|j|d��S(u�
    Show the details of an existing health check.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f show_hc gce name=hc
    ufunctionu:The show_hc function must be called with -f or --function.unameu"Must specify name of health check.(RR$R%RR8R=R�(R�RYRZ((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytshow_hc�s
	cC@s|dkrtd��n|s.d|kr?tjd�tSd|kr\tjd�tS|d}|d}|jdd�}t�}tdd	d
dd|d
tddtd�|j	|||�}tdd	ddd|d
tddtd�tj
d|�t|�S(u�
    Create a static address in a region.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_address gce name=my-ip region=us-central1 address=IP
    ufunctionuAThe create_address function must be called with -f or --function.unameu2A name must be specified when creating an address.uregionu+A region must be specified for the address.uaddressucloud.fire_eventueventucreate addressusalt/cloud/address/creatingR�R�usock_dirR�u	transportucreated addressusalt/cloud/address/createduCreated GCE Address %sN(RR$R%RR�RwR8RWRtex_create_addressR�RG(R�RYREt	ex_regiont
ex_addressRZRF((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyR��s@


	

c
C@sS|dkrtd��n|s.d|kr?tjd�tS|sRd|krctjd�tS|d}|d}t�}tddd	d
di|d6dtd
dtd�y|j|j||��}Wn3t	k
r	}tjd|||dt
j�tSXtdddddi|d6dtd
dtd�tjd|�|S(u�
    Permanently delete a static address.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f delete_address gce name=my-ip
    ufunctionuAThe delete_address function must be called with -f or --function.unameu2A name must be specified when deleting an address.uregionu4A region must be specified when deleting an address.ucloud.fire_eventueventudelete addressusalt/cloud/address/deletingR�R�usock_dirR�u	transportu8Address %s in region %s was not found. Exception was: %sR�udeleted addressusalt/cloud/address/deleteduDeleted GCE Address %s(
RR$R%RR8RWRtex_destroy_addressR�RR�R�R�(R�RYRER�RZR�R�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytdelete_addresssP


	



cC@s�|dkrtd��n|s.d|kr?tjd�tS|sRd|krctjd�tSt�}t|j|d|d��S(u�
    Show the details of an existing static address.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f show_address gce name=mysnapshot region=us-central1
    ufunctionu@The show_snapshot function must be called with -f or --function.unameuMust specify name.uregionuMust specify region.(RR$R%RR8RGR�(R�RYRZ((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytshow_addressHs
	c

C@s�|dkrtd��n|s.d|kr?tjd�tSd|kr\tjd�tSd|krytjd�tSd	|kr�tjd
�tS|d}|d}|d}|jd	�jd�}|jdd
�}|jdd�}|jdd�}t�}	t|	�}
|jdd�}|dk	rJt	|	||�}n|rb|jd�}nt
ddddd|dtddtd�|
j|||||d|d|d|�}t
ddddd|dtddtd�t
|�S( u�
    Create a load-balancer configuration.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_lb gce name=lb region=us-central1 ports=80
    ufunctionu<The create_lb function must be called with -f or --function.unameu6A name must be specified when creating a health check.uportsu=A port or port-range must be specified for the load-balancer.uregionu1A region must be specified for the load-balancer.umembersu4A comma-separated list of members must be specified.u,uprotocolutcpu	algorithmuhealthchecksuaddressucloud.fire_eventueventucreate load_balanceru salt/cloud/loadbalancer/creatingR�R�usock_dirR�u	transportR�tex_healthchecksR�ucreated load_balancerusalt/cloud/loadbalancer/createdN(RR$R%RR�R�RwR8R,R�RWRtcreate_balancerRU(
R�RYREtportsR�tmemberstprotocolt	algorithmR�RZtlb_connR�RM((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt	create_lbfsh



	
	
cC@s|dkrtd��n|s.d|kr?tjd�tS|d}tt��}tddddd	i|d6d
tddtd
�y|j|j	|��}Wn0t
k
r�}tjd||dtj�tSXtddddd	i|d6d
tddtd
�|S(u�
    Permanently delete a load-balancer.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f delete_lb gce name=lb
    ufunctionu<The delete_hc function must be called with -f or --function.unameu6A name must be specified when deleting a health check.ucloud.fire_eventueventudelete load_balanceru salt/cloud/loadbalancer/deletingR�R�usock_dirR�u	transportu1Load balancer %s was not found. Exception was: %sR�udeleted load_balancerusalt/cloud/loadbalancer/deleted(
RR$R%RR,R8RWRtdestroy_balancertget_balancerRR�R�(R�RYRER�R�R�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt	delete_lb�sD





cC@se|dkrtd��n|s.d|kr?tjd�tStt��}t|j|d��S(u�
    Show the details of an existing load-balancer.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f show_lb gce name=lb
    ufunctionu:The show_lb function must be called with -f or --function.unameu#Must specify name of load-balancer.(RR$R%RR,R8RUR�(R�RYR�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytshow_lb�s
cC@s|dkrtd��n|s.d|kr?tjd�tSd|kr\tjd�tSt�}|j|d�}t|�}|j|d�}tddd	d
d|dt	d
dt	d�|j
||�}tddddd|dt	d
dt	d�t|�S(u�
    Add an existing node/member to an existing load-balancer configuration.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f attach_lb gce name=lb member=myinstance
    ufunctionu<The attach_lb function must be called with -f or --function.unameu'A load-balancer name must be specified.umemberu#A node name name must be specified.ucloud.fire_eventueventuattach load_balanceru!salt/cloud/loadbalancer/attachingR�R�usock_dirR�u	transportuattached load_balanceru salt/cloud/loadbalancer/attached(RR$R%RR8RVR,R�RWRtbalancer_attach_compute_nodeR=(R�RYRZR?R�RMR�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt	attach_lbs>
	

c	C@s^|dkrtd��n|s.d|kr?tjd�tSd|kr\tjd�tSt�}t|�}|j|d�}|j|�}d}x+|D]#}|j	|dkr�|}Pq�q�W|s�tjd|d|d�tSt
dd	d
dd|d
tddtd�|j||�}t
dd	ddd|d
tddtd�|S(u�
    Remove an existing node/member from an existing load-balancer configuration.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f detach_lb gce name=lb member=myinstance
    ufunctionu<The detach_lb function must be called with -f or --function.unameu'A load-balancer name must be specified.umemberu#A node name name must be specified.u2The specified member %s was not a member of LB %s.ucloud.fire_eventueventudetach load_balanceru!salt/cloud/loadbalancer/detachingR�R�usock_dirR�u	transportudetached load_balanceru salt/cloud/loadbalancer/detachedN(
RR$R%RR8R,R�tbalancer_list_membersRwtidRWRtbalancer_detach_member(	R�RYRZR�RMtmember_listt
remove_membertmemberR�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt	detach_lbBsR
	


cC@s|dkrtd��n|s.d|kr?tjd�tS|d}t�}tddddd	i|d6d
tddtd
�y|j|j|��}Wn0t	k
r�}tjd||dt
j�tSXtddddd	i|d6d
tddtd
�|S(u�
    Permanently delete a disk snapshot.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f delete_snapshot gce name=disk-snap-1
    ufunctionuBThe delete_snapshot function must be called with -f or --function.unameu2A name must be specified when deleting a snapshot.ucloud.fire_eventueventudelete snapshotusalt/cloud/snapshot/deletingR�R�usock_dirR�u	transportu,Snapshot %s was not found. Exception was: %sR�udeleted snapshotusalt/cloud/snapshot/deleted(RR$R%RR8RWRtdestroy_volume_snapshottex_get_snapshotRR�R�(R�RYRERZR�R�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytdelete_snapshot�sD

	



cC@sS|dkrtd��n|s.d|kr?tjd�tSt�}|j|jd��}tddddd	i|jd
6|j	djd6|j
d
6dtddtd�y|j|�}Wn3t
k
r�}tjd|j|dtj�tSXtddddd	i|jd
6|j	djd6|j
d
6dtddtd�|S(u�
    Permanently delete a persistent disk.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f delete_disk gce disk_name=pd
    ufunctionu>The delete_disk function must be called with -f or --function.u	disk_nameu3A disk_name must be specified when deleting a disk.ucloud.fire_eventueventudelete diskusalt/cloud/disk/deletingR�unameuzoneulocationusizeR�usock_dirR�u	transportujDisk %s is in use and must be detached before deleting.
The following exception was thrown by libcloud:
%sR�udeleted diskusalt/cloud/disk/deleted(RR$R%RR8t
ex_get_volumeR�RWRER]R`Rtdestroy_volumeRR�R�(R�RYRZRBR�R�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytdelete_disk�sJ
	





c
C@s�|dkrtd��n|dkr0i}n|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}|jdd	�}|dkr�tjd
�tS|dkr�tjd�tS|dkr|dkr|dkrtjd�tSt�}|j|d�}t}	t	d
ddddi|d6|j
d6|d6|d6dtddtd�|j||||||	|�}
t	d
ddddi|d6|j
d6|d6|d6dtddtd�t
|
�S(u�
    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:

    .. code-block:: bash

        salt-cloud -f create_disk gce disk_name=pd size=300 location=us-central1-b
    ufunctionu>The create_disk function must be called with -f or --function.u	disk_nameuimageulocationusizeusnapshotutypeupd-standardu9A location (zone) must be specified when creating a disk.u3A disk_name must be specified when creating a disk.u&Must specify image, snapshot, or size.ucloud.fire_eventueventucreate diskusalt/cloud/disk/creatingR�unameR�usock_dirR�u	transportucreated diskusalt/cloud/disk/createdN(RRwR�R$R%RR8RrtTrueRWRERt
create_volumeRC(R�RYREtimageRsR`tsnapshott	disk_typeRZtuse_existingRB((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytcreate_disk�sf	$	





cC@s]|dkrtd��n|s.d|kr?tjd�tSd|kr\tjd�tSt�}|jd�}|jd�}y|j|�}Wn0tk
r�}tjd||dtj	�tSXt
d	d
ddd
i|d6|d6dtddtd�|j||�}t
d	d
ddd
i|d6|d6dtddtd�t
|�S(u�
    Create a new disk snapshot. Must specify `name` and  `disk_name`.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_snapshot gce name=snap1 disk_name=pd
    ufunctionuBThe create_snapshot function must be called with -f or --function.unameu2A name must be specified when creating a snapshot.u	disk_nameu7A disk_name must be specified when creating a snapshot.u(Disk %s was not found. Exception was: %sR�ucloud.fire_eventueventucreate snapshotusalt/cloud/snapshot/creatingR�R�usock_dirR�u	transportucreated snapshotusalt/cloud/snapshot/created(RR$R%RR8R�R�RR�R�RWRtcreate_volume_snapshotR=(R�RYRZREt	disk_nameRBR�R�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytcreate_snapshotTsR
	



cC@sD|sd|kr$tjd�tSt�}t|j|d��S(u�
    Show the details of an existing disk.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a show_disk myinstance disk_name=mydisk
        salt-cloud -f show_disk gce disk_name=mydisk
    u	disk_nameuMust specify disk_name.(R$R%RR8RCR�(RER�RYRZ((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt	show_disk�s	cC@s_|dkrtd��n|s.d|kr?tjd�tSt�}t|j|d��S(u�
    Show the details of an existing snapshot.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f show_snapshot gce name=mysnapshot
    ufunctionu@The show_snapshot function must be called with -f or --function.unameuMust specify name.(RR$R%RR8R=R�(R�RYRZ((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt
show_snapshot�s
	c	C@s|dkrtd��n|s2tjd�tS|sEd|krVtjd�tS|}|d}t�}|j|�}|j|�}tdddd	d
i|d6|d6dtd
dtd�|j	||�}tddddd
i|d6|d6dtd
dtd�|S(u�
    Detach a disk from an instance.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a detach_disk myinstance disk_name=mydisk
    uactionu:The detach_Disk action must be called with -a or --action.uMust specify an instance name.u	disk_nameu#Must specify a disk_name to detach.ucloud.fire_eventueventudetach diskusalt/cloud/disk/detachingR�unameR�usock_dirR�u	transportu
detached diskusalt/cloud/disk/detached(
RR$R%RR8RVR�RWRt
detach_volume(	RER�RYt	node_nameRRZR?RBR�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytdetach_disk�sH

	



c
C@s�|dkrtd��n|s2tjd�tS|sEd|krVtjd�tS|}|d}|jdd�j�}|jdt�}|jd	t�}|r�|j�dkr�t}nt}|dkr�tjd�tSt�}|j	|�}	|j
|�}
tdddddi|d6|d6|d6|d6dtddtd�|j
|	|
d|d|d|�}tdddddi|d6|d6|d6|d6dtddtd�|S( u�
    Attach an existing disk to an existing instance.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a attach_disk myinstance disk_name=mydisk mode=READ_WRITE
    uactionu:The attach_disk action must be called with -a or --action.uMust specify an instance name.u	disk_nameu#Must specify a disk_name to attach.umodeu
READ_WRITEubootuauto_deleteutrueuyesuenabledu	READ_ONLYu6Mode must be either READ_ONLY or (default) READ_WRITE.ucloud.fire_eventueventuattach diskusalt/cloud/disk/attachingR�unameR�usock_dirR�u	transporttex_modetex_boottex_auto_deleteu
attached diskusalt/cloud/disk/attached(utrueuyesuenabled(u
READ_WRITEu	READ_ONLY(RR$R%RR�tupperR�R�R8RVR�RWRt
attach_volume(RER�RYR	RR�tboottauto_deleteRZR?RBR�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytattach_disksf

		

	

cC@s�|dkrtd��nt�}tddddj|�di|d6d	td
dtd�|j|j|��}tdddd
j|�di|d6d	td
dtd�|S(u�
    Call GCE 'reset' on the instance.

    CLI Example:

    .. code-block:: bash

        salt-cloud -a reboot myinstance
    uactionu5The reboot action must be called with -a or --action.ucloud.fire_eventueventureboot instanceusalt/cloud/{0}/rebootingR�unameR�usock_dirR�u	transportusalt/cloud/{0}/rebooted(RR8RWR1Rtreboot_nodeRV(RXRYRZR�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytrebootRs*
	



cC@s�|dkrtd��nt�}tddddj|�di|d6d	td
dtd�|j|j|��}tdddd
j|�di|d6d	td
dtd�|S(u�
    Call GCE 'start on the instance.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -a start myinstance
    uactionu4The start action must be called with -a or --action.ucloud.fire_eventueventustart instanceusalt/cloud/{0}/startingR�unameR�usock_dirR�u	transportusalt/cloud/{0}/started(RR8RWR1Rt
ex_start_nodeRV(RXRYRZR�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytstart|s*	



cC@s�|dkrtd��nt�}tddddj|�di|d6d	td
dtd�|j|j|��}tdddd
j|�di|d6d	td
dtd�|S(u�
    Call GCE 'stop' on the instance.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt-cloud -a stop myinstance
    uactionu3The stop action must be called with -a or --action.ucloud.fire_eventueventu
stop instanceusalt/cloud/{0}/stoppingR�unameR�usock_dirR�u	transportusalt/cloud/{0}/stopped(RR8RWR1Rtex_stop_nodeRV(RXRYRZR�((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytstop�s*	



c
C@s|r!|dkr!td��nt�}y|j|�}WnDtk
r�}tjd||dtj�tdj|���nXt	dddd	j|�d
i|d6dt
d
dt
d�d$}|jdr$d|jdkr$x9|jddD]#}|ddkr�|d}q�q�Wnt
�}t}|rr||dkrrd|d|krr|d|d}ny|j|�}	WnDtk
r�}tjd||dtj�tdj|���nXt	ddddj|�d
i|d6dt
d
dt
d�|r�tjd�t	ddddd
i|d6dt
d
dt
d�y|j|j|��Wn/tk
r�}tjd||dtj�nXt	ddddd
i|d6dt
d
dt
d�nt
jd t�tkrt	d!|tjd"�d#t
�n|	S(%u�
    Call 'destroy' on the instance.  Can be called with "-a destroy" or -d

    CLI Example:

    .. code-block:: bash

        salt-cloud -a destroy myinstance1 myinstance2 ...
        salt-cloud -d myinstance1 myinstance2 ...
    uactionu:The destroy action must be called with -d or "-a destroy".u{Could not locate instance %s

The following exception was thrown by libcloud when trying to run the initial deployment: 
%sR�uCould not find instance {0}.ucloud.fire_eventueventudelete instanceusalt/cloud/{0}/deletingR�unameR�usock_dirR�u	transportumetadatauitemsukeyusalt-cloud-profileuvalueuprofilesudelete_boot_pdu|Could not destroy instance %s

The following exception was thrown by libcloud when trying to run the initial deployment: 
%suCould not destroy instance {0}.usalt/cloud/{0}/deleteduMdelete_boot_pd is enabled for the instance profile, attempting to delete diskudelete diskusalt/cloud/disk/deletinguxCould not destroy disk %s

The following exception was thrown by libcloud when trying to run the initial deployment: 
%sudeleted diskusalt/cloud/disk/deleteduupdate_cachedirucloud.delete_minion_cachediru:iN(RR8RVR>R$R%R�R�R1RWRRwR]R
Rtdestroy_nodeR�R�R�R�R�R!R�(
RXRYRZR?R�tprofileR~Rptdelete_boot_pdtinst_deleted((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytdestroy�s�	

 	*





$cC@s8|dkrtd��nt|d�}|d}t�}t|j|��}td�d}x�t|�D]�\}}	dj|t|d|��}
i|
d	6|d
ddd
6|	dd6|	j	dd�d6|	j	dd�d6|	j	dd�d6|	j	dt�d6}t|d�t
||d�qpWdS(u)
    .. versionadded:: 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.
    uactionuDThe create_attach_volumes action must be called with -a or --action.uvolumesunodeuaiu	{0}-sd{1}iu	disk_nameuextrauzoneunameulocationusizeutypeupd-standarduimageusnapshotuauto_deleteufunctionN(RRR8RARVtordt	enumerateR1tchrR�RwRRR(RER�RYtvolumesR?RZt	node_datatlettertidxtvolumetvolume_nametvolume_dict((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytcreate_attach_volumesH	s(
	 
c	C@shtj|d�s"td��ny=|dr^tjttpAd|dd|�tkr^tSWntk
rrnXt	dddd	j
|d�d
t	dd|ddd
dg�dtddtd�t�}i|dd6t||�d6t
||�d6t||�d6t||�d6t|�d6t|�d6t|�d6}tjd|tdd�}|j�dkr�d}n6|dkr�d;}n!t||�}t|||�}||d<||d<td<kr�|jitjd!|tdd"�d!6tjd#|tdt�d#6tjd$|tdd;�d$6tjd%|tdd;�d%6tjd&|tdt�d'6tjd(|tdt�d)6�|jd!�d=kr�td+��q�ntjd,|d|dj�tjd-|�t	ddd.d/j
|d�d
t	dd0|ddd
dg�dtddtd�y|j |�}Wn4t!k
r�}tj"d1|d|d2t#j$�tSXtjd3|td4t�}|r!t	ddd5d6j
|d�d
i|d36dtddtd�tjd7|d�t%|di|d36|d86d9d:�nyt&|dd:�}Wn#t'k
r]t&|jd:�}nX||fS(>uZ
    Request a single GCE instance from a data dict.

    .. versionchanged: 2017.7.0
    unameueVM names must start with a letter, only contain letters, numbers, or dashes and cannot end in a dash.uprofileugceRpucloud.fire_eventueventucreate instanceusalt/cloud/{0}/creatingR�ucloud.filter_eventucreatinguproviderudriverR�usock_dirR�u	transportusizeuimageulocationu
ex_networku
ex_subnetworkuex_tagsuex_metadatauexternal_ipRmu	ephemeraluNoneiiiuex_disk_typeupd-standarduex_disk_auto_deleteuex_disks_gce_structuex_service_accountsu
ip_forwardinguex_can_ip_forwardupreemptibleuex_preemptibleupd-ssduGThe value of 'ex_disk_type' needs to be one of: 'pd-standard', 'pd-ssd'uCreating GCE instance %s in %suCreate instance kwargs %surequesting instanceusalt/cloud/{0}/requestingu
requestinguwError creating %s on GCE

The following exception was thrown by libcloud when trying to run the initial deployment: 
%sR�uvolumesRnuattaching volumesu salt/cloud/{0}/attaching_volumesu$Create and attach volumes to node %sunodeRYuactionN(iii(upd-standardupd-ssd((tGCE_VM_NAME_REGEXtmatchRRtis_profile_configuredRR!RtAttributeErrorRWR1R8RvRqRtR�R�R|R�R.R�RwR�R�tLIBCLOUD_VERSION_INFOR9R�R�R$R�RER�tcreate_nodeR>R%R�R�R(R[t	TypeError(	RpRZR�texternal_ipRDR"R�R!t	node_dict((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytrequest_instance�	s�	

"
	

		

	"





cC@s1|rtd��nt|�}t|t�r?td��n|d}|d}t|�\}}t||�|d<||d<td|t�}|j|�t	j
d|d	�t	jd
|d	tj
|��tddd
dj|d	�dtdd|d	dddg�dtddtd�|S(u8
    Create a single GCE instance from a data dict.
    u,You cannot create an instance with -a or -f.u-There was an error creating the GCE instance.iiussh_hostukey_filenameucloud.bootstrapuCreated Cloud VM '%s'unameu'%s' VM creation details:
%sucloud.fire_eventueventucreated instanceusalt/cloud/{0}/createdR�ucloud.filter_eventucreateduprofileuproviderudriverR�usock_dirR�u	transport(RR2RxtboolR�R�RWRR9R$R�ttracetpprinttpformatR1(RpRYt	node_infoR1R"R�R�R<((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytcreate

s4



"
cC@syd}tjjj|dtdd�}tjjtdd�}tjj	j
|d��}tj|d|�Wd	QXtS(
u�
    Download most recent pricing information from GCE and save locally

    CLI Examples:

    .. code-block:: bash

        salt-cloud -f update_pricing my-gce-config

    .. versionadded:: 2015.8.0
    uEhttps://cloudpricingcalculator.appspot.com/static/data/pricelist.jsontdecodetdecode_typeujsonucachediru
gce-pricing.puwudictN(
RRthttptqueryR�RRR�Rtfilestfopentmsgpacktdump(R�RYturlt
price_jsontoutfiletfho((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytupdate_pricing5
s!	cC@sltdj|di�}|s+idd6S|jdd�}|jd�}t|�dksn|d	d
kryidd6S|jdd
�jd�}|d}dj|dj��}tjjtdd�}tjj	|�s�t
�ntjj
j|d��}tj|�}	WdQXt|	d||�}
t|	ddd�}t|	ddd�}t|	ddd�}
t|	ddd�}|
dd|}|
dd|}|
dd|
}|
dd|}|	}i}|
|d<|dd|d <|d d!|d"<|||||d#<|d#d$|d%<|jd&t�r]||d'<ni||d6S((u
    Show pricing for a particular profile. This is only an estimate, based on
    unofficial pricing sources.

    .. versionadded:: 2015.8.0

    CLI Examples:

    .. code-block:: bash

        salt-cloud -f show_pricing my-gce-config profile=my-profile
    uprofilesuprofileu#The requested profile was not founduErroruprovideru0:0u:iiugceu,The requested profile does not belong to GCEulocationuusu-iuCP-COMPUTEENGINE-VMIMAGE-{0}usizeucachediru
gce-pricing.purNugcp_price_listusustained_use_tiersu0.25u0.50u0.75u1.0i�iuper_houriuper_dayiuper_weeku	per_monthiuper_yearurawu_raw(RR�R�R�R1RRRR�texistsRERRR=R>R?tloadtfloatR(R�RYRRtcompsRDR`t	pricefileRDR_tper_hourtweek1_discounttweek2_discounttweek3_discounttweek4_discounttweek1tweek2tweek3tweek4trawR<((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pytshow_pricingM
sF
"
	


(�t__doc__t
__future__RRRRtsystreR5R�R?tastRtsalt.utils.versionsRt
_LooseVersionRwR#tlibcloudtlibcloud.compute.typesRtlibcloud.compute.providersRtlibcloud.loadbalancer.typesR*tlibcloud.loadbalancer.providersR)tlibcloud.common.googleRRt__version__tlibcloud.securitytsecurityt
CA_CERTS_PATHRHR�R'tImportErrorR"Rtsalt.utils.functoolsR	tsalt.extR
tsalt.utils.cloudRtsalt.utils.filestsalt.utils.httptsalt.configRtsalt.cloud.libcloudfuncstsalt.exceptionsRt	getLoggert__name__R$RR2R3tavail_locationstglobalstscriptRt
list_nodestlist_nodes_fulltlist_nodes_selecttcompileR)RR
RR,R8R=RARCRGRUR[RbRlRqRtRvR|R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRRR
RRRRR(R2R8RERU(((s9/usr/lib/python2.7/site-packages/salt/cloud/clouds/gce.pyt<module>.s�	



		
	
						
	(*	
								
		
			%	C;RC#M;L;9FS;6B;?VE=O*,,t8	�+

Zerion Mini Shell 1.0