summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Guerri <davide.guerri@gmail.com>2015-04-21 14:51:51 +0100
committerDavide Guerri <davide.guerri@gmail.com>2015-04-21 14:51:51 +0100
commit0c1e4c009c19fbdf02db2c32a353157fa287ab61 (patch)
treec71d0d9a0312b684c016bef14a9e56edabae6f5f
parent6edf76c7ba51a5a5d2428a44881cc66f6732fe45 (diff)
downloadopenstack-ansible-modules-0c1e4c009c19fbdf02db2c32a353157fa287ab61.tar.gz
Allow non-admin users to create router and router interfaces
-rw-r--r--neutron_router20
-rw-r--r--neutron_router_interface17
2 files changed, 21 insertions, 16 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 = {
diff --git a/neutron_router_interface b/neutron_router_interface
index 8d57725..1d6648a 100644
--- a/neutron_router_interface
+++ b/neutron_router_interface
@@ -127,15 +127,18 @@ 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")