Rackspace support for switft module.

Allow setting auth_version, also don't make `password` a required field, can also use api_key.
Pass api_key in kwargs as `key`, that's what's expected in the utils module.
Also update notes with those details and a recommendation for using version 1 auth.
This commit is contained in:
Ethan Erchinger 2015-10-16 18:19:49 +00:00 committed by rallytime
parent fd2ca2df1b
commit fab1ad39af

View file

@ -6,14 +6,17 @@ 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, password, tenant, and
auth URL are specified either in a pillar or in the minion's config file.
: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.password: verybadpass
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:
@ -21,21 +24,27 @@ Inspired by the S3 and Nova modules
openstack1:
keystone.user: admin
keystone.password: verybadpass
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.password: verybadpass
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.
'''
from __future__ import absolute_import
@ -67,9 +76,10 @@ def _auth(profile=None):
if profile:
credentials = __salt__['config.option'](profile)
user = credentials['keystone.user']
password = credentials['keystone.password']
password = credentials.get('keystone.password', None)
tenant = credentials['keystone.tenant']
auth_url = credentials['keystone.auth_url']
auth_version = credentials['keystone.auth_version']
region_name = credentials.get('keystone.region_name', None)
api_key = credentials.get('keystone.api_key', None)
os_auth_system = credentials.get('keystone.os_auth_system', None)
@ -78,15 +88,17 @@ def _auth(profile=None):
password = __salt__['config.option']('keystone.password')
tenant = __salt__['config.option']('keystone.tenant')
auth_url = __salt__['config.option']('keystone.auth_url')
auth_version = __salt__['config.option']('keystone.auth_version')
region_name = __salt__['config.option']('keystone.region_name')
api_key = __salt__['config.option']('keystone.api_key')
os_auth_system = __salt__['config.option']('keystone.os_auth_system')
kwargs = {
'user': user,
'password': password,
'api_key': api_key,
'key': api_key,
'tenant_name': tenant,
'auth_url': auth_url,
'auth_version': auth_version,
'region_name': region_name
}