%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/swift.pyo

�
���^c@@s�dZddlmZmZmZddlZddljjj	Z
eje�Z
d�ZiZdd�Zddd�Zdddedd�Zd�Zdddd	�ZdS(
u(
Module for handling OpenStack Swift calls
Author: Anthony Stanton <anthony.stanton@gmail.com>

Inspired by the S3 and Nova modules

:depends:   - swiftclient Python module
:configuration: This module is not usable until the user, tenant, auth URL, and password or auth_key
    are specified either in a pillar or in the minion's config file.
    For example::

        keystone.user: admin
        keystone.tenant: admin
        keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
        keystone.password: verybadpass
        # or
        keystone.auth_key: 203802934809284k2j34lkj2l3kj43k

    If configuration for multiple OpenStack accounts is required, they can be
    set up as different configuration profiles:
    For example::

        openstack1:
          keystone.user: admin
          keystone.tenant: admin
          keystone.auth_url: 'http://127.0.0.1:5000/v2.0/'
          keystone.password: verybadpass
          # or
          keystone.auth_key: 203802934809284k2j34lkj2l3kj43k

        openstack2:
          keystone.user: admin
          keystone.tenant: admin
          keystone.auth_url: 'http://127.0.0.2:5000/v2.0/'
          keystone.password: verybadpass
          # or
          keystone.auth_key: 303802934809284k2j34lkj2l3kj43k

    With this configuration in place, any of the swift functions can make use of
    a configuration profile by declaring it explicitly.
    For example::

        salt '*' swift.get mycontainer myfile /tmp/file profile=openstack1

    NOTE: For Rackspace cloud files setting keystone.auth_version = 1 is recommended.
i(tabsolute_importtunicode_literalstprint_functionNcC@s
tj�S(uI
    Only load this module if swift
    is installed on this minion.
    (tsuostcheck_swift(((s6/usr/lib/python2.7/site-packages/salt/modules/swift.pyt__virtual__<scC@s[|r�td|�}|d}|jdd�}|d}|d}|jdd�}|jdd�}|jd	d�}|jd
d�}	n�tdd�}tddd�}tdd�}tdd�}tddd�}tdd�}tdd	�}tdd
�}	i|d6|d6|d
6|d6|d6|d6|d6}
tj|
�S(u&
    Set up openstack credentials
    u
config.optionu
keystone.userukeystone.passwordukeystone.tenantukeystone.auth_urlukeystone.auth_versioniukeystone.region_nameukeystone.api_keyukeystone.os_auth_systemuuserupasswordukeyutenant_nameuauth_urluauth_versionuregion_nameN(t__salt__tgettNoneRt	SaltSwift(tprofiletcredentialstusertpasswordttenanttauth_urltauth_versiontregion_nametapi_keytos_auth_systemtkwargs((s6/usr/lib/python2.7/site-packages/salt/modules/swift.pyt_authGs6



cC@s9t|�}|dkr%|j|�S|j||�SdS(u
    Delete a container, or delete an object from a container.

    CLI Example to delete a container::

        salt myminion swift.delete mycontainer

    CLI Example to delete an object from a container::

        salt myminion swift.delete mycontainer remoteobject
    N(RRtdelete_containert
delete_object(tconttpathR
t
swift_conn((s6/usr/lib/python2.7/site-packages/salt/modules/swift.pytdeleteks
cC@s}t|�}|dkr"|j�S|dkr;|j|�S|tkrZ|j|||�S|dk	ry|j|||�StS(u
    List the contents of a container, or return an object from a container. Set
    return_bin to True in order to retrieve an object wholesale. Otherwise,
    Salt will attempt to parse an XML response.

    CLI Example to list containers:

    .. code-block:: bash

        salt myminion swift.get

    CLI Example to list the contents of a container:

    .. code-block:: bash

        salt myminion swift.get mycontainer

    CLI Example to return the binary contents of an object:

    .. code-block:: bash

        salt myminion swift.get mycontainer myfile.png return_bin=True

    CLI Example to save the binary contents of an object to a local file:

    .. code-block:: bash

        salt myminion swift.get mycontainer myfile.png local_file=/tmp/myfile.png

    N(RRtget_accountt
get_containertTruet
get_objecttFalse(RRt
local_filet
return_binR
R((s6/usr/lib/python2.7/site-packages/salt/modules/swift.pyRs

cC@sdS(N((((s6/usr/lib/python2.7/site-packages/salt/modules/swift.pythead�scC@sLt|�}|dkr%|j|�S|dk	rD|j|||�StSdS(uT
    Create a new container, or upload an object to a container.

    CLI Example to create a container:

    .. code-block:: bash

        salt myminion swift.put mycontainer

    CLI Example to upload an object to a container:

    .. code-block:: bash

        salt myminion swift.put mycontainer remotepath local_file=/path/to/file
    N(RRt
put_containert
put_objectR (RRR!R
R((s6/usr/lib/python2.7/site-packages/salt/modules/swift.pytput�s
(t__doc__t
__future__RRRtloggingtsalt.utils.openstack.swifttutilst	openstacktswiftRt	getLoggert__name__tlogRt__opts__RRRR RR#R&(((s6/usr/lib/python2.7/site-packages/salt/modules/swift.pyt<module>/s	$0	

Zerion Mini Shell 1.0