File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/swift.cpython-310.pyc
o
�N�g# � @ sj d Z ddlZddlm m mZ e�e�Z dd� Z
ddd�Zddd�Zdd
d�Z
dd
� 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.
� Nc C s t �� S )zI
Only load this module if swift
is installed on this minion.
)�suosZcheck_swift� r r �F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/swift.py�__virtual__8 s r c C s� | r3t d | �}|d }|�dd�}|d }|d }|�dd�}|�d d�}|�d
d�}|�dd�} n2t d d�}t d dd�}t d d�}t d d�}t d dd�}t d d �}t d d
�}t d d�} |||||||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__�getr Z SaltSwift)�profileZcredentialsr r Ztenantr
r r Zapi_keyZos_auth_system�kwargsr r r �_auth@ s6 �
r c C s&