Add listing security groups functionality
[snaps.git] / snaps / openstack / utils / neutron_utils.py
index 0d69fc8..3daf1f7 100644 (file)
@@ -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):
     """