From dc76020bee7085a3e2e9d1bd94e4ad7904d3b77d Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Mon, 16 Apr 2018 10:24:34 +0200 Subject: Add listing security groups functionality JIRA: SNAPS-302 Be able to list the available security groups Change-Id: I82e2daeb388f4eb3bc8cbc5fd02006b30b959c2f Signed-off-by: Manuel Buil --- snaps/openstack/utils/neutron_utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'snaps/openstack/utils/neutron_utils.py') diff --git a/snaps/openstack/utils/neutron_utils.py b/snaps/openstack/utils/neutron_utils.py index 0d69fc8..3daf1f7 100644 --- a/snaps/openstack/utils/neutron_utils.py +++ b/snaps/openstack/utils/neutron_utils.py @@ -681,6 +681,21 @@ def get_security_group_by_id(neutron, sec_grp_id): return None +def list_security_groups(neutron): + + """ + Lists the available security groups + :param neutron: the neutron client + """ + logger.info('Listing the available security groups') + sec_groups = [] + response = neutron.list_security_groups() + for sg in response['security_groups']: + sec_groups.append(__map_os_security_group(neutron, sg)) + + return sec_groups + + def create_security_group_rule(neutron, keystone, sec_grp_rule_settings, proj_name): """ -- cgit 1.2.3-korg