%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/states/cloud.pyo

�
���^c@@s�dZddlmZmZmZddlZddlmZddlj	j
Zd�Zd�Z
ddd�Zd	�Zdddd
�Zddd�Zdddd�Zdd
�Zdd�Zdd�Zddd�ZdS(u�
Using states instead of maps to deploy clouds
=============================================

.. versionadded:: 2014.1.0

Use this minion to spin up a cloud instance:

.. code-block:: yaml

    my-ec2-instance:
      cloud.profile:
        my-ec2-config
i(tabsolute_importtprint_functiontunicode_literalsN(tsixcC@s
dtkS(u@
    Only load if the cloud module is available in __salt__
    u
cloud.profile(t__salt__(((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pyt__virtual__scC@s^i|d6id6dd6dd6}tj|d�rLd|d<t|d<|St|d<|SdS(Nunameuchangesuresultuucommentua-zA-Z0-9._-uInvalid characters in name.(tNonetsuct
check_nametFalsetTrue(tnametret((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pyt_check_name#s




ucC@s/|si}ni|d6td6|d6|d6S(Nunameuresultuchangesucomment(R
(Rtcommenttchanges((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pyt_valid1s	
cC@s9tjdt�}tdddd|�}|td<|S(Nutestucloud.actiontfunu
show_instancetnames(t__opts__tgetR	R(Rttesttinstance((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pyt
_get_instance:s
c	K@s<i|d6id6dd6dd6}td}|dk	r�t|tj�sc|s�t|dd�Sq�t|tj�r�||d	t�d
kr�t|dd�Sq�n|dk	rt|tj�s�|rt|dd�Sqt|tj�r||d	t�d
krt|dd�Sqntdd
|dd�rTt|d<dj|�|d<|Stdrudj|�|d<|Std||d||�}|r�d|kr�||d<t|d<dj||t	j
|��|d<n\|rd|krt|d<dj|t|d�|d<n t|d<dj|t�|d<|S(ub
    Spin up a single instance on a cloud provider, using salt-cloud. This state
    does not take a profile argument; rather, it takes the arguments that would
    normally be configured as part of the state.

    Note that while this function does take any configuration argument that
    would normally be used to create an instance, it will not verify the state
    of any of those arguments on an existing instance. Stateful properties of
    an instance should be configured using their own individual state (i.e.,
    cloud.tagged, cloud.untagged, etc).

    name
        The name of the instance to create

    cloud_provider
        The name of the cloud provider to use

    onlyif
        Do run the state only if is unless succeed

    unless
        Do not run the state at least unless succeed

    opts
        Any extra opts that need to be used
    unameuchangesuresultuucommentucmd.retcodeRuonlyif condition is falsetpython_shelliuunless condition is trueucloud.has_instanceRtprovideruAlready present instance {0}utestu Instance {0} needs to be createducloud.createtoptsuErroruFCreated instance {0} using provider {1} and the following options: {2}u3Failed to create instance {0}using profile {1}: {2}uPFailed to create instance {0} using profile {1}, please check your configurationN(
RRt
isinstanceRtstring_typesRR
tformatRtpprinttpformatR	tprofile(	Rtcloud_providertonlyiftunlessRtkwargsRtretcodetinfo((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pytpresentCsZ









cC@si|d6id6dd6dd6}td}|dk	r�t|tj�sc|s�t|dd�Sq�t|tj�r�||d	t�d
kr�t|dd�Sq�n|dk	rt|tj�s�|rt|dd�Sqt|tj�r||d	t�d
krt|dd�Sqntdd
|dd�sTt|d<dj|�|d<|Stdrudj|�|d<|Std|�}|r�d|kr�||d<t|d<dj|�|d<nPd|kr�t	|d<dj||d�|d<nt	|d<dj|�|d<|S(u�
    Ensure that no instances with the specified names exist.

    CAUTION: This is a destructive state, which will search all
    configured cloud providers for the named instance,
    and destroy it.

    name
        The name of the instance to destroy

    onlyif
        Do run the state only if is unless succeed

    unless
        Do not run the state at least unless succeed

    unameuchangesuresultuucommentucmd.retcodeRuonlyif condition is falseRiuunless condition is trueucloud.has_instanceRRuAlready absent instance {0}utestu"Instance {0} needs to be destroyedu
cloud.destroyuErroruDestroyed instance {0}u#Failed to destroy instance {0}: {1}uFailed to destroy instance {0}N(
RRRRRRR
RRR	(RR"R#RR%R&((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pytabsent�sN








c	K@s�i|d6id6dd6dd6}td}|dk	r�t|tj�sc|s�t|dd�Sq�t|tj�r�||d	t�d
kr�t|dd�Sq�n|dk	rt|tj�s�|rt|dd�Sqt|tj�r||d	t�d
krt|dd�Sqnt|g�}|rgtd�|D��rgt|d<d
j	|�|d<|St
dr�dj	|�|d<|Std||d|d|�}	|	jdd�}
d}t|	t�r|	j|i�}t|t�r|jdd�}qn|
p|}
|	r�|
r�|	j|�}t|d<dj	||�}d|kr~|d|d<|jd|�|d<q�|	|d<||d<n^|
r�t
|d<dj	||dj	|
|�j��|d<n t
|d<dj	||�|d<|S(u0
    Create a single instance on a cloud provider, using a salt-cloud profile.

    Note that while profiles used this function do take any configuration
    argument that would normally be used to create an instance using a profile,
    this state will not verify the state of any of those arguments on an
    existing instance. Stateful properties of an instance should be configured
    using their own individual state (i.e., cloud.tagged, cloud.untagged, etc).

    name
        The name of the instance to create

    profile
        The name of the cloud profile to use

    onlyif
        Do run the state only if is unless succeed

    unless
        Do not run the state at least unless succeed

    kwargs
        Any profile override or addition

    opts
        Any extra opts that need to be used
    unameuchangesuresultuucommentucmd.retcodeRuonlyif condition is falseRiuunless condition is truecs@s|]}d|kVqdS(uNot ActionedN((t.0tkey((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pys	<genexpr>
suAlready present instance {0}utestu Instance {0} needs to be createdu
cloud.profiletvm_overridesRuErroru&Created instance {0} using profile {1}u4Failed to create instance {0} using profile {1}: {2}u{0}
{1}
u.Failed to create instance {0}using profile {1}N(RRRRRRR
RtanyRRRtdictR	tstrip(RR R"R#RR$RR%RR&t
main_errort
name_errortsubinfoterrort	node_infotdefault_msg((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pyR �sp









"

cK@st|�}|ds|Stdd|�}||krZdj|�|d<t|d<|Stdr�dj|�|d<d|d<|Stdd	|d||�}|r�t|d<d
j|�|d<idd6|d6|d
<nt|d<dj|�|d<|S(u+
    Check that a block volume exists.
    uresultucloud.volume_listRuVolume exists: {0}ucommentutestuVolume {0} will be created.ucloud.volume_createRuVolume {0} was createduoldunewuchangesuVolume {0} failed to create.N(R
RRR
RRR	(RRR$Rtvolumestresponse((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pytvolume_present<s.




	

cK@s�t|�}|ds|Stdd|�}||krQd|d<t|d<|Stdr|dj|�|d<d|d<|Stdd	|d||�}|r�t|d<d
j|�|d<i||d6|d6|d
<nt|d<dj|�|d<|S(u+
    Check that a block volume exists.
    uresultucloud.volume_listRuVolume is absent.ucommentutestuVolume {0} will be deleted.ucloud.volume_deleteRuVolume {0} was deleteduoldunewuchangesuVolume {0} failed to delete.N(R
RR
RRRR	(RRR$RR5R6((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pyt
volume_absent^s.





	

c		K@s�t|�}|ds|St|�}|ds4|Stdd|�}tdddd|�}||kr�||dr�||}d	j||�|d
<t|d<|S||kr�dj|�|d
<t|d<|S|s�dj|�|d
<t|d<|Std
r(dj|�|d
<d|d<|Stdd|d|d||�}|r�t|d<dj|�|d
<i||d6|d6|d<nt|d<dj|�|d
<|S(u.
    Check if a block volume is attached.
    uresultucloud.volume_listRucloud.actionRu
show_instanceRuattachmentsu0Volume {name} is already attached: {attachments}ucommentuVolume {0} does not existuServer {0} does not existutestu$Volume {0} will be will be attached.ucloud.volume_attachtserver_nameuVolume {0} was createduoldunewuchangesuVolume {0} failed to attach.N(R
RRR
R	RR(	RR9RR$RR5RtvolumeR6((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pytvolume_attached�sR


	







	

c	
K@s�t|�}|ds|S|dk	rCt|�}|dsC|Sntdd|�}|r{tdddd|g�}nd}||kr�||dr�||}d	j||�|d
<t|d<|S||kr�dj|�|d
<t|d<|S|r,|dk	r,dj|�|d
<t|d<|Std
rWdj|�|d
<d|d<|Stdd|d|d||�}|r�t|d<dj|�|d
<i||d6|d6|d<nt|d<dj|�|d
<|S(ub
    Check if a block volume is attached.

    Returns True if server or Volume do not exist.
    uresultucloud.volume_listRucloud.actionRu
show_instanceRuattachmentsu4Volume {name} is not currently attached to anything.ucommentuVolume {0} does not existuServer {0} does not existutestu$Volume {0} will be will be detached.ucloud.volume_detachR9uVolume {0} was createduoldunewuchangesuVolume {0} failed to detach.N(R
RRRR
RR	(	RR9RR$RR5RR:R6((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pytvolume_detached�sT









	

(t__doc__t
__future__RRRRtsalt.extRtsalt.utils.cloudtutilstcloudRRR
RRRR'R(R R7R8R;R<(((s5/usr/lib/python2.7/site-packages/salt/states/cloud.pyt<module>s					VAb"":

Zerion Mini Shell 1.0