%PDF- %PDF-
| Direktori : /proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/salt/states/ |
| Current File : //proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/salt/states/libcloud_storage.pyc |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z e j e � Z
d � Z d � Z d � Z
d � Z d � Z d � Z d
� Z e d � Z d S( u2
Apache Libcloud Storage State
=============================
Manage cloud storage using libcloud
:codeauthor: ``Anthony Shaw <anthonyshaw@apache.org>``
Apache Libcloud Storage (object/blob) management for a full list
of supported clouds, see http://libcloud.readthedocs.io/en/latest/storage/supported_providers.html
Clouds include Amazon S3, Google Storage, Aliyun, Azure Blobs, Ceph, OpenStack swift
.. versionadded:: 2018.3.0
:configuration:
This module uses a configuration profile for one or multiple Storage providers
.. code-block:: yaml
libcloud_storage:
profile_test1:
driver: google_storage
key: GOOG0123456789ABCXYZ
secret: mysecret
profile_test2:
driver: s3
key: 12345
secret: mysecret
Examples
--------
Creating a container and uploading a file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: yaml
web_things:
libcloud_storage.container_present:
name: my_container_name
profile: profile1
libcloud_storage.object_present:
name: my_file.jpg
container: my_container_name
path: /path/to/local/file.jpg
profile: profile1
Downloading a file
~~~~~~~~~~~~~~~~~~
This example will download the file from the remote cloud and keep it locally
.. code-block:: yaml
web_things:
libcloud_storage.file_present:
name: my_file.jpg
container: my_container_name
path: /path/to/local/file.jpg
profile: profile1
:depends: apache-libcloud
i ( t absolute_importt unicode_literalst print_functionNc C@ s t S( N( t True( ( ( s@ /usr/lib/python2.7/site-packages/salt/states/libcloud_storage.pyt __virtual__M s c C@ s t j j j t � d S( N( t saltt utilst compatt pack_dundert __name__( t opts( ( s@ /usr/lib/python2.7/site-packages/salt/states/libcloud_storage.pyt __init__Q s c C@ s i | d 6| d 6| d 6| d 6S( Nu resultu commentu nameu changes( ( t resultt messaget namet changes( ( s@ /usr/lib/python2.7/site-packages/salt/states/libcloud_storage.pyt state_resultU s
c C@ s� t d | � } g | D] } | d | k r | ^ q } t | � d k r^ t t d | i � St d | | � } t t d | | � Sd S( u�
Ensures a container is present.
:param name: Container name
:type name: ``str``
:param profile: The profile key
:type profile: ``str``
u libcloud_storage.list_containersu namei u Container already existsu! libcloud_storage.create_containeru Created new containerN( t __salt__t lenR R ( R t profilet
containerst zt matchR ( ( s@ /usr/lib/python2.7/site-packages/salt/states/libcloud_storage.pyt container_present\ s
)c C@ s� t d | � } g | D] } | d | k r | ^ q } t | � d k r^ t t d | i � St d | | � } t | d | i � Sd S( u�
Ensures a container is absent.
:param name: Container name
:type name: ``str``
:param profile: The profile key
:type profile: ``str``
u libcloud_storage.list_containersu namei u Container already absentu! libcloud_storage.delete_containeru Deleted containerN( R R R R ( R R R R R R ( ( s@ /usr/lib/python2.7/site-packages/salt/states/libcloud_storage.pyt container_absento s
)c C@ se t d | | | � } | d k r5 t t d | i � St d | | | | � } t | d | i � Sd S( u(
Ensures a object is presnt.
:param container: Container name
:type container: ``str``
:param name: Object name in cloud
:type name: ``str``
:param path: Local path to file
:type path: ``str``
:param profile: The profile key
:type profile: ``str``
u% libcloud_storage.get_container_objectu Object already presentu libcloud_storage.upload_objectu Uploaded objectN( R t NoneR R ( t containerR t pathR t existing_objectR ( ( s@ /usr/lib/python2.7/site-packages/salt/states/libcloud_storage.pyt object_present� s
c C@ sb t d | | | � } | d k r5 t t d | i � St d | | | � } t | d | i � Sd S( u�
Ensures a object is absent.
:param container: Container name
:type container: ``str``
:param name: Object name in cloud
:type name: ``str``
:param profile: The profile key
:type profile: ``str``
u% libcloud_storage.get_container_objectu Object already absentu libcloud_storage.delete_objectu Deleted objectN( R R R R ( R R R R R ( ( s@ /usr/lib/python2.7/site-packages/salt/states/libcloud_storage.pyt
object_absent� s
c C@ s/ t d | | | | | � } t | d | i � S( u�
Ensures a object is downloaded locally.
:param container: Container name
:type container: ``str``
:param name: Object name in cloud
:type name: ``str``
:param path: Local path to file
:type path: ``str``
:param profile: The profile key
:type profile: ``str``
:param overwrite_existing: Replace if already exists
:type overwrite_existing: ``bool``
u libcloud_storage.download_objectu Downloaded object( R R ( R R R R t overwrite_existingR ( ( s@ /usr/lib/python2.7/site-packages/salt/states/libcloud_storage.pyt file_present� s ( t __doc__t
__future__R R R t loggingt salt.utils.compatR t getLoggerR t logR R R R R R R t FalseR ( ( ( s@ /usr/lib/python2.7/site-packages/salt/states/libcloud_storage.pyt <module>A s