summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDustin Lundquist <dustin@null-ptr.net>2014-11-06 21:13:21 -0800
committerDustin Lundquist <dustin@null-ptr.net>2014-11-06 21:13:21 -0800
commit5d713727f269e111598604af8e6579ebb81104ba (patch)
tree0b980e2b6110c1fbab4ebde4df8ecb6924290d98
parentf29017d385bedebd179525ac11edc7201dc39278 (diff)
downloadopenstack-ansible-modules-5d713727f269e111598604af8e6579ebb81104ba.tar.gz
Fix keystone_service user/pass authentication
keystone_service included an incomplete username and password authentication path. Since the keystone client was initialized with endpoint rather than auth_url it didn't obtain a token and did not have permissions to preform operations. Additionally some operations required the client to authenticate with a tenant_name as well.
-rw-r--r--keystone_service21
1 files changed, 14 insertions, 7 deletions
diff --git a/keystone_service b/keystone_service
index 9b1cc58..aa4302d 100644
--- a/keystone_service
+++ b/keystone_service
@@ -85,14 +85,16 @@ else:
import traceback
-def authenticate(endpoint, token, login_user, login_password, insecure):
+def authenticate(endpoint, token, login_user, login_password, tenant_name,
+ insecure):
"""Return a keystone client object"""
if token:
return client.Client(endpoint=endpoint, token=token, insecure=insecure)
else:
- return client.Client(endpoint=endpoint, username=login_user,
- password=login_password, insecure=insecure)
+ return client.Client(auth_url=endpoint, username=login_user,
+ password=login_password, tenant_name=tenant_name,
+ insecure=insecure)
def get_service(keystone, name):
""" Retrieve a service by name """
@@ -248,22 +250,26 @@ def main():
region=dict(required=True),
state=dict(default='present', choices=['present', 'absent']),
endpoint=dict(required=False,
- default="http://127.0.0.1:35357/v2.0"),
+ default="http://127.0.0.1:35357/v2.0",
+ aliases=['auth_url']),
token=dict(required=False),
insecure=dict(required=False, default=False, choices=BOOLEANS),
login_user=dict(required=False),
- login_password=dict(required=False)
+ login_password=dict(required=False),
+ tenant_name=dict(required=False, aliases=['tenant'])
),
supports_check_mode=True,
mutually_exclusive=[['token', 'login_user'],
- ['token', 'login_password']]
+ ['token', 'login_password'],
+ ['token', 'tenant_name']]
)
endpoint = module.params['endpoint']
token = module.params['token']
login_user = module.params['login_user']
login_password = module.params['login_password']
+ tenant_name = module.params['tenant_name']
insecure = module.boolean(module.params['insecure'])
name = module.params['name']
service_type = module.params['type']
@@ -278,7 +284,8 @@ def main():
region = module.params['region']
state = module.params['state']
- keystone = authenticate(endpoint, token, login_user, login_password, insecure)
+ keystone = authenticate(endpoint, token, login_user, login_password,
+ tenant_name, insecure)
check_mode = module.check_mode
try: