Merge "Bulk creation of SecurityGroups"
diff --git a/neutron/tests/tempest/api/test_security_groups.py b/neutron/tests/tempest/api/test_security_groups.py
index a6009e4..4520ecc 100644
--- a/neutron/tests/tempest/api/test_security_groups.py
+++ b/neutron/tests/tempest/api/test_security_groups.py
@@ -53,3 +53,17 @@
         self.assertEqual(show_body['security_group']['name'], new_name)
         self.assertEqual(show_body['security_group']['description'],
                          new_description)
+
+    @test.idempotent_id('7c0ecb10-b2db-11e6-9b14-000c29248b0d')
+    def test_create_bulk_sec_groups(self):
+        # Creates 2 sec-groups in one request
+        sec_nm = [data_utils.rand_name('secgroup'),
+                  data_utils.rand_name('secgroup')]
+        body = self.client.create_bulk_security_groups(sec_nm)
+        created_sec_grps = body['security_groups']
+        self.assertEqual(2, len(created_sec_grps))
+        for secgrp in created_sec_grps:
+            self.addCleanup(self.client.delete_security_group,
+                            secgrp['id'])
+            self.assertIn(secgrp['name'], sec_nm)
+            self.assertIsNotNone(secgrp['id'])
diff --git a/neutron/tests/tempest/services/network/json/network_client.py b/neutron/tests/tempest/services/network/json/network_client.py
index 6b71f02..610b049 100644
--- a/neutron/tests/tempest/services/network/json/network_client.py
+++ b/neutron/tests/tempest/services/network/json/network_client.py
@@ -251,6 +251,18 @@
         self.expected_success(201, resp.status)
         return service_client.ResponseBody(resp, body)
 
+    def create_bulk_security_groups(self, security_group_list):
+        group_list = [{'security_group': {'name': name}}
+                      for name in security_group_list]
+        post_data = {'security_groups': group_list}
+        body = self.serialize_list(post_data, 'security_groups',
+                                   'security_group')
+        uri = self.get_uri("security-groups")
+        resp, body = self.post(uri, body)
+        body = {'security_groups': self.deserialize_list(body)}
+        self.expected_success(201, resp.status)
+        return service_client.ResponseBody(resp, body)
+
     def wait_for_resource_deletion(self, resource_type, id):
         """Waits for a resource to be deleted."""
         start_time = int(time.time())