%PDF- %PDF-
| Direktori : /proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/salt/states/ |
| Current File : //proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/salt/states/cloud.pyo |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l m Z d d l j j
Z d � Z d � Z
d d d � Z d � Z d d d d
� Z d d d � Z d d d d � Z d d
� Z d d � Z d d � Z d d d � Z d S( 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 ( t absolute_importt print_functiont unicode_literalsN( t sixc C@ s
d t k S( 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__ s c C@ s^ i | d 6i d 6d d 6d d 6} t j | d � rL d | d <t | d <| St | d <| Sd S( Nu nameu changesu resultu u commentu a-zA-Z0-9._-u Invalid characters in name.( t Nonet suct
check_namet Falset True( t namet ret( ( s5 /usr/lib/python2.7/site-packages/salt/states/cloud.pyt _check_name# s
u c C@ s/ | s i } n i | d 6t d 6| d 6| d 6S( Nu nameu resultu changesu comment( R
( R t commentt changes( ( s5 /usr/lib/python2.7/site-packages/salt/states/cloud.pyt _valid1 s
c C@ s9 t j d t � } t d d d d | � } | t d <| S( Nu testu cloud.actiont funu
show_instancet names( t __opts__t getR R ( R t testt instance( ( s5 /usr/lib/python2.7/site-packages/salt/states/cloud.pyt
_get_instance: s
c K@ s< i | d 6i d 6d d 6d d 6} t d } | d k r� t | t j � sc | s� t | d d �Sq� t | t j � r� | | d t �d
k r� t | d d �Sq� n | d k rt | t j � s� | rt | d d �Sqt | t j � r| | d t �d
k rt | d d �Sqn t d d
| d d � rTt | d <d j | � | d <| St d rud j | � | d <| St d | | d | | �} | r�d | k r�| | d <t | d <d j | | t j
| � � | d <n\ | rd | k rt | d <d j | t | d � | d <n t | d <d j | 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
u nameu changesu resultu u commentu cmd.retcodeR u onlyif condition is falset python_shelli u unless condition is trueu cloud.has_instanceR t provideru Already present instance {0}u testu Instance {0} needs to be createdu cloud.createt optsu ErroruF Created instance {0} using provider {1} and the following options: {2}u3 Failed to create instance {0}using profile {1}: {2}uP Failed to create instance {0} using profile {1}, please check your configurationN(
R R t
isinstanceR t string_typesR R
t formatR t pprintt pformatR t profile( R t cloud_providert onlyift unlessR t kwargsR t retcodet info( ( s5 /usr/lib/python2.7/site-packages/salt/states/cloud.pyt presentC sZ
c C@ s i | d 6i d 6d d 6d d 6} t d } | d k r� t | t j � sc | s� t | d d �Sq� t | t j � r� | | d t �d
k r� t | d d �Sq� n | d k rt | t j � s� | rt | d d �Sqt | t j � r| | d t �d
k rt | d d �Sqn t d d
| d d � sTt | d <d j | � | d <| St d rud j | � | d <| St d | � } | r�d | k r�| | d <t | d <d j | � | d <nP d | k r�t | d <d j | | d � | d <n t | d <d j | � | 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
u nameu changesu resultu u commentu cmd.retcodeR u onlyif condition is falseR i u unless condition is trueu cloud.has_instanceR R u Already absent instance {0}u testu"