Restore the syntax -U tenant:user

On a relatively recent build of swift, all my scripts blew up with
"No tenant specified". It was caused by the fix to add --os_tenant_name,
commit ID:  208b8e85a8

This patch restores the old behavior. I tested it to work with old
swauth-based Swift, new Keystone-based Swift, in the latter case using
both -U and --os_tenant_name arguments.

Note that this patch permits to use a literal colon in the user name
with the new syntax, as long as tenant is specified. Empty tenant
names are not allowed with either syntax.

Change-Id: I7785e6981a9d6281d0421c43875ee19d61d5ff43
Bug: 982909
This commit is contained in:
Pete Zaitcev 2012-04-26 10:58:07 -06:00
parent 92312f5631
commit 6b91352007
1 changed files with 4 additions and 2 deletions

View File

@ -199,6 +199,10 @@ def _get_auth_v1_0(url, user, key, snet):
def _get_auth_v2_0(url, user, tenant_name, key, snet):
if not tenant_name and ':' in user:
tenant_name, user = user.split(':', 1)
if not tenant_name:
raise ClientException('No tenant specified')
body = {'auth': {'passwordCredentials':
{'password': key, 'username': user},
'tenantName': tenant_name}}
@ -250,8 +254,6 @@ def get_auth(url, user, key, snet=False, tenant_name=None, auth_version="1.0"):
if auth_version in ["1.0", "1"]:
return _get_auth_v1_0(url, user, key, snet)
elif auth_version in ["2.0", "2"]:
if not tenant_name:
raise ClientException('No tenant specified')
return _get_auth_v2_0(url, user, tenant_name, key, snet)