diff options
Diffstat (limited to 'snaps/openstack/utils/neutron_utils.py')
-rw-r--r-- | snaps/openstack/utils/neutron_utils.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/snaps/openstack/utils/neutron_utils.py b/snaps/openstack/utils/neutron_utils.py index 061bc56..2de3586 100644 --- a/snaps/openstack/utils/neutron_utils.py +++ b/snaps/openstack/utils/neutron_utils.py @@ -347,7 +347,7 @@ def delete_security_group(neutron, sec_grp): neutron.delete_security_group(sec_grp.id) -def get_security_group(neutron, name): +def get_security_group(neutron, name, tenant_id=None): """ Returns the first security group object of the given name else None :param neutron: the client @@ -356,7 +356,10 @@ def get_security_group(neutron, name): """ logger.info('Retrieving security group with name - ' + name) - groups = neutron.list_security_groups(**{'name': name}) + filter = {'name': name} + if tenant_id: + filter['tenant_id'] = tenant_id + groups = neutron.list_security_groups(**filter) for group in groups['security_groups']: if group['name'] == name: return SecurityGroup(**group) |