summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorin Hochstein <lorinh@gmail.com>2015-02-16 18:05:12 -0500
committerLorin Hochstein <lorinh@gmail.com>2015-02-16 18:05:12 -0500
commit451dcdeadfd35615a867d5e59a684e4aa82959ae (patch)
tree9281ddf0e60aae433a5fcca964f15e8e537b7db1
parente4005b63f9b27d3e8b99c7b878826ce0f971cdef (diff)
parent9abb9e33575b438890e4e60477c58728cd6c1d36 (diff)
downloadopenstack-ansible-modules-451dcdeadfd35615a867d5e59a684e4aa82959ae.tar.gz
Merge pull request #35 from nihilifer/bugfix/admin_context
Getting tenant id from Keystone client when tenant not provided
-rw-r--r--neutron_sec_group11
1 files changed, 6 insertions, 5 deletions
diff --git a/neutron_sec_group b/neutron_sec_group
index 0d955fd..518c50e 100644
--- a/neutron_sec_group
+++ b/neutron_sec_group
@@ -313,19 +313,20 @@ def _create_sg_rules(network_client, sg, rules):
def _get_tenant_id(module, identity_client):
"""
Returns the tenant_id, given tenant_name.
- if tenant_name is not specified in the module params uses login_tenant_name
+ if tenant_name is not specified in the module params uses tenant_id
+ from Keystone session
:param identity_client: identity_client used to get the tenant_id from its
name.
:param module_params: module parameters.
"""
if not module.params['tenant_name']:
- tenant_name = module.params['login_tenant_name']
+ tenant_id = identity_client.tenant_id
else:
tenant_name = module.params['tenant_name']
+ tenant = _get_tenant(identity_client, tenant_name)
+ tenant_id = tenant.id
- tenant = _get_tenant(identity_client, tenant_name)
-
- return tenant.id
+ return tenant_id
def _get_tenant(identity_client, tenant_name):