fixed quantum_ modules to work with minimum access rights if greater access rights are not needed

reviewable/pr18780/r1
Markus Suonto 9 years ago
parent b978f98715
commit 32edc2f56f

@ -164,18 +164,17 @@ def _get_neutron_client(module, kwargs):
def _set_tenant_id(module): def _set_tenant_id(module):
global _os_tenant_id global _os_tenant_id
if not module.params['tenant_name']: if not module.params['tenant_name']:
tenant_name = module.params['login_tenant_name'] _os_tenant_id = _os_keystone.tenant_id
else: else:
tenant_name = module.params['tenant_name'] tenant_name = module.params['tenant_name']
for tenant in _os_keystone.tenants.list(): for tenant in _os_keystone.tenants.list():
if tenant.name == tenant_name: if tenant.name == tenant_name:
_os_tenant_id = tenant.id _os_tenant_id = tenant.id
break break
if not _os_tenant_id: if not _os_tenant_id:
module.fail_json(msg = "The tenant id cannot be found, please check the parameters") module.fail_json(msg = "The tenant id cannot be found, please check the parameters")
def _get_net_id(neutron, module): def _get_net_id(neutron, module):
kwargs = { kwargs = {
'tenant_id': _os_tenant_id, 'tenant_id': _os_tenant_id,

@ -136,17 +136,16 @@ def _get_neutron_client(module, kwargs):
def _set_tenant_id(module): def _set_tenant_id(module):
global _os_tenant_id global _os_tenant_id
if not module.params['tenant_name']: if not module.params['tenant_name']:
login_tenant_name = module.params['login_tenant_name'] _os_tenant_id = _os_keystone.tenant_id
else: else:
login_tenant_name = module.params['tenant_name'] tenant_name = module.params['tenant_name']
for tenant in _os_keystone.tenants.list(): for tenant in _os_keystone.tenants.list():
if tenant.name == login_tenant_name: if tenant.name == tenant_name:
_os_tenant_id = tenant.id _os_tenant_id = tenant.id
break break
if not _os_tenant_id: if not _os_tenant_id:
module.fail_json(msg = "The tenant id cannot be found, please check the parameters") module.fail_json(msg = "The tenant id cannot be found, please check the parameters")
def _get_router_id(module, neutron): def _get_router_id(module, neutron):
kwargs = { kwargs = {

@ -138,18 +138,17 @@ def _get_neutron_client(module, kwargs):
def _set_tenant_id(module): def _set_tenant_id(module):
global _os_tenant_id global _os_tenant_id
if not module.params['tenant_name']: if not module.params['tenant_name']:
login_tenant_name = module.params['login_tenant_name'] _os_tenant_id = _os_keystone.tenant_id
else: else:
login_tenant_name = module.params['tenant_name'] tenant_name = module.params['tenant_name']
for tenant in _os_keystone.tenants.list(): for tenant in _os_keystone.tenants.list():
if tenant.name == login_tenant_name: if tenant.name == tenant_name:
_os_tenant_id = tenant.id _os_tenant_id = tenant.id
break break
if not _os_tenant_id: if not _os_tenant_id:
module.fail_json(msg = "The tenant id cannot be found, please check the parameters") module.fail_json(msg = "The tenant id cannot be found, please check the parameters")
def _get_router_id(module, neutron): def _get_router_id(module, neutron):
kwargs = { kwargs = {
'name': module.params['router_name'], 'name': module.params['router_name'],

@ -170,16 +170,16 @@ def _get_neutron_client(module, kwargs):
def _set_tenant_id(module): def _set_tenant_id(module):
global _os_tenant_id global _os_tenant_id
if not module.params['tenant_name']: if not module.params['tenant_name']:
tenant_name = module.params['login_tenant_name'] _os_tenant_id = _os_keystone.tenant_id
else: else:
tenant_name = module.params['tenant_name'] tenant_name = module.params['tenant_name']
for tenant in _os_keystone.tenants.list(): for tenant in _os_keystone.tenants.list():
if tenant.name == tenant_name: if tenant.name == tenant_name:
_os_tenant_id = tenant.id _os_tenant_id = tenant.id
break break
if not _os_tenant_id: if not _os_tenant_id:
module.fail_json(msg = "The tenant id cannot be found, please check the parameters") module.fail_json(msg = "The tenant id cannot be found, please check the parameters")
def _get_net_id(neutron, module): def _get_net_id(neutron, module):
kwargs = { kwargs = {

Loading…
Cancel
Save