%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s}dZddlmZmZmZddlZddlZddlZ	ddl
Z	ddlmZ
ddlmZeje�ZdZy�ddlZddlmZddlmZeed	�r�e
ej�e
e�kr�e��nejd
�jej�eZWnek
r%e ZnXd�Z!d�Z"d
�Z#d�Z$dd�Z&d�Z'd�Z(d�Z)d�Z*d�Z+dd�Z,dd�Z-dd�Z.d�Z/d�Z0d�Z1dd�Z2dd�Z3d�Z4d�Z5dd�Z6d �Z7d!�Z8d"�Z9dd#�Z:d$�Z;d%�Z<d&�Z=d'�Z>d(�Z?d)�Z@d*�ZAd+�ZBd,�ZCd-�ZDdS(.u
Apache Libcloud Compute Management
==================================

Connection module for Apache Libcloud Compute management for a full list
of supported clouds, see http://libcloud.readthedocs.io/en/latest/compute/supported_providers.html

Clouds include Amazon EC2, Azure, Google GCE, VMware, OpenStack Nova

.. versionadded:: 2018.3.0

:configuration:
    This module uses a configuration profile for one or multiple cloud providers

    .. code-block:: yaml

        libcloud_compute:
            profile_test1:
              driver: google
              key: service-account@googlecloud.net
              secret: /path/to.key.json
            profile_test2:
              driver: arm
              key: 12345
              secret: mysecret

:depends: apache-libcloud
i(tabsolute_importtunicode_literalstprint_functionN(tLooseVersion(tsixu2.0.0(t
get_driver(tNodeu__version__ulibcloudcC@s#tsdjt�}t|fStS(u0
    Only load if libcloud libraries exist.
    uAA apache-libcloud library with version at least {0} was not found(tHAS_LIBCLOUDtformattREQUIRED_LIBCLOUD_VERSIONtFalsetTrue(tmsg((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyt__virtual__?s
	
cC@stjjjt�dS(N(tsalttutilstcompattpack_dundert__name__(topts((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyt__init__JscC@s�tdd�|}t|d�}|j�}|d=|jd�|d<|jdd�|d<|ddkrz|d=n|jdt�|d<|jdd�|d<|jdd�|d<||�S(	Nu
config.optionulibcloud_computeudriverukeyusecretusecureuhostuport(t__salt__RtcopytgettNoneR(tprofiletconfigtclstargs((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyt_get_driverNs
cK@satd|�}tjjj|�}|j|�}g}x!|D]}|jt|��q@W|S(u>
    Return a list of nodes

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_nodes method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.list_nodes profile1
    R(RRRRtclean_kwargst
list_nodestappendt_simple_node(Rtlibcloud_kwargstconntnodestrettnode((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR]s
c	K@s�td|�}tjjj|�}|dk	r�g|j�D]}|j|kr=|^q=}t|�dkrt	d��q�|j
d|d|�}n|j
|�}g}x!|D]}|jt|��q�W|S(u�
    Return a list of node sizes

    :param profile: The profile key
    :type  profile: ``str``

    :param location_id: The location key, from list_locations
    :type  location_id: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_sizes method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.list_sizes profile1
        salt myminion libcloud_compute.list_sizes profile1 us-east1
    RiuLocation not foundtlocationN(
RRRRRRtlist_locationstidtlent
ValueErrort
list_sizesR t_simple_size(	Rtlocation_idR"R#tloct	locationstsizesR%tsize((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR,vs.
cK@satd|�}tjjj|�}|j|�}g}x!|D]}|jt|��q@W|S(uY
    Return a list of locations for this cloud

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_locations method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.list_locations profile1
    R(RRRRRR(R t_simple_location(RR"R#R0R%R/((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR(�s
cK@s7td|�}t|j|�|�}|j||�S(u�
    Reboot a node in the cloud

    :param node_id: Unique ID of the node to reboot
    :type  node_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's reboot_node method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.reboot_node as-2346 profile1
    R(Rt
_get_by_idRtreboot_node(tnode_idRR"R#R&((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR5�scK@s7td|�}t|j|�|�}|j||�S(u�
    Destroy a node in the cloud

    :param node_id: Unique ID of the node to destroy
    :type  node_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's destroy_node method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.destry_node as-2346 profile1
    R(RR4Rtdestroy_node(R6RR"R#R&((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR7�scK@satd|�}tjjj|�}|j|�}g}x!|D]}|jt|��q@W|S(u[
    Return a list of storage volumes for this cloud

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_volumes method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.list_volumes profile1
    R(RRRRRtlist_volumesR t_simple_volume(RR"R#tvolumesR%tvolume((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR8�s
cK@sytd|�}tjjj|�}t|j�|�}|j||�}g}x!|D]}|jt	|��qXW|S(u�
    Return a list of storage volumes snapshots for this cloud

    :param volume_id: The volume identifier
    :type  volume_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_volume_snapshots method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.list_volume_snapshots vol1 profile1
    R(
RRRRRR4R8tlist_volume_snapshotsR t_simple_volume_snapshot(t	volume_idRR"R#R;t	snapshotsR%tsnapshot((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR<�s
cK@svtd|�}tjjj|�}|dk	rHt|j�|�}nd}|j|||dd|�}t	|�S(u�
    Create a storage volume

    :param size: Size of volume in gigabytes (required)
    :type size: ``int``

    :param name: Name of the volume to be created
    :type name: ``str``

    :param location_id: Which data center to create a volume in. If
                            empty, undefined behavior will be selected.
                            (optional)
    :type location_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_volumes method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.create_volume 1000 vol1 profile1
    RR@N(
RRRRRRR4R(t
create_volumeR9(R2tnameRR.R"R#R'R;((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRAscK@s[td|�}tjjj|�}t|j�|�}|j|d||�}t|�S(u<
    Create a storage volume snapshot

    :param volume_id:  Volume ID from which to create the new
                        snapshot.
    :type  volume_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param name: Name of the snapshot to be created (optional)
    :type name: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's create_volume_snapshot method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.create_volume_snapshot vol1 profile1
    RRB(	RRRRRR4R8tcreate_volume_snapshotR=(R>RRBR"R#R;R@((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRCDs
cK@sgtd|�}tjjj|�}t|j�|�}t|j�|�}|j||d||�S(u?
    Attaches volume to node.

    :param node_id:  Node ID to target
    :type  node_id: ``str``

    :param volume_id:  Volume ID from which to attach
    :type  volume_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param device: Where the device is exposed, e.g. '/dev/sdb'
    :type device: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's attach_volume method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.detach_volume vol1 profile1
    Rtdevice(	RRRRRR4R8Rt
attach_volume(R6R>RRDR"R#R;R&((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyREcs
cK@sItd|�}tjjj|�}t|j�|�}|j||�S(u�
    Detaches a volume from a node.

    :param volume_id:  Volume ID from which to detach
    :type  volume_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's detach_volume method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.detach_volume vol1 profile1
    R(RRRRRR4R8t
detach_volume(R>RR"R#R;((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRF�scK@sItd|�}tjjj|�}t|j�|�}|j||�S(u�
    Destroy a volume.

    :param volume_id:  Volume ID from which to destroy
    :type  volume_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's destroy_volume method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.destroy_volume vol1 profile1
    R(RRRRRR4R8tdestroy_volume(R>RR"R#R;((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRG�scK@satd|�}tjjj|�}t|j�|�}t|j|�|�}|j||�S(u%
    Destroy a volume snapshot.

    :param volume_id:  Volume ID from which the snapshot belongs
    :type  volume_id: ``str``

    :param snapshot_id:  Volume Snapshot ID from which to destroy
    :type  snapshot_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's destroy_volume_snapshot method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.destroy_volume_snapshot snap1 profile1
    R(	RRRRRR4R8R<tdestroy_volume_snapshot(R>tsnapshot_idRR"R#R;R@((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRH�s
cK@s�td|�}tjjj|�}|dk	rHt|j�|�}nd}|jd||�}g}x!|D]}|j	t
|��qpW|S(u�
    Return a list of images for this cloud

    :param profile: The profile key
    :type  profile: ``str``

    :param location_id: The location key, from list_locations
    :type  location_id: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_images method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.list_images profile1
    RR'N(RRRRRRR4R(tlist_imagesR t
_simple_image(RR.R"R#R'timagesR%timage((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRJ�s
cK@sXtd|�}tjjj|�}t|j�|�}t|j||d||��S(u�
    Create an image from a node

    :param node_id: Node to run the task on.
    :type node_id: ``str``

    :param name: name for new image.
    :type name: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param description: description for new image.
    :type description: ``description``

    :param libcloud_kwargs: Extra arguments for the driver's create_image method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.create_image server1 my_image profile1
        salt myminion libcloud_compute.create_image server1 my_image profile1 description='test image'
    Rtdescription(	RRRRRR4RRKtcreate_image(R6RBRRNR"R#R&((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRO�scK@sItd|�}tjjj|�}t|j�|�}|j||�S(u�
    Delete an image of a node

    :param image_id: Image to delete
    :type image_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's delete_image method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.delete_image image1 profile1
    R(RRRRRR4RJtdelete_image(timage_idRR"R#RM((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRPscK@s@td|�}tjjj|�}|j||�}t|�S(u�
    Get an image of a node

    :param image_id: Image to fetch
    :type image_id: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's delete_image method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.get_image image1 profile1
    R(RRRRRt	get_imageRK(RQRR"R#RM((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRR,sc	K@s^td|�}tjjj|�}|j||�}|j|||d||�}t|�S(u�
    Copies an image from a source region to the current region.

    :param source_region: Region to copy the node from.
    :type source_region: ``str``

    :param image_id: Image to copy.
    :type image_id: ``str``

    :param name: name for new image.
    :type name: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param description: description for new image.
    :type name: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's copy_image method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.copy_image us-east1 image1 'new image' profile1
    RRN(RRRRRRRt
copy_imageRK(	t
source_regionRQRBRRNR"R#RMt	new_image((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRSEscK@satd|�}tjjj|�}|j|�}g}x!|D]}|jt|��q@W|S(uX
    List all the available key pair objects.

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's list_key_pairs method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.list_key_pairs profile1
    R(RRRRRtlist_key_pairsR t_simple_key_pair(RR"R#tkeysR%tkey((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRVis
cK@s:td|�}tjjj|�}t|j||��S(u�
    Get a single key pair by name

    :param name: Name of the key pair to retrieve.
    :type name: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's get_key_pair method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.get_key_pair pair1 profile1
    R(RRRRRRWtget_key_pair(RBRR"R#((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRZ�scK@s:td|�}tjjj|�}t|j||��S(u�
    Create a single key pair by name

    :param name: Name of the key pair to create.
    :type name: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's create_key_pair method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.create_key_pair pair1 profile1
    R(RRRRRRWtcreate_key_pair(RBRR"R#((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR[�scK@sxtd|�}tjjj|�}tjj|�sB|dkr[t|j	|||��St|j
|||��SdS(uZ
    Import a new public key from string or a file path

    :param name: Key pair name.
    :type name: ``str``

    :param key: Public key material, the string or a path to a file
    :type  key: ``str`` or path ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param key_type: The key pair type, either `FILE` or `STRING`. Will detect if not provided
        and assume that if the string is a path to an existing path it is a FILE, else STRING.
    :type  key_type: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's import_key_pair_from_xxx method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.import_key_pair pair1 key_value_data123 profile1
        salt myminion libcloud_compute.import_key_pair pair1 /path/to/key profile1
    RuFILEN(RRRRRtostpathtexistsRWtimport_key_pair_from_filetimport_key_pair_from_string(RBRYRtkey_typeR"R#((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pytimport_key_pair�s
cK@sCtd|�}tjjj|�}|j|�}|j||�S(u�
    Delete a key pair

    :param name: Key pair name.
    :type  name: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's import_key_pair_from_xxx method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.delete_key_pair pair1 profile1
    R(RRRRRRZtdelete_key_pair(RBRR"R#RY((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRc�scK@s=tjjj|�}td|�}t||�}||�S(u�
    Call an extended method on the driver

    :param method: Driver's method name
    :type  method: ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.extra ex_get_permissions google container_name=my_container object_name=me.jpg --out=yaml
    R(RRRRRtgetattr(tmethodRR"R#tconnection_method((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pytextra�scC@s�g|D]}|j|kr|^q}t|�dkrItd��n0t|�dkrytdjt|����n|dS(u.
    Get item from a list by the id field
    iuCould not find a matching itemiuThe id matched {0} items, not 1(R)R*R+R(t
collectionR)titemtmatches((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR4s(cC@s6i|jd6|jd6|jd6|jd6|jd6S(Nuidunameusizeustateuextra(R)RBR2tstateRg(R;((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR9s



cC@s"i|jd6|jd6|jd6S(Nuidunameucountry(R)RBtcountry(R'((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR3"s

cC@sJi|jd6|jd6|jd6|jd6|jd6|jd6|jd6S(Nuidunameuramudisku	bandwidthupriceuextra(R)RBtramtdiskt	bandwidthtpriceRg(R2((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR-*s





cC@shi|jd6|jd6tj|j�d6|jd6|jd6|jrVt|j�nid6|j	d6S(Nuidunameustateu
public_ipsuprivate_ipsusizeuextra(
R)RBRt	text_typeRkt
public_ipstprivate_ipsR2R-Rg(R&((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR!6s



cC@sXi|jd6t|d�r%|jn|jd6|jd6|jd6|jd6|jd6S(Nuidunameusizeuextraucreatedustate(R)thasattrRBR2RgtcreatedRk(R@((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyR=Bs
"


cC@s"i|jd6|jd6|jd6S(Nuidunameuextra(R)RBRg(RM((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRKMs

cC@s6i|jd6|jd6|jd6|jd6|jd6S(Nunameufingerprintu
public_keyuprivate_keyuextra(RBtfingerprintt
public_keytprivate_keyRg(RY((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyRWUs



(Et__doc__t
__future__RRRtloggingtos.pathR\tsalt.utils.argsRtsalt.utils.compattsalt.utils.versionsRt
_LooseVersiontsalt.extRt	getLoggerRtlogR	tlibcloudtlibcloud.compute.providersRtlibcloud.compute.baseRRtt__version__tImportErrortsetLeveltCRITICALRRR
R
RRRRR,R(R5R7R8R<RARCRERFRGRHRJRORPRRRSRVRZR[RbRcRgR4R9R3R-R!R=RKRW(((sA/usr/lib/python2.7/site-packages/salt/modules/libcloud_compute.pyt<module>sl*


				%					' 			! 		$			'				
					

Zerion Mini Shell 1.0