Merge "Make security_groups_client use **kwargs"
diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py
index 33313be..9acf23b 100644
--- a/tempest/api/compute/admin/test_quotas_negative.py
+++ b/tempest/api/compute/admin/test_quotas_negative.py
@@ -129,7 +129,7 @@
         # will be raised when out of quota
         self.assertRaises((lib_exc.Forbidden, lib_exc.OverLimit),
                           self.sg_client.create_security_group,
-                          "sg-overlimit", "sg-desc")
+                          name="sg-overlimit", description="sg-desc")
 
     @decorators.skip_because(bug="1186354",
                              condition=CONF.service_available.neutron)
@@ -157,7 +157,8 @@
         s_name = data_utils.rand_name('securitygroup')
         s_description = data_utils.rand_name('description')
         securitygroup =\
-            self.sg_client.create_security_group(s_name, s_description)
+            self.sg_client.create_security_group(name=s_name,
+                                                 description=s_description)
         self.addCleanup(self.sg_client.delete_security_group,
                         securitygroup['id'])
 
diff --git a/tempest/api/compute/admin/test_security_groups.py b/tempest/api/compute/admin/test_security_groups.py
index ff87a4f..b2a1b98 100644
--- a/tempest/api/compute/admin/test_security_groups.py
+++ b/tempest/api/compute/admin/test_security_groups.py
@@ -51,7 +51,8 @@
             name = data_utils.rand_name('securitygroup')
             description = data_utils.rand_name('description')
             securitygroup = (self.client
-                             .create_security_group(name, description))
+                             .create_security_group(name=name,
+                                                    description=description))
             self.addCleanup(self._delete_security_group,
                             securitygroup['id'], admin=False)
             security_group_list.append(securitygroup)
@@ -61,9 +62,8 @@
         for i in range(2):
             name = data_utils.rand_name('securitygroup')
             description = data_utils.rand_name('description')
-            adm_securitygroup = (self.adm_client
-                                 .create_security_group(name,
-                                                        description))
+            adm_securitygroup = self.adm_client.create_security_group(
+                name=name, description=description)
             self.addCleanup(self._delete_security_group,
                             adm_securitygroup['id'])
             security_group_list.append(adm_securitygroup)
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 33442b2..2126787 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -222,8 +222,8 @@
         if description is None:
             description = data_utils.rand_name('description')
         body = \
-            cls.security_groups_client.create_security_group(name,
-                                                             description)
+            cls.security_groups_client.create_security_group(
+                name=name, description=description)
         cls.security_groups.append(body)
 
         return body
diff --git a/tempest/api/compute/security_groups/test_security_groups_negative.py b/tempest/api/compute/security_groups/test_security_groups_negative.py
index d8cbe3d..642aca1 100644
--- a/tempest/api/compute/security_groups/test_security_groups_negative.py
+++ b/tempest/api/compute/security_groups/test_security_groups_negative.py
@@ -72,16 +72,17 @@
         s_description = data_utils.rand_name('description')
         # Create Security Group with empty string as group name
         self.assertRaises(lib_exc.BadRequest,
-                          self.client.create_security_group, "", s_description)
+                          self.client.create_security_group,
+                          name="", description=s_description)
         # Create Security Group with white space in group name
         self.assertRaises(lib_exc.BadRequest,
-                          self.client.create_security_group, " ",
-                          s_description)
+                          self.client.create_security_group,
+                          name=" ", description=s_description)
         # Create Security Group with group name longer than 255 chars
         s_name = 'securitygroup-'.ljust(260, '0')
         self.assertRaises(lib_exc.BadRequest,
-                          self.client.create_security_group, s_name,
-                          s_description)
+                          self.client.create_security_group,
+                          name=s_name, description=s_description)
 
     @decorators.skip_because(bug="1161411",
                              condition=CONF.service_available.neutron)
@@ -96,8 +97,8 @@
         # Create Security Group with group description longer than 255 chars
         s_description = 'description-'.ljust(260, '0')
         self.assertRaises(lib_exc.BadRequest,
-                          self.client.create_security_group, s_name,
-                          s_description)
+                          self.client.create_security_group,
+                          name=s_name, description=s_description)
 
     @test.idempotent_id('9fdb4abc-6b66-4b27-b89c-eb215a956168')
     @testtools.skipIf(CONF.service_available.neutron,
@@ -109,11 +110,11 @@
         # be created
         s_name = data_utils.rand_name('securitygroup')
         s_description = data_utils.rand_name('description')
-        self.create_security_group(s_name, s_description)
+        self.create_security_group(name=s_name, description=s_description)
         # Now try the Security Group with the same 'Name'
         self.assertRaises(lib_exc.BadRequest,
-                          self.client.create_security_group, s_name,
-                          s_description)
+                          self.client.create_security_group,
+                          name=s_name, description=s_description)
 
     @test.attr(type=['negative'])
     @test.idempotent_id('36a1629f-c6da-4a26-b8b8-55e7e5d5cd58')
diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py
index 98a2f9d..7e09096 100644
--- a/tempest/api/compute/servers/test_server_rescue.py
+++ b/tempest/api/compute/servers/test_server_rescue.py
@@ -48,9 +48,8 @@
         # Security group creation
         cls.sg_name = data_utils.rand_name('sg')
         cls.sg_desc = data_utils.rand_name('sg-desc')
-        cls.sg = \
-            cls.security_groups_client.create_security_group(cls.sg_name,
-                                                             cls.sg_desc)
+        cls.sg = cls.security_groups_client.create_security_group(
+            name=cls.sg_name, description=cls.sg_desc)
         cls.sg_id = cls.sg['id']
 
         # Server for positive tests
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index 7e2868e..1d7f7fa 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -83,7 +83,7 @@
         name = data_utils.rand_name('security')
         description = data_utils.rand_name('description')
         cls.security_group = cls.security_client.create_security_group(
-            name, description)
+            name=name, description=description)
 
         parent_group_id = cls.security_group['id']
         ip_protocol = 'tcp'
@@ -262,7 +262,7 @@
             resp['status'] = None
             self.assertRaises(lib_exc.BadRequest,
                               self.alt_security_client.create_security_group,
-                              s_name, s_description)
+                              name=s_name, description=s_description)
         finally:
             # Next request the base_url is back to normal
             if resp['status'] is not None:
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index f35548a..9402154 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -915,7 +915,7 @@
             continue
 
         body = client.secgroups.create_security_group(
-            secgroup['name'], secgroup['description'])
+            name=secgroup['name'], description=secgroup['description'])
         secgroup_id = body['id']
         # for each security group, create the rules
         for rule in secgroup['rules']:
diff --git a/tempest/common/validation_resources.py b/tempest/common/validation_resources.py
index 852ee54..15c452f 100644
--- a/tempest/common/validation_resources.py
+++ b/tempest/common/validation_resources.py
@@ -27,7 +27,8 @@
     sg_name = data_utils.rand_name('securitygroup-')
     sg_description = data_utils.rand_name('description-')
     security_group = \
-        security_group_client.create_security_group(sg_name, sg_description)
+        security_group_client.create_security_group(name=sg_name,
+                                                    description=sg_description)
     if add_rule:
         security_group_client.create_security_group_rule(security_group['id'],
                                                          'tcp', 22, 22)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 67052b0..869de2d 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -261,7 +261,7 @@
         sg_name = data_utils.rand_name(self.__class__.__name__)
         sg_desc = sg_name + " description"
         secgroup = self.security_groups_client.create_security_group(
-            sg_name, sg_desc)
+            name=sg_name, description=sg_desc)
         self.assertEqual(secgroup['name'], sg_name)
         self.assertEqual(secgroup['description'], sg_desc)
         self.addCleanup(self.delete_wrapper,
diff --git a/tempest/scenario/test_large_ops.py b/tempest/scenario/test_large_ops.py
index fa70d3f..c44557e 100644
--- a/tempest/scenario/test_large_ops.py
+++ b/tempest/scenario/test_large_ops.py
@@ -87,7 +87,7 @@
         # Since no traffic is tested, we don't need to actually add rules to
         # secgroup
         secgroup = self.security_groups_client.create_security_group(
-            'secgroup-%s' % name, 'secgroup-desc-%s' % name)
+            name='secgroup-%s' % name, description='secgroup-desc-%s' % name)
         self.addCleanupClass(self.security_groups_client.delete_security_group,
                              secgroup['id'])
         create_kwargs = {
diff --git a/tempest/services/compute/json/security_groups_client.py b/tempest/services/compute/json/security_groups_client.py
index eec961c..c0b667b 100644
--- a/tempest/services/compute/json/security_groups_client.py
+++ b/tempest/services/compute/json/security_groups_client.py
@@ -43,36 +43,26 @@
         self.validate_response(schema.get_security_group, resp, body)
         return service_client.ResponseBody(resp, body['security_group'])
 
-    def create_security_group(self, name, description):
+    def create_security_group(self, **kwargs):
         """
         Creates a new security group.
         name (Required): Name of security group.
         description (Required): Description of security group.
         """
-        post_body = {
-            'name': name,
-            'description': description,
-        }
-        post_body = json.dumps({'security_group': post_body})
+        post_body = json.dumps({'security_group': kwargs})
         resp, body = self.post('os-security-groups', post_body)
         body = json.loads(body)
         self.validate_response(schema.get_security_group, resp, body)
         return service_client.ResponseBody(resp, body['security_group'])
 
-    def update_security_group(self, security_group_id, name=None,
-                              description=None):
+    def update_security_group(self, security_group_id, **kwargs):
         """
         Update a security group.
         security_group_id: a security_group to update
         name: new name of security group
         description: new description of security group
         """
-        post_body = {}
-        if name:
-            post_body['name'] = name
-        if description:
-            post_body['description'] = description
-        post_body = json.dumps({'security_group': post_body})
+        post_body = json.dumps({'security_group': kwargs})
         resp, body = self.put('os-security-groups/%s' % security_group_id,
                               post_body)
         body = json.loads(body)
diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py
index 4a27466..03a2d27 100644
--- a/tempest/stress/actions/ssh_floating.py
+++ b/tempest/stress/actions/ssh_floating.py
@@ -93,8 +93,8 @@
         sec_grp_cli = self.manager.security_groups_client
         s_name = data_utils.rand_name('sec_grp')
         s_description = data_utils.rand_name('desc')
-        self.sec_grp = sec_grp_cli.create_security_group(s_name,
-                                                         s_description)
+        self.sec_grp = sec_grp_cli.create_security_group(
+            name=s_name, description=s_description)
         create_rule = sec_grp_cli.create_security_group_rule
         create_rule(self.sec_grp['id'], 'tcp', 22, 22)
         create_rule(self.sec_grp['id'], 'icmp', -1, -1)
diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py
index c48ad4b..93a443e 100644
--- a/tempest/stress/actions/volume_attach_verify.py
+++ b/tempest/stress/actions/volume_attach_verify.py
@@ -55,8 +55,8 @@
         sec_grp_cli = self.manager.security_groups_client
         s_name = data_utils.rand_name('sec_grp')
         s_description = data_utils.rand_name('desc')
-        self.sec_grp = sec_grp_cli.create_security_group(s_name,
-                                                         s_description)
+        self.sec_grp = sec_grp_cli.create_security_group(
+            name=s_name, description=s_description)
         create_rule = sec_grp_cli.create_security_group_rule
         create_rule(self.sec_grp['id'], 'tcp', 22, 22)
         create_rule(self.sec_grp['id'], 'icmp', -1, -1)
diff --git a/tempest/tests/cmd/test_javelin.py b/tempest/tests/cmd/test_javelin.py
index f0921d5..3a3e46e 100644
--- a/tempest/tests/cmd/test_javelin.py
+++ b/tempest/tests/cmd/test_javelin.py
@@ -278,8 +278,8 @@
 
         mocked_function = self.fake_client.secgroups.create_security_group
         mocked_function.assert_called_once_with(
-            self.fake_object['name'],
-            self.fake_object['description'])
+            name=self.fake_object['name'],
+            description=self.fake_object['description'])
 
 
 class TestDestroyResources(JavelinUnitTest):