HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/swift.cpython-310.pyc
o

�N�g#�@sjdZddlZddlmmmZe�e�Z	dd�Z
ddd�Zddd�Zdd
d�Z
dd
�Zddd�ZdS)a(
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.
�NcCst��S)zI
    Only load this module if swift
    is installed on this minion.
    )�suosZcheck_swift�rr�F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/swift.py�__virtual__8srcCs�|r3td|�}|d}|�dd�}|d}|d}|�dd�}|�d	d�}|�d
d�}|�dd�}	n2tdd�}tddd�}tdd�}tdd�}tddd�}tdd	�}tdd
�}tdd�}	|||||||d�}
tjd
i|
��S)z&
    Set up openstack credentials
    z
config.optionz
keystone.userzkeystone.passwordNzkeystone.tenantzkeystone.auth_urlzkeystone.auth_version�zkeystone.region_namezkeystone.api_keyzkeystone.os_auth_system)�user�password�keyZtenant_name�auth_url�auth_version�region_namer)Z__salt__�getrZ	SaltSwift)�profileZcredentialsrrZtenantr
rrZapi_keyZos_auth_system�kwargsrrr�_auth@s6�
rcCs&t|�}|dur
|�|�S|�||�S)a
    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)rZdelete_containerZ
delete_object)�cont�pathr�
swift_connrrr�deleteds
rFcCsZt|�}|dur|��S|dur|�|�S|dur |�|||�S|dur+|�|||�SdS)a
    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

    NTF)rZget_accountZ
get_containerZ
get_object)rr�
local_fileZ
return_binrrrrrr
xs
r
cCsdS�Nrrrrr�head�srcCs4t|�}|dur
|�|�S|dur|�|||�SdS)aT
    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
    NF)rZ
put_containerZ
put_object)rrrrrrrr�put�s
rr)NN)NNNFN)NNN)�__doc__�loggingZsalt.utils.openstack.swift�utilsZ	openstackZswiftr�	getLogger�__name__�logrrrr
rrrrrr�<module>s/


$
0