%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s!dZddlmZmZmZddlZddlZddlZddlZddl	m
Z
ddlZddl
ZddlZddljZddlmZmZmZmZmZddlmZybddlZddlmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%e&Z'Wne(k
rHe)Z'nXej*e+�Z,dZ-d	�Z.d
�Z/d�Z0d�Z1d
�Z2dd�Z4dd�Z5ddd�Z6dd�Z7d�Z8d�Z9dd�Z:ddd�Z;d�Z<ddd�Z=d�Z>d�Z?d�Z@ddd�ZAddd�ZBddd�ZCddd�ZDdd�ZEd �ZFd!�ZGd"�ZHd#�ZId$�ZJd%�ZKd&�ZLd'�ZMdd(�ZNdd)�ZOdd*�ZPdd+�ZQd,�ZRd-�ZSd.�ZTd/�ZUd0�ZVd1�ZWd2�ZXdS(3u�

ProfitBricks Cloud Module
=========================

The ProfitBricks SaltStack cloud module allows a ProfitBricks server to
be automatically deployed and bootstraped with Salt.

:depends: profitbrick >= 3.1.0

The module requires ProfitBricks credentials to be supplied along with
an existing virtual datacenter UUID where the server resources will
reside. The server should also be assigned a public LAN, a private LAN,
or both along with SSH key pairs.
...

Set up the cloud configuration at ``/etc/salt/cloud.providers`` or
``/etc/salt/cloud.providers.d/profitbricks.conf``:

.. code-block:: yaml

    my-profitbricks-config:
      driver: profitbricks
      # The ProfitBricks login username
      username: user@example.com
      # The ProfitBricks login password
      password: secretpassword
      # The ProfitBricks virtual datacenter UUID
      datacenter_id: <UUID>
      # SSH private key filename
      ssh_private_key: /path/to/private.key
      # SSH public key filename
      ssh_public_key: /path/to/public.key

.. code-block:: yaml

    my-profitbricks-profile:
      provider: my-profitbricks-config
      # Name of a predefined server size.
      size: Micro Instance
      # Assign CPU family to server.
      cpu_family: INTEL_XEON
      # Number of CPU cores to allocate to node (overrides server size).
      cores: 4
      # Amount of RAM in multiples of 256 MB (overrides server size).
      ram: 4096
      # The server availability zone.
      availability_zone: ZONE_1
      # Name or UUID of the HDD image to use.
      image: <UUID>
      # Image alias could be provided instead of image.
      # Example 'ubuntu:latest'
      #image_alias: <IMAGE_ALIAS>
      # Size of the node disk in GB (overrides server size).
      disk_size: 40
      # Type of disk (HDD or SSD).
      disk_type: SSD
      # Storage availability zone to use.
      disk_availability_zone: ZONE_2
      # Assign the server to the specified public LAN.
      public_lan: <ID>
      # Assign firewall rules to the network interface.
      public_firewall_rules:
        SSH:
          protocol: TCP
          port_range_start: 22
          port_range_end: 22
      # Assign the server to the specified private LAN.
      private_lan: <ID>
      # Enable NAT on the private NIC.
      nat: true
      # Assign additional volumes to the server.
      volumes:
        data-volume:
          disk_size: 500
          disk_availability_zone: ZONE_3
        log-volume:
          disk_size: 50
          disk_type: SSD

To use a private IP for connecting and bootstrapping node:

.. code-block:: yaml

    my-profitbricks-profile:
      ssh_interface: private_lan

Set ``deploy`` to False if Salt should not be installed on the node.

.. code-block:: yaml

    my-profitbricks-profile:
      deploy: False
i(tabsolute_importtprint_functiontunicode_literalsN(tLooseVersion(tSaltCloudConfigErrortSaltCloudNotFoundtSaltCloudExecutionFailuretSaltCloudExecutionTimeouttSaltCloudSystemExit(tsix(tProfitBricksServicetServertNICtVolumetFirewallRuletIPBlockt
DatacentertLoadBalancertLANtPBNotFoundErrortPBErroruprofitbrickscC@s*t�tkrtSt�tkr&tStS(u0
    Check for ProfitBricks configurations.
    (tget_configured_providertFalsetget_dependenciest__virtualname__(((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyt__virtual__�s
cC@stjttptd�S(u/
    Return the first configured instance.
    uusernameupasswordu
datacenter_id(uusernameupasswordu
datacenter_id(tconfigtis_provider_configuredt__opts__t__active_provider_name__R(((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyR�s	cC@sttj�t|�kS(u%
    Checks profitbricks version
    (RtprofitbrickstAPI_VERSION(tversion((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytversion_compatible�scC@stjtitd6�S(u+
    Warn if dependencies are not met.
    uprofitbricks(Rtcheck_driver_dependenciesRtHAS_PROFITBRICKS(((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyR�sc
C@sCtdtjdt�tdt�dtjdt�tdt��S(u5
    Return a conn object for the passed VM data
    tusernameuusernamet
search_globaltpasswordupassword(R
Rtget_cloud_config_valueRRR(((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytget_conn�s	cC@s�|dkrtd��ni}t�}xi|j�dD]W}|djd�\}}i|dd6}||kr�i||<n||||<q;W|S(ub
    Return a dict of all available VM locations on the cloud provider with
    relevant data
    uactionucThe avail_images function must be called with -f or --function, or with the --list-locations optionuitemsuidu/(RR(tlist_locationstsplit(tcalltrettconntitemtregtloctlocation((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytavail_locations�s	
cC@sy|dkrtd��ni}t�}xH|j�dD]6}i|dd6}|j|d�|||d<q;W|S(u>
    Return a list of the images that are on the provider
    uactionu`The avail_images function must be called with -f or --function, or with the --list-images optionuitemsuidu
propertiesuname(RR(tlist_imagestupdate(R+R,R-R.timage((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytavail_images�s	cC@s�|dkrtd��ntd�s6td��ni}t�}|jd�dk	r�|j|jd�d�}i|ddd	6||d
<|Sx8|jd�dD]#}i|ddd	6||d
<q�W|S(
u�
    List all the images with alias by location

    CLI Example:

    .. code-block:: bash

        salt-cloud -f list_images my-profitbricks-config location=us/las
    ufunctionu>The list_images function must be called with -f or --function.u4.0uJThe 'image_alias' feature requires the profitbricks SDK v4.0.0 or greater.ulocationiu
propertiesuimageAliasesuimage_aliasuiduitemsN(RR!RR(tgettNonetget_locationR)(R+tkwargsR,R-R.((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyR3�s
	!cC@s|dkrtd��niidd6dd6dd6d	d
6d6idd6d
d6dd6d	d
6d6idd6dd6dd6dd
6d6idd6dd6dd6dd
6d6idd6dd6dd6dd
6d6idd6dd6dd6dd
6d6idd6dd6dd6dd
6d 6}|S(!u
    Return a dict of all available VM sizes on the cloud provider with
    relevant data. Latest version can be found at:
    uactionu^The avail_sizes function must be called with -f or --function, or with the --list-sizes optionu1uidiurami2udiskiucoresuMicro Instanceu2iuSmall Instanceu3iiuMedium Instanceu4iiuLarge Instanceu5i8iuExtra Large Instanceu6ipu Memory Intensive Instance Mediumu7i�uMemory Intensive Instance Large(R(R+tsizes((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytavail_sizessPcC@s�tjd|t�}t�}|s,|dSxW|D]O}tj||d�tj|�f}|r3tj|�|kr3||Sq3Wtdj|���dS(u%
    Return the VM's size object
    usizeuSmall Instanceuidu.The specified size, '{0}', could not be found.N(RR'RR<R	t	text_typeRtformat(tvm_tvm_sizeR;tsizetcombinations((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytget_sizeTs	
&cC@sftjdt�tdt�}t�}y|jd|�Wn$tk
ratj	d|��nX|S(u:
    Return datacenter ID from provider configuration
    u
datacenter_idR%t
datacenter_iduFailed to get datacenter: %s(
RR'RRRR(tget_datacenterRtlogterror(RDR-((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytget_datacenter_idgs		
cC@s�|dkrtd��ni}t�}t|�}xO|j|d�dD]6}i|dd6}|j|d�|||d<qNW|S(uE
    Return a list of the loadbalancers that are on the provider
    uactionugThe avail_images function must be called with -f or --function, or with the --list-loadbalancers optionuiduitemsu
propertiesuname(RR(REtlist_loadbalancersR4(R+R,R-t
datacenterR.tlb((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyRI}s	cC@s�|dkrtd��n|dkr0i}nt�}t�}td|jd�d|jd�d|jd��}|j||�}t||d	d
�|S(u�
    Creates a loadbalancer within the datacenter from the provider config.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_loadbalancer profitbricks name=mylb
    ufunctionuAThe create_address function must be called with -f or --function.tnameunametipuiptdhcpudhcpi<uloadbalancerN(RR8R(RHRR7tcreate_loadbalancert_wait_for_completion(R+R:R-RDtloadbalancertresponse((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyRO�s
			cC@sQt�}x,|j�dD]}|d|kr|SqWtdj|���dS(uF
    Return the datacenter from the config provider datacenter ID
    uitemsuidu2The specified datacenter '{0}' could not be found.N(RHtlist_datacentersRR>(R-RDR.((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyRE�s	cC@s�|dkrtd��n|d
kr0i}n|jd�d
krTtd��n|jd�d
krxtd��nt�}td|dd|dd	|jd
��}|j|�}t||dd�|S(u�
    Creates a virtual datacenter based on supplied parameters.

    CLI Example:

    .. code-block:: bash

        salt-cloud -f create_datacenter profitbricks name=mydatacenter
        location=us/las description="my description"
    ufunctionuAThe create_address function must be called with -f or --function.unameu The "name" parameter is requiredulocationu$The "location" parameter is requiredRLR1tdescriptionudescriptioni<ucreate_datacenterN(RR8R7RR(Rtcreate_datacenterRP(R+R:R-RJRR((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyRU�s 		
cC@stjd|tdddt�S(uJ
    Return the type of disk to use. Either 'HDD' (default) or 'SSD'.
    u	disk_typetdefaultuHDDR%(RR'RR(R?((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyt
get_disk_type�scC@stjd|tdddt�S(u@
    Return the wait_for_timeout for resource provisioning.
    uwait_for_timeoutRVii<R%i�(RR'RR(R?((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytget_wait_timeout�scC@s�tjd|t�jdd�}t�}xGtj|�D]6}|r:|||d||dfkr:||Sq:Wtdj|���dS(u(
    Return the image object to use
    uimageuasciiusalt-cloud-force-asciiuidunameu/The specified image, '{0}', could not be found.N(	RR'RtencodeR6R	titerkeysRR>(R?tvm_imagetimagestkey((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyt	get_image�s	(cC@s�|dkrtd��ng}|s3t�}nxV|j�dD]D}i|dd6}|j|d�|ji||dd6�qDWi|d6S(u�
    List all the data centers

    CLI Example:

    .. code-block:: bash

        salt-cloud -f list_datacenters my-profitbricks-config
    ufunctionuCThe list_datacenters function must be called with -f or --function.uitemsuidu
propertiesunameuDatacenters(RR(RSR4tappend(R-R+tdatacentersR.RJ((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyRSs
 cC@s�|dkrtd��n|s-t�}ni}t�}y|jd|�}Wn$tk
rxtjd|��nXxU|dD]I}i|dd6}|j|d�|jd�|d	<|||d
<q�W|S(u7
    Return a list of VMs that are on the provider
    uactionu=The list_nodes function must be called with -f or --function.RDu,Failed to get nodes list from datacenter: %suitemsuidu
propertiesuvmStateustateuname(	RR(RHtlist_serversRRFRGR4tpop(R-R+R,RDtnodesR.tnode((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyt
list_nodes)s&	
	c	C@sz|dkrtd��n|s-t�}ni}t�}|jd|dd�}x�|dD]�}i|dd6}|j|d�|jd	�|d
<g|d<g|d<|d
dddkrCxz|d
ddD]c}|ddr�n|ddd}tjjj	|�r+|dj
|�q�|dj
|�q�Wn|||d<q_Wtd|tj
d�dt�|S(uL
    Return a list of the VMs that are on the provider, with all fields
    uactionuBThe list_nodes_full function must be called with -f or --function.RDtdepthiuitemsuidu
propertiesuvmStateustateu
public_ipsuprivate_ipsuentitiesunicsiuipsunameucloud.cache_node_listu:(RR(RHRaR4Rbtsalttutilstcloudtis_public_ipR_t	__utils__RR*R(	R-R+R,RDRcR.Rdtnict
ip_address((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytlist_nodes_fullHs8	

cC@s�|dkrtd��nt�}|dkr9i}ni}g|d<|jd�dkrmtd��n|jd�}d}|jd�dk	r�|jd�}n|jtd|d	|��}x'|d
dD]}|dj|�q�W|S(u
    Reserve the IP Block
    uactionuBThe reserve_ipblock function must be called with -f or --function.uipsulocationu$The "location" parameter is requirediusizeRAR1u
propertiesN(RR(R8R7Rtreserve_ipblockRR_(R+R:R-R,R1RAtblockR.((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyRots$		
cC@sD|dkrtd��nt�}td||tt�||S(uC
    Show the details from the provider concerning an instance
    uactionu<The show_instance action must be called with -a or --action.ucloud.cache_node(RRnRkRR(RLR+Rc((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyt
show_instance�s	cC@set�}xU|j|�dD]@}|dd|kri|dd6}|j|d�|SqWdS(u(
    Return a node for the named VM
    uitemsu
propertiesunameuidN(RHRaR4(R-RLRDR.Rd((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytget_node�s	cC@stjd|tdddt�S(uj
    Return the ssh_interface type to connect to. Either 'public_ips' (default)
    or 'private_ips'.
    u
ssh_interfaceRVu
public_ipsR%(RR'RR(R?((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyt
ssh_interface�scC@sHg}d|kr�g}d|kr7t|d�}ntdtt|d��ddd|�}d|kr�t|d�|_n|j|�nd|krDg}d	|kr�t|d	�}ntdt|d�dd
d|�}d|krt|d�|_nd|kr4d|kr4|d|_n|j|�n|S(
uT
    Create network interfaces on appropriate LANs as defined in cloud profile.
    u
public_lanupublic_firewall_rulestlanRLupublictfirewall_rulesu
public_ipsuprivate_lanuprivate_firewall_rulesuprivateuprivate_ipsunat(t_get_firewall_rulesRtset_public_lantintt_get_ip_addressestipsR_tnat(R?tnicsRuRl((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyt	_get_nics�s0		cC@s�t�}t�}yQ|jd|d|�}|ddsZ|jd|d|dt�n|dSWn7tk
r�|j|tdtdd��}|dSXd	S(
u�
    Enables public Internet access for the specified public_lan. If no public
    LAN is available, then a new public LAN is created.
    RDtlan_idu
propertiesupublictpublicuidRLu
Public LANN(R(RHtget_lant
update_lantTruet	Exceptiont
create_lanR(R~R-RDRt((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyRw�s		

	cC@s�tjd|tdtdd�}|dk	r�tjj|�}tjj|�sit	dj
|���ng}tjj
j|��:}x0|j�D]"}|jtjjj|��q�WWdQX|SdS(u+
    Retrieve list of SSH public keys.
    ussh_public_keyR%RVu/The defined ssh_public_key '{0}' does not existN(RR'RRR8tostpatht
expandusertisfileRR>RgRhtfilestfopent	readlinesR_tstringutilst
to_unicode(R?tkey_filenametssh_keystrfhR]((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytget_public_keys�s&cC@sqtjd|tdtdd�}|dk	rmtjj|�}tjj|�sit	dj
|���n|SdS(uH
    Check SSH private key file and return absolute path if exists.
    ussh_private_keyR%RVu0The defined ssh_private_key '{0}' does not existN(RR'RRR8R�R�R�R�RR>(R?R�((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytget_key_filename
scC@satd||ddddg�}tdd|dj|d�d	|d
tddtd
�dS(Nucloud.filter_eventunameuprofileuproviderudriverucloud.fire_eventueventusalt/cloud/{0}/creatingtargstsock_dirusock_dirt	transportu	transport(RkR>R(R?teventRTR�((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytsignal_event s
c
C@sKy7|dr6tjttpd|d�tkr6tSWntk
rJnXd|krstd�rstd��nd|kr�d|kr�tj	d�nt
|dd	�d!}t�}t
�}t|�}t|�g}d
|kr|jt|��nt|||�}t
|dd�yR|jd
|d|�}tjd|ddtj�t||t|�d�Wngtk
r�}tj	d|d|dtj�tStk
r�}tj	d|d|dtj�tSX|d|d<d�}y[tjjj|d||fdtjd|tdd+�dtjd |tdd��}Wn_t t!fk
r�}z*yt"|d�Wnt#k
r�nXWd!t#t$j%|j&���XnXtj'd"�tjd#|�tj'd$|t(j)|��t
|d%d&�d'|kr;t*|�|d(<t+d)|t�}	|	j,|�|	St#d*��d!S(,u-
    Create a single VM from a data dict
    uprofileuprofitbricksuimage_aliasu4.0uLThe 'image_alias' parameter requires the profitbricks SDK v4.0.0 or greater.uimageu/The image or image_alias parameter is required.ucreatingustarting createuvolumesu
requestingurequesting instanceRDtserveruCreate server request ID: %su	requestIdtexc_info_on_loglevelu
create_serveru�Error creating %s on ProfitBricks

The following exception was thrown by the profitbricks library when trying to run the initial deployment: 
%sunameuError creating %s 

Error: 
%suidu	server_idcS@st}yLt|dd�}|s&tStjd|dtj|d�|d�Wn-tk
r�}tjd|dtj	�tSX|ddk}|s�dSt
|�d	kr�|d
r�|d
d|d<nt
|�d	kr�|d
r�|d
d|d<n|S(u?
        Query node data until node becomes available.
        unameuactionu+Loaded node data for %s:
name: %s
state: %sustateuFailed to get nodes list: %sR�uRUNNINGNuprivate_lanuprivate_ipsiussh_hostu
public_ips(RRqRFtdebugtpprinttpformatR�RGtloggingtDEBUGRs(R?tdatatrunningterr((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyt__query_node_datavs*&	
tupdate_argsttimeoutuwait_for_ip_timeoutRVi
i<tintervaluwait_for_ip_intervalNuVM is now runninguCreated Cloud VM %su%s VM creation details:
%sucreateducreated instanceussh_hostukey_filenameucloud.bootstrapu!A valid IP address was not found.iX(-Rtis_profile_configuredRRRtAttributeErrorR!RRFRGR�R8RHR(R}t_get_system_volumetextendt_get_data_volumest_get_servert
create_servertinfoR�R�RPRXRR�RgRhRitwait_for_ipR'RRtdestroyRR	R=tmessageR�R�R�R�RkR4(
R?R�RDR-R|tvolumesR�texcR�R,((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytcreate1s�
	
			#


cC@s�|dkrtd��ntddddj|�di|d6d	td
dtd�t�}t�}t||�}d}tj	d
t
�tdt�}|jd|d|d�}|j
d|d|d�|r4xW|dD]H}tjd|d�|jd|d|d�tjd|d�q�Wntddddj|�di|d6d	td
dtd�tjdt�tkr�td|tjd�dt�ntS(u<
    destroy a machine by name

    :param name: name given to the machine
    :param call: call value in this case is 'action'
    :return: array of booleans , true if successfully stopped and true if
             successfully removed

    CLI Example:

    .. code-block:: bash

        salt-cloud -d vm_name

    ufunctionuEThe destroy action must be called with -d, --destroy, -a or --action.ucloud.fire_eventueventudestroying instanceusalt/cloud/{0}/destroyingR�unameR�usock_dirR�u	transportudelete_volumesR%RDt	server_iduiduitemsuDeleting volume %st	volume_iduDeleted volume %sudestroyed instanceusalt/cloud/{0}/destroyeduupdate_cachedirucloud.delete_minion_cachediru:iN(RRkR>RRHR(RrR8RR'RRtget_attached_volumest
delete_serverRFR�t
delete_volumeR7R�RR*(RLR+RDR-Rdtattached_volumestdelete_volumestvol((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyR��sV

				
	


cC@s?t�}t�}t||�}|jd|d|d�tS(u�
    reboot a machine by name
    :param name: name given to the machine
    :param call: call value in this case is 'action'
    :return: true if successful

    CLI Example:

    .. code-block:: bash

        salt-cloud -a reboot vm_name
    RDR�uid(RHR(Rrt
reboot_serverR�(RLR+RDR-Rd((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytreboot	s

		cC@s?t�}t�}t||�}|jd|d|d�tS(u�
    stop a machine by name
    :param name: name given to the machine
    :param call: call value in this case is 'action'
    :return: true if successful

    CLI Example:

    .. code-block:: bash

        salt-cloud -a stop vm_name
    RDR�uid(RHR(Rrtstop_serverR�(RLR+RDR-Rd((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytstops

		cC@s?t�}t�}t||�}|jd|d|d�tS(u�
    start a machine by name
    :param name: name given to the machine
    :param call: call value in this case is 'action'
    :return: true if successful


    CLI Example:

    .. code-block:: bash

        salt-cloud -a start vm_name
    RDR�uid(RHR(Rrtstart_serverR�(RLR+RDR-Rd((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pytstart5s
		cC@sJt|�}d|kr)|d|d<nd|krF|d|d<n|S(uK
    Apply any extra component overrides to VM from the cloud profile.
    ucoresuram(RC(R?R@((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyt_override_sizeLscC@s�t|�}tjd|tdddt�}tjd|tdddt�}td|dd|dd	|d
|dd|d
|d|�S(u=
    Construct server instance from cloud profile config
    uavailability_zoneRVR%u
cpu_familyRLunametramuramtavailability_zonetcoresucorest
cpu_familytcreate_volumesR|N(R�RR'RR8RR(R?R�R|R@R�R�((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyR�[s		


cC@s�t|�d}d|kr)|d}ntddj|d�d|dt|��}d|kry|d}||_nt|�}||_d	|j�kr�|d	|_n/t	|�d
|_
d|kr�|d|_n|S(uC
    Construct VM system volume list from cloud profile config
    udisku	disk_sizeRLu{0} StorageunameRAt	disk_typeuimage_passworduimage_aliasuidudisk_availability_zone(RCR
R>RWtimage_passwordR�R�tkeystimage_aliasR^R5R�(R?t	disk_sizetvolumeR�R�((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyR�zs$

	c
C@s�g}|d}x�tj|�D]�\}}d||j�krZtdj|���nd||j�kr�d||d<ntd|d||dd||dd	d
�}d||j�kr�||d|_n|j|�q W|S(uJ
    Construct a list of optional data volumes from the cloud profile
    uvolumesu	disk_sizeu'The volume '{0}' is missing 'disk_size'u	disk_typeuHDDRLRAR�tlicence_typeuOTHERudisk_availability_zone(R	t	iteritemsR�RR>R
R�R_(R?R,R�R]tvalueR�((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyR��s"
	cC@s(g}x|D]}|j|�q
W|S(u(
    Construct a list of ip address
    (R_(tip_addressesR,R.((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyRy�s
cC@sg}xtj|�D]\}}d||j�krPtdj|���n|jtd|d||jdd�d||jdd�d||jdd�d	||jd
d�d||jdd�d
||jdd�d||jdd�d||jdd��	�qW|S(uM
    Construct a list of optional firewall rules from the cloud profile.
    uprotocolu-The firewall rule '{0}' is missing 'protocol'RLtprotocolt
source_macu
source_mact	source_ipu	source_ipt	target_ipu	target_iptport_range_startuport_range_starttport_range_enduport_range_endt	icmp_typeu	icmp_typet	icmp_codeu	icmp_codeN(	R	R�R�RR>R_RR7R8(RuR,R]R�((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyRv�s cC@s�|s
dStj�|}x�|tj�kr�tjd�|jd|ddt�}|dddkrpdS|ddd	krtd
j|tj|d�|dd���qqWtdj|tj|d����dS(
u<
    Poll request status until resource is provisioned.
    Nit
request_idu	requestIdtstatusumetadataustatusuDONEuFAILEDu4Request: {0}, requestId: {1} failed to complete:
{2}umessageuCTimed out waiting for asynchronous operation {0} "{1}" to complete.(ttimetsleeptget_requestR�R�R>R	R=(R-tpromisetwait_timeouttmsgtoperation_result((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyRP�s$
	
	(Yt__doc__t
__future__RRRR�R�R�R�tsalt.utils.versionsRtsalt.utils.cloudRgtsalt.utils.filestsalt.utils.stringutilstsalt.configRtsalt.exceptionsRRRRRtsalt.extR	Rtprofitbricks.clientR
RRR
RRRRRRRR�R#tImportErrorRt	getLoggert__name__RFRRRR!RR(R8R2R6R3R<RCRHRIRORERURWRXR^RSReRnRoRqRrRsR}RwR�R�R�R�R�R�R�R�R�R�R�R�RyRvRP(((sB/usr/lib/python2.7/site-packages/salt/cloud/clouds/profitbricks.pyt<module>^s|(	L


	
			
	$;			$	
	
	,!	
		!					�O			$	"		

Zerion Mini Shell 1.0