%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@svdZddlmZmZmZddlZddlZddlZddlZddl	m
Z
ddlZddl
ZddlZddlZddlZddlmZyddlZWnek
r�ZnXddlTddljZddlmZddlmZmZmZm Z m!Z!ydd	l"m#Z#e$Z%Wnek
rXe&Z%nXej'e(�Z)ej'd
�Z*dZ+ee,e-��Z,ee.e-��Z.d�Z/d
�Z0d�Z1d�Z2ddd�Z4d�Z5d�Z6dd�Z7d�Z8d�Z9d�Z:d�Z;d�Z<d�Z=d�Z>d�Z?ddd�Z@ddd�ZAd�ZBd�ZCd �ZDd!�ZEdd"�ZFdd#�ZGdd$�ZHdd%�ZId&ddd'�ZJeJZKd(�ZLd)�ZMd*d+�ZNeNZOdd,�ZPePZQd-�ZRdd.�ZSd/�ZTd0�ZUd1�ZVdd2�ZWdd3�ZXdd4�ZYdd5�ZZdd6�Z[dd7�Z\dS(8u�
OpenStack Nova Cloud Module
===========================

OpenStack is an open source project that is in use by a number a cloud
providers, each of which have their own ways of using it.

The OpenStack Nova module for Salt Cloud was bootstrapped from the OpenStack
module for Salt Cloud, which uses a libcloud-based connection. The Nova module
is designed to use the nova and glance modules already built into Salt.

These modules use the Python novaclient and glanceclient libraries,
respectively. In order to use this module, the proper salt configuration must
also be in place.  This can be specified in the master config, the minion
config, a set of grains or a set of pillars.

.. code-block:: yaml

    my_openstack_profile:
      keystone.user: admin
      keystone.password: verybadpass
      keystone.tenant: admin
      keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'

Note that there is currently a dependency upon netaddr. This can be installed
on Debian-based systems by means of the python-netaddr package.

This module currently requires the latest develop branch of Salt to be
installed.

This module has been tested to work with HP Cloud and Rackspace. See the
documentation for specific options for either of these providers. These
examples could be set up in the cloud configuration at
``/etc/salt/cloud.providers`` or
``/etc/salt/cloud.providers.d/openstack.conf``:

.. code-block:: yaml

    my-openstack-config:
      # The name of the configuration profile to use on said minion
      config_profile: my_openstack_profile

      ssh_key_name: mykey

      driver: nova
      userdata_file: /tmp/userdata.txt

To use keystoneauth1 instead of keystoneclient, include the `use_keystoneauth`
option in the provider config.

.. note:: this is required to use keystone v3 as for authentication.

.. code-block:: yaml

    my-openstack-config:
      use_keystoneauth: True
      identity_url: 'https://controller:5000/v3'
      auth_version: 3
      compute_name: nova
      compute_region: RegionOne
      service_type: compute
      verify: '/path/to/custom/certs/ca-bundle.crt'
      tenant: admin
      user: admin
      password: passwordgoeshere
      driver: nova

Note: by default the nova driver will attempt to verify its connection
utilizing the system certificates. If you need to verify against another bundle
of CA certificates or want to skip verification altogether you will need to
specify the verify option. You can specify True or False to verify (or not)
against system certificates, a path to a bundle or CA certs to check against, or
None to allow keystoneauth to search for the certificates on its own.(defaults to True)

For local installations that only use private IP address ranges, the
following option may be useful. Using the old syntax:

Note: For api use, you will need an auth plugin.  The base novaclient does not
support apikeys, but some providers such as rackspace have extended keystone to
accept them

.. code-block:: yaml

    my-openstack-config:
      # Ignore IP addresses on this network for bootstrap
      ignore_cidr: 192.168.50.0/24

    my-nova:
      identity_url: 'https://identity.api.rackspacecloud.com/v2.0/'
      compute_region: IAD
      user: myusername
      password: mypassword
      tenant: <userid>
      driver: nova

    my-api:
      identity_url: 'https://identity.api.rackspacecloud.com/v2.0/'
      compute_region: IAD
      user: myusername
      api_key: <api_key>
      os_auth_plugin: rackspace
      tenant: <userid>
      driver: nova
      networks:
        - net-id: 47a38ff2-fe21-4800-8604-42bd1848e743
        - net-id: 00000000-0000-0000-0000-000000000000
        - net-id: 11111111-1111-1111-1111-111111111111

This is an example profile.

.. code-block:: yaml

    debian8-2-iad-cloudqe4:
      provider: cloudqe4-iad
      size: performance1-2
      image: Debian 8 (Jessie) (PVHVM)
      script_args: -UP -p python-zmq git 2015.8

and one using cinder volumes already attached

.. code-block:: yaml

    # create the block storage device
    centos7-2-iad-rackspace:
      provider: rackspace-iad
      size: general1-2
      block_device:
        - source: image
          id: <image_id>
          dest: volume
          size: 100
          shutdown: <preserve/remove>
          bootindex: 0

    # with the volume already created
    centos7-2-iad-rackspace:
      provider: rackspace-iad
      size: general1-2
      boot_volume: <volume id>

    # create the volume from a snapshot
    centos7-2-iad-rackspace:
      provider: rackspace-iad
      size: general1-2
      snapshot: <cinder snapshot id>

    # create the create an extra ephemeral disk
    centos7-2-iad-rackspace:
      provider: rackspace-iad
      size: general1-2
      ephemeral:
        - size: 100
          format: <swap/ext4>

    # create the create an extra ephemeral disk
    centos7-2-iad-rackspace:
      provider: rackspace-iad
      size: general1-2
      swap: <size>

Block Device can also be used for having more than one block storage device attached

.. code-block:: yaml

    centos7-2-iad-rackspace:
      provider: rackspace-iad
      size: general1-2
      block_device:
        - source: image
          id: <image_id>
          dest: volume
          size: 100
          shutdown: <preserve/remove>
          bootindex: 0
        - source: blank
          dest: volume
          device: xvdc
          size: 100
          shutdown: <preserve/remove>

Floating IPs can be auto assigned and ssh_interface can be set to fixed_ips, floating_ips, public_ips or private_ips

.. code-block:: yaml

    centos7-2-iad-rackspace:
      provider: rackspace-iad
      size: general1-2
      ssh_interface: floating_ips
      floating_ip:
        auto_assign: True
        pool: public


Note: You must include the default net-ids when setting networks or the server
will be created without the rest of the interfaces

Note: For rackconnect v3, rackconnectv3 needs to be specified with the
rackconnect v3 cloud network as its variable.
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tnova(t*(tnamespaced_function(tSaltCloudConfigErrortSaltCloudNotFoundtSaltCloudSystemExittSaltCloudExecutionFailuretSaltCloudExecutionTimeout(tall_matching_cidrsurequestsunovacC@sctjtttjdd�j���t�tkr;tSt	�tkrNtSt
ddd�tS(u'
    Check for Nova configurations
    urequests_log_leveluwarninguversions.warn_untiluNeonu~This driver has been deprecated and will be removed in the {version} release of Salt. Please use the openstack driver instead.(trequest_logtsetLeveltgetattrtloggingt__opts__tgettuppertget_configured_providertFalsetget_dependenciest	__utils__t__virtualname__(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyt__virtual__�s(cC@stjttptd�S(u/
    Return the first configured instance.
    uuserutenantuidentity_urlucompute_region(uuserutenantuidentity_urlucompute_region(tconfigtis_provider_configuredRt__active_provider_name__R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyRs	cC@s*itd6tj�d6}tjt|�S(u*
    Warn if dependencies aren't met.
    unetaddrupython-novaclient(tHAS_NETADDRRt
check_novaRtcheck_driver_dependenciesR(tdeps((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyRscC@s�t�}|j�}|d|d<|d|d<|d|d<|d|d<|jd	t�|d	<d
|kr�|d
|d
<nd|kr�|d	tkr�|d|d<n,d|kr�|d	tkr�tjd�ntj|�}|S(
u5
    Return a conn object for the passed VM data
    uuseruusernameutenantu
project_iduidentity_urluauth_urlucompute_regionuregion_nameuuse_keystoneauthupassworduverifyu]SSL Certificate verification option is specified but use_keystoneauth is False or not present(	RtcopyRRtTruetlogtwarningRtSaltNova(tvm_tkwargstconn((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytget_conn-s	cC@s{|dkrtd��n|dkr3t�}ntj|j�dd�d}i}x|D]}|||d<q_W|S(u$
    Return a list of locations
    uactionufThe avail_locations function must be called with -f or --function, or with the --list-locations optionutypeucomputeu	endpointsuregionN(R	tNoneR)Rt	get_entrytget_catalog(R(tcallt	endpointstrettendpoint((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytavail_locationsGs
cC@s�tjd|tdd�jdd�}|s>tjd�d	S|j�}x4|D],}|||d|fkrQ||dSqQWy|j|�}|dSWn1t	j
jk
r�}tdj
||���nXd	S(
u(
    Return the image object to use
    uimagetdefaultuuasciiusalt-cloud-force-asciiu&No image set, must be boot from volumeuidu3The specified image, '{0}', could not be found: {1}N(Rtget_cloud_config_valueRtencodeR#tdebugR*t
image_listt
image_showt
novaclientt
exceptionstNotFoundRtformat(R(R&tvm_imageR6timgtimagetexc((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyt	get_image\s"

cC@s�i}tjd|tdi�|d<tjd|tdg�|d<tjd|tdg�|d<tjd|tdd�|d<tjd|tdd�|d<tjd|tdd�|d<|S(Nublock_device_mappingR2ublock_deviceu	ephemeraluswapusnapshotuboot_volume(RR3RR*(R&R/((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytget_block_mapping_optsyscC@sN|dkrtd��nt�}|j|�j}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(R	R)t
show_instancet__dict__RRR(tnameR-R(tnode((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyRB�s	cC@s�|j�}tjd|t�}|s/|dSxU|D]M}|r6tj|�tj||d�tj|�fkr6||dSq6Wtdj|���dS(u%
    Return the VM's size object
    usizeiuidu.The specified size, '{0}', could not be found.N(t
list_sizesRR3RRt	text_typeRR;(R(R&tsizestvm_sizetsize((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytget_size�s
;cC@s�tjd|tdddt�}tj}|dkrBtj}nx=|D]5}ytj||�|SWqItk
r}qIqIXqIWtS(uT
    Return the preferred Internet protocol. Either 'ipv4' (default) or 'ipv6'.
    uprotocolR2uipv4t
search_globaluipv6(	RR3RRtsockettAF_INETtAF_INET6t	inet_ptont	Exception(R&tipstprototfamilytip((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytpreferred_ip�s	

cC@swttkrtjd�dStjd|tdddt�}|dkrst||g�rstjd||�t	StS(uQ
    Return True if we are to ignore the specified IP. Compatible with IPv4.
    uError: netaddr is not installeduignore_cidrR2uRLu'IP "%s" found within "%s"; ignoring it.(
RRR#terrorRR3RRR$R"(R&RUtcidr((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytignore_cidr�s
cC@stjd|tdddt�S(uj
    Return the ssh_interface type to connect to. Either 'public_ips' (default)
    or 'private_ips'.
    u
ssh_interfaceR2u
public_ipsRL(RR3RR(R&((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyt
ssh_interface�scC@stjd|tdtdt�S(ux
    Determine if we should wait for rackconnect automation before running.
    Either 'False' (default) or 'True'.
    urackconnectR2RL(RR3RR(R&((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytrackconnect�scC@stjd|tdtdt�S(ul
    Determine if server is using rackconnectv3 or not
    Return the rackconnect network name or False
    u
rackconnectv3R2RL(RR3RR(R&((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyt
rackconnectv3�scC@stjd|tdtdt�S(uj
    Determine if we should use an extra network to bootstrap
    Either 'False' (default) or 'True'.
    ucloudnetworkR2RL(RR3RR(R&((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytcloudnetwork�scC@stjd|tdtdt�S(u~
    Determine if we should wait for the managed cloud automation before
    running. Either 'False' (default) or 'True'.
    umanagedcloudR2RL(RR3RR(R&((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytmanagedcloud�sc
C@s�|dkrtd��ntddddj|�di|d6d	td
dtd�|skt�}n|j|�}t�d
}|d#kr�tj	d|�nd#}d|j
kr�d|j
dkr�|j
dd}nt}|r||krd||kr||d}n|r\tjd|�t
jjtd�}|j|d�}ntjd||�tjd|�|j|j�}	|	rztjd|�tddddj|�di|d6d	td
dtd�tjdt�tkr,t
jjjt|tjdd��d�ntjdt�tkrhtd|tjd �dt�ntd!|�tStj	d"|�tS($u
    Delete a single VM
    ufunctionuEThe destroy action must be called with -d, --destroy, -a or --action.ucloud.fire_eventueventudestroying instanceusalt/cloud/{0}/destroyingtargsunametsock_dirusock_dirt	transportu	transportuprofilesuUnable to find the VM %sumetadatauprofileuflush_mine_on_destroyuClearing Salt Mine: %su	conf_fileu
mine.flushuClearing Salt Mine: %s, %suDestroying VM: %suDestroyed VM: %sudestroyed instanceusalt/cloud/{0}/destroyedudelete_sshkeysu
ssh_interfaceu
public_ipsiuupdate_cachedirucloud.delete_minion_cachediru:ucloud.cachedir_index_deluFailed to Destroy VM: %sN(R	RR;RR)tserver_by_nameRR*R#RWtextraRtinfotsalttclienttget_local_clienttcmdtdeletetidRR"tutilstcloudt
remove_sshkeyRRtsplit(
RDR(R-REtprofilestprofiletflush_mine_on_destroytsalt_clienttminionsR/((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytdestroys\


""

/$cC@s;|dkrtd��ntjd|d�tjjj|dd�t�}|j�}yt	||�|d<Wn6t
k
r�}tdj|d|d|���nXyt||�|d	<Wn6t
k
r�}td
j|d|d|���nXt
jd|td
t�|d<t
jd|td
t�}|dk	r�|}|j�}g}xa|D]Y}	|	gtj|�D]\}
}|
^q|kr�|j|	�qctdj|	���qcW||d<nt
jd|tddd
t�}|dk	r||d<nt
jd|td
tdd�|d<t
jd|td
t�}
|
r�i|d<xu|
D]j}tjj|
|�r�tjjj|
|d��}|j�|d|<WdQXq^|
||d|<q^Wnt
jd|td
tdd�}|dk	rryJtjjj|d��,}tjjjt||j��|d<WdQXWqrt
k
rn}tjd||�qrXnt
jd|td
t�|d<|jt |��i|dd6|j!dd�d6|d	d6}t"dddd j|d�d!it"d"d#|t#|��d$6d%td&d'td(�y|j$|�}Wn/t
k
ro}td)j|d|���nX|j%j!d*d�dkr�|j!d+d�dkr�td,��nt
jd-|td
tdi�}|j!d.t�rd}|j!d/d�dk	rg|j!d/d�}y|j&|�}|d0}Wq$t
k
rc}td1j|d|���q$Xn�|j!d2d3�}y|j'|�d0}Wn�t
k
r#tjd4�xMtj|j(��D]6\}}|d5dkr�|d2|kr�|}Pq�q�W|dkr$tj)d6|d�q$nXd7�}y tjjj*|d8|f�Wn\t+t,fk
r�}z*yt-|d�Wntk
r�nXWdttj.|���XnXy"|j/|d|�||d-<Wqt
k
r�}td1j|d|���qXn|j!d*d�s1|j%j!d*d9�|d*<n||fS(:u�
    Put together all of the information necessary to request an instance
    through Novaclient and then fire off the request the instance.

    Returns data about the instance
    ufunctionu?The request_instance action must be called with -a or --action.uCreating Cloud VM %sunameua-zA-Z0-9._-uimage_idu?Error creating {0} on OPENSTACK

Could not find image {1}: {2}
uimageu	flavor_idu>Error creating {0} on OPENSTACK

Could not find size {1}: {2}
usizeussh_key_nameRLukey_nameusecurity_groupsuNo such security group: '{0}'uavailability_zoneR2unetworksunicsufilesurNu
userdata_fileuuserdatau#Failed to read userdata from %s: %suconfig_driveuBoot From Volumeucloud.fire_eventueventurequesting instanceusalt/cloud/{0}/requestingR_ucloud.filter_eventu
requestingukwargsR`usock_dirRau	transportuzError creating {0} on Nova

The following exception was thrown by libcloud when trying to run the initial deployment: {1}
upasswordukey_filenameu(No password returned.  Set ssh_key_file.ufloating_ipuauto_assignu
ip_addressuipu�Error assigning floating_ip for {0} on Nova

The following exception was thrown by libcloud when trying to assign a floating ip: {1}
upoolupublicu�A new IP address was unable to be allocated. An IP address will be pulled from the already allocated list, This will cause a race condition when building in parallel.ufixed_ipu9No IP addresses available to allocate for this server: %scS@s{y7t|dd�}tjd|dtj|��Wn-tk
rf}tjd|dtj�t	SX|ddkpzdS(NunameuactionuLoaded node data for %s:
%suFailed to get nodes list: %stexc_info_on_loglevelustateuACTIVE(RBR#R5tpprinttpformatRQRWRtDEBUGRR*(R&REterr((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyt__query_node_data�s$	
tupdate_argsu(0R	R#RdReRkRlt
check_nameR)R!R@RQR;RKRR3RRR*t
secgroup_listRt	iteritemstappendRtostpathtexiststfilestfopentreadtuserdata_templatet	exceptiontupdateRARRtlisttbootRctfloating_ip_showtfloating_ip_createtfloating_ip_listRWtwait_for_ipRR
RtRGtfloating_ip_associate(R&R-R(R'R?tsecurity_groupst	vm_groupstavail_groupst
group_listtvmgRDtdetailstavzR�tsrc_pathtfp_t
userdata_filetevent_kwargstdatatfloating_ip_conftfloating_ipt
ip_addresst
fl_ip_dictRytpooltfl_iptoptsRz((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytrequest_instanceBs	
.



# 
3		

" 	
c
C@shy7t|dd�}tjd|dtj|��Wn-tk
rf}tjd|dtj�t	SX|ddk}|s�dSt
|�tkr�|jdi�}|jd	i�jd
d�}|dkr�tjd
�dSnt
|�tkrI|j|d�j}|jd	i�jdd�}|dkrItjd�dSn|jdi�jdd�}	t|�|dk}
t|�|dk}t|
|f�r|
r�t|�n	t|�}x<|dj|g�D]$}
|
ddkr�|
d}	Pq�q�Wt|d<ntt|�t
|�f�rat|�dksE|
ra|	dkra|	g|_|Sg}d|kr�d|kr�d|kr�d|kr�d|jdi�kr�|ddg}n|jdg�}|jdg�}|jdg�}|jdg�}|r�|r�tjd�x�|D]�}t||g�}|t	krVq,ntjjj|�r�tjd|�|jj|�tjd�|j}q,tjd|�t||�}||jkr,|r,|j|�q,q,Wn|rRt|�dkrRxF|D];}t||�}||jkr|r|j|�qqWng}|r�||_t|�dkr�|j|�q�n|r�||_t|�dkr�|j|�q�n|r�||_t|�dkr�|j|�q�n|r,tjd |�||_t|�dkr,|Sn|rdtjd |�||_t|�dkrd|SndS(!NunameuactionuLoaded node data for %s:
%suFailed to get nodes list: %sRuustateuACTIVEuextraumetadataurackconnect_automation_statusuuDEPLOYEDu.Waiting for Rackconnect automation to completeuidurax_service_level_automationuCompleteu0Waiting for managed cloud automation to completeu	access_ipu	addressesuversioniuaddrucloudnetworkuprivate_ipsu
public_ipsufloating_ipsu	fixed_ipsuDPrivate IPs returned, but not public. Checking for misidentified IPsu%s is a public IPuVPublic IP address was not ready when we last checked. Appending public IP address now.u%s is a private IPuresult = %s( RBR#R5RvRwRQRWRRxRR[R"RR^tserver_show_libcloudRcR\RZtanyR]t
public_ipsR$RVReRkRltis_public_ipRRYtprivate_ipstfloating_ipst	fixed_ips(R&R�R(RERytrunningRct	rc_statust	mc_statust	access_iptrcv3tsshiftnetworknametnetworktresulttprivatetpublictfixedtfloatingt
private_ipt	ignore_iptnon_private_ips((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyt_query_node_datas�$	









					c
C@s�y=|dr<tjttpd|dd|�tkr<tSWntk
rPnXtjd|t�}tjd|tdtdd&�}|d&k	r�tj	j
|�r�tdj|���n||d	<t
d
ddd
j|d�dt
dd|ddddg�dtddtd�t�}d|krd|kr�d|kr�tjd|d�tjjjtjjd|t��\|d<|d<n|j|d�}|d	d&kr*dtkr*tdtkr*tjjj�|d<|j|d|d�q*nt|�\}}|j|d<y^tjjjtd|||fd tjd!|tdd9�d$tjd%|tdd"��}Wn\ttfk
r�}z*yt |d�Wnt!k
r�nXWd&t!t"j#|���XnXtjd'�t$|�d(krt%||j&�}n`t$|�d)krBt%||j'�}n9t$|�d*krit%||j(�}nt%||j)�}tjd+|�tjjj*|t�d(kr�t%||j&�}tj+d,|�n�tjjj*|t�d)krt%||j'�}tj+d,|�netjjj*|t�d*krTt%||j(�}tj+d,|�n"t%||j)�}tjd,|�|s�t!d-��n||d.<||d/<t
d0|t�}|j,|j-�d|d1kr�|d1d=ntj+d2|d�tjd3|dt.j/|j-��i|dd6|dd6|dd6|dd6|j(d*6|j'd)6|j&d(6|j)d46}	t
d
dd5d6j|d�dt
dd7|	t0|	��dtddtd�t
d8|d|dd|d�|S(:u-
    Create a single VM from a data dict
    uprofileunovaR&udeployussh_key_fileRLR2u-The defined ssh_key_file '{0}' does not existukey_filenameucloud.fire_eventueventustarting createusalt/cloud/{0}/creatingunameR_ucloud.filter_eventucreatinguproviderudriverR`usock_dirRau	transportuinstance_idupub_keyupriv_keyuGenerating minion keys for '%s'ukeysizeuchange_passwordupasswordR{ttimeoutuwait_for_ip_timeouti
i<tintervaluwait_for_ip_intervalNuVM is now runninguprivate_ipsu	fixed_ipsufloating_ipsuUsing IP address %suSalt interface set to: %su A valid IP address was not foundussh_hostu	salt_hostucloud.bootstrapuextrauCreated Cloud VM '%s'u'%s' VM creation details:
%su
public_ipsucreated instanceusalt/cloud/{0}/createducreateducloud.cachedir_index_addiX(1Rtis_profile_configuredRRRtAttributeErrorR3R*R�R�tisfileRR;RR)R#R5ReRkRltgen_keysR�R"tpycryptotsecure_passwordt
root_passwordR�RjR�R�RR
RtR	RRGRZRVR�R�R�R�tget_salt_interfaceRdR�RCRvRwR�(
R&tdeploytkey_filenameR(R�R?R�tsalt_ip_addressR/t
event_data((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytcreate�s�	


"
		,









#cC@st�}|j�S(uI
    Return a dict of all available VM images on the cloud provider.
    (R)R6(R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytavail_images8s	cC@st�}|j�S(uH
    Return a dict of all available VM sizes on the cloud provider.
    (R)tflavor_list(R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytavail_sizes@s	cK@s|dkrtd��ni}t�}|j�}|s@iSx�|D]�}|j||d�j|�}|dkrqGng}g}d|kr�i|d<nx�|dD]�}	x�|d|	D]�}
tjjj	|
jdd��r�|j
|
d�q�d|
dkr#|j
|
d�q�d|
dkr�|j
|
d�q�q�Wq�W|d	r�tjjj	|d	�r�|j
|d	�q�|j
|d	�n|d
r�|j
|d
�ni|dd6|ddd6|ddd
6|dd6|d6|d6||<qGW|S(u8
    Return a list of the VMs that in this location
    uactionu=The list_nodes function must be called with -f or --function.uidu	addressesuaddruu:u.u
accessIPv4u
accessIPv6uimageuflavorusizeustateuprivate_ipsu
public_ipsN(R	R)tserver_listtserver_showRR*ReRkRlR�R(R-R'R/R(R�tservert
server_tmpR�R�R�taddress((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyt
list_nodesHsL	
 
!

cK@s�|dkrtd��ni}t�}|j�}|s@iSxL|D]D}y"|j||d�j||<WqGtk
r�}i}qGXqGWtd|tjd�dt	�|S(u8
    Return a list of the VMs that in this location
    uactionuBThe list_nodes_full function must be called with -f or --function.uiducloud.cache_node_listu:i(
R	R)R�R�RCt
IndexErrorRRRnR(R-R'R/R(R�R�R?((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytlist_nodes_full~s 	
!cK@s>|dkrtd��nt�}|j�}|s:iS|S(u8
    Return a list of the VMs that in this location
    uactionuAThe list_nodes_min function must be called with -f or --function.(R	R)tserver_list_min(R-R'R(R�((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytlist_nodes_min�s	cC@s tjjjt�td|�S(uO
    Return a list of the VMs that are on the provider, with select fields
    uquery.selection(ReRkRltlist_nodes_selectR�R(R-((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR��sidcK@sNt�}i|d6|d6|d6|d6}|jdd�|d<|j|�S(u%
    Create block storage device
    unameusizeusnapshotuvoltypeuavailability_zoneN(R)RR*t
volume_create(RDRJtsnapshottvoltypeR'R(t
create_kwargs((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR��s	

cK@st�}|j|�S(u%
    Delete block storage device
    (R)t
volume_delete(RDR'R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR��s	cK@st�}|j|dd�S(u
    Detach block volume
    R�i,(R)t
volume_detach(RDR'R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR��s	u	/dev/xvdbcK@s"t�}|j|||dd�S(u
    Attach block volume
    R�i,(R)t
volume_attach(RDtserver_nametdeviceR'R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR��s	c
K@s�|dkrtd��nt|d�tkrMtjjj|d�}n
|d}g}xF|D]>}t}i|dd6}d|kr�|d|d<ned|kr�|d|d<nH|d|d<d|kr�|d|d<nd	|kr|d	|d	<nd
|kr1t|�}t	}|j
|�ntd|dd|d
|jdd�dd�}	|	rddj|d
||d�}
tj|
�|j|
�qdqdW|S(u3
    Create and attach volumes to created node
    ufunctionuDThe create_attach_volumes action must be called with -a or --action.uvolumesunameu	volume_idusnapshotusizeutypeuiopsuidRDR�R�udeviceR-uactionu{0} attached to {1} (aka {2})N(R	ttypetstrReRktyamlt	safe_loadRt
create_volumeR"R�t
attach_volumeRR*R;R#RdR(RDR-R'tvolumesR/tvolumetcreatedtvolume_dicttcreated_volumetattachtmsg((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pytvolume_create_attach�sJ


	

cK@st�}|j�S(u
    List block devices
    (R)tvolume_list(R'R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR�-s	cK@st�}|j�S(u
    List private networks
    (R)tnetwork_list(R-R'R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR�5s	cK@st�}|j||�S(u!
    Create private networks
    (R)tnetwork_create(RDR'R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR�=s	cK@st�}|j|�S(u!
    Create private networks
    (R)tvirtual_interface_list(RDR'R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR�Es	cK@st�}|j||�S(u!
    Create private networks
    (R)tvirtual_interface_create(RDtnet_nameR'R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR�Ms	cC@s.|dkrtd��nt�}|j�S(uD
    List all floating IP pools

    .. versionadded:: 2016.3.0
    ufunctionuEThe floating_ip_pool_list action must be called with -f or --function(R	R)tfloating_ip_pool_list(R-R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR�Us
	cC@s.|dkrtd��nt�}|j�S(u;
    List floating IPs

    .. versionadded:: 2016.3.0
    ufunctionu@The floating_ip_list action must be called with -f or --function(R	R)R�(R-R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR�ds
	cC@sR|dkrtd��nd|kr8tjd�tSt�}|j|d�S(u@
    Allocate a floating IP

    .. versionadded:: 2016.3.0
    ufunctionuBThe floating_ip_create action must be called with -f or --functionupoolupool is required(R	R#RWRR)R�(R'R-R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR�ss
	cC@sR|dkrtd��nd|kr8tjd�tSt�}|j|d�S(uA
    De-allocate floating IP

    .. versionadded:: 2016.3.0
    ufunctionuBThe floating_ip_delete action must be called with -f or --functionufloating_ipufloating_ip is required(R	R#RWRR)tfloating_ip_delete(R'R-R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR��s
	cC@s`|dkrtd��nd|kr8tjd�tSt�}|j||d�t�|S(uU
    Associate a floating IP address to a server

    .. versionadded:: 2016.3.0
    uactionuDThe floating_ip_associate action must be called with -a of --action.ufloating_ipufloating_ip is required(R	R#RWRR)R�R�(RDR'R-R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR��s
	cC@s`|dkrtd��nd|kr8tjd�tSt�}|j||d�t�|S(uR
    Disassociate a floating IP from a server

    .. versionadded:: 2016.3.0
    uactionuGThe floating_ip_disassociate action must be called with -a of --action.ufloating_ipufloating_ip is required(R	R#RWRR)tfloating_ip_disassociateR�(RDR'R-R(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyR��s
	(]t__doc__t
__future__RRRR�RRMRvtsalt.extRtsalt.utils.cloudRetsalt.utils.filestsalt.utils.pycryptotsalt.utils.yamltsalt.clienttsalt.utils.openstackRtnovaclient.exceptionsR8tImportErrorR?tsalt.cloud.libcloudfuncstsalt.configRtsalt.utils.functoolsRtsalt.exceptionsRRR	R
RtnetaddrRR"RRt	getLoggert__name__R#R
RtscripttglobalstrebootRRRR)R*R1R@RARBRKRVRYRZR[R\R]R^RtR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�tcreate_attach_volumesR�R�R�R�R�R�R�R�R�R�R�(((s:/usr/lib/python2.7/site-packages/salt/cloud/clouds/nova.pyt<module>�s�
(


														@�	�	�		6			<				

Zerion Mini Shell 1.0