diff options
Diffstat (limited to 'neutron_router')
-rw-r--r-- | neutron_router | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/neutron_router b/neutron_router index 56d384d..a724c45 100644 --- a/neutron_router +++ b/neutron_router @@ -126,18 +126,20 @@ def _get_neutron_client(module, kwargs): def _set_tenant_id(module): global _os_tenant_id - if not module.params['tenant_name']: - login_tenant_name = module.params['login_tenant_name'] + if module.params['tenant_name']: + # We need admin power in order retrieve the tenant_id of a given + # tenant name and to create/delete networks for a tenant that is not + # the one used to authenticate the user. + tenant_name = module.params['tenant_name'] + for tenant in _os_keystone.tenants.list(): + if tenant.name == tenant_name: + _os_tenant_id = tenant.id + break else: - login_tenant_name = module.params['tenant_name'] + _os_tenant_id = _os_keystone.tenant_id - for tenant in _os_keystone.tenants.list(): - if tenant.name == login_tenant_name: - _os_tenant_id = tenant.id - break if not _os_tenant_id: - module.fail_json(msg = "The tenant id cannot be found, please check the paramters") - + module.fail_json(msg = "The tenant id cannot be found, please check the paramters") def _get_router_id(module, neutron): kwargs = { |