Merge "Make volume_types_client use **kwargs"
diff --git a/tempest/api/volume/admin/test_multi_backend.py b/tempest/api/volume/admin/test_multi_backend.py
index 6d2aaea..8e43b00 100644
--- a/tempest/api/volume/admin/test_multi_backend.py
+++ b/tempest/api/volume/admin/test_multi_backend.py
@@ -71,7 +71,7 @@
         else:
             extra_specs = {spec_key_without_prefix: backend_name_key}
         self.type = self.volume_types_client.create_volume_type(
-            type_name, extra_specs=extra_specs)['volume_type']
+            name=type_name, extra_specs=extra_specs)['volume_type']
         self.volume_type_id_list.append(self.type['id'])
 
         params = {self.name_field: vol_name, 'volume_type': type_name}
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index 754cc5a..acb591d 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -50,7 +50,7 @@
         for i in range(2):
             vol_type_name = data_utils.rand_name("volume-type")
             vol_type = self.volume_types_client.create_volume_type(
-                vol_type_name,
+                name=vol_type_name,
                 extra_specs=extra_specs)['volume_type']
             volume_types.append(vol_type)
             self.addCleanup(self._delete_volume_type, vol_type['id'])
@@ -97,7 +97,7 @@
         extra_specs = {"storage_protocol": proto,
                        "vendor_name": vendor}
         body = self.volume_types_client.create_volume_type(
-            name,
+            name=name,
             extra_specs=extra_specs)['volume_type']
         self.assertIn('id', body)
         self.addCleanup(self._delete_volume_type, body['id'])
@@ -125,7 +125,8 @@
         provider = "LuksEncryptor"
         control_location = "front-end"
         name = data_utils.rand_name("volume-type")
-        body = self.volume_types_client.create_volume_type(name)['volume_type']
+        body = self.volume_types_client.create_volume_type(
+            name=name)['volume_type']
         self.addCleanup(self._delete_volume_type, body['id'])
 
         # Create encryption type
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs.py b/tempest/api/volume/admin/test_volume_types_extra_specs.py
index bec803c..502cd86 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs.py
@@ -25,7 +25,7 @@
         super(VolumeTypesExtraSpecsV2Test, cls).resource_setup()
         vol_type_name = data_utils.rand_name('Volume-type')
         cls.volume_type = cls.volume_types_client.create_volume_type(
-            vol_type_name)['volume_type']
+            name=vol_type_name)['volume_type']
 
     @classmethod
     def resource_cleanup(cls):
diff --git a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
index 040ef53..6483af3 100644
--- a/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_extra_specs_negative.py
@@ -30,7 +30,7 @@
         vol_type_name = data_utils.rand_name('Volume-type')
         cls.extra_specs = {"spec1": "val1"}
         cls.volume_type = cls.volume_types_client.create_volume_type(
-            vol_type_name,
+            name=vol_type_name,
             extra_specs=cls.extra_specs)['volume_type']
 
     @classmethod
@@ -70,7 +70,7 @@
     def test_update_multiple_extra_spec(self):
         # Should not update volume type extra specs with multiple specs as
             # body.
-        extra_spec = {"spec1": "val2", 'spec2': 'val1'}
+        extra_spec = {"spec1": "val2", "spec2": "val1"}
         self.assertRaises(
             lib_exc.BadRequest,
             self.volume_types_client.update_volume_type_extra_specs,
@@ -101,7 +101,7 @@
         self.assertRaises(
             lib_exc.BadRequest,
             self.volume_types_client.create_volume_type_extra_specs,
-            self.volume_type['id'], ['invalid'])
+            self.volume_type['id'], extra_specs=['invalid'])
 
     @test.idempotent_id('031cda8b-7d23-4246-8bf6-bbe73fd67074')
     def test_delete_nonexistent_volume_type_id(self):
diff --git a/tempest/api/volume/admin/test_volume_types_negative.py b/tempest/api/volume/admin/test_volume_types_negative.py
index 2694b63..bc32fc9 100644
--- a/tempest/api/volume/admin/test_volume_types_negative.py
+++ b/tempest/api/volume/admin/test_volume_types_negative.py
@@ -36,7 +36,7 @@
     def test_create_with_empty_name(self):
         # Should not be able to create volume type with an empty name.
         self.assertRaises(lib_exc.BadRequest,
-                          self.volume_types_client.create_volume_type, '')
+                          self.volume_types_client.create_volume_type, name='')
 
     @test.idempotent_id('994610d6-0476-4018-a644-a2602ef5d4aa')
     def test_get_nonexistent_type_id(self):
diff --git a/tempest/api/volume/test_qos.py b/tempest/api/volume/test_qos.py
index 2f7c3df..722a39a 100644
--- a/tempest/api/volume/test_qos.py
+++ b/tempest/api/volume/test_qos.py
@@ -53,7 +53,7 @@
     def _create_test_volume_type(self):
         vol_type_name = utils.rand_name("volume-type")
         vol_type = self.volume_types_client.create_volume_type(
-            vol_type_name)['volume_type']
+            name=vol_type_name)['volume_type']
         self.addCleanup(self.volume_types_client.delete_volume_type,
                         vol_type['id'])
         return vol_type
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index c2159c3..7e8fb7a 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -1365,7 +1365,7 @@
         randomized_name = data_utils.rand_name('scenario-type-' + name)
         LOG.debug("Creating a volume type: %s", randomized_name)
         body = client.create_volume_type(
-            randomized_name)['volume_type']
+            name=randomized_name)['volume_type']
         self.assertIn('id', body)
         self.addCleanup(client.delete_volume_type, body['id'])
         return body
diff --git a/tempest/services/volume/base/admin/base_types_client.py b/tempest/services/volume/base/admin/base_types_client.py
index de6ea8a..867273e 100644
--- a/tempest/services/volume/base/admin/base_types_client.py
+++ b/tempest/services/volume/base/admin/base_types_client.py
@@ -47,10 +47,10 @@
         """Returns the primary type of resource this client works with."""
         return 'volume-type/encryption-type'
 
-    def list_volume_types(self, params=None):
+    def list_volume_types(self, **params):
         """List all the volume_types created."""
         url = 'types'
-        if params is not None:
+        if params:
             url += '?%s' % urllib.urlencode(params)
 
         resp, body = self.get(url)
@@ -66,19 +66,13 @@
         self.expected_success(200, resp.status)
         return service_client.ResponseBody(resp, body)
 
-    def create_volume_type(self, name, **kwargs):
-        """Creates a new Volume_type.
+    def create_volume_type(self, **kwargs):
+        """Create volume type.
 
-        name(Required): Name of volume_type.
-        Following optional keyword arguments are accepted:
-        extra_specs: A dictionary of values to be used as extra_specs.
+        Available params: see http://developer.openstack.org/
+                              api-ref-blockstorage-v2.html#createVolumeType
         """
-        post_body = {
-            'name': name,
-            'extra_specs': kwargs.get('extra_specs'),
-        }
-
-        post_body = json.dumps({'volume_type': post_body})
+        post_body = json.dumps({'volume_type': kwargs})
         resp, body = self.post('types', post_body)
         body = json.loads(body)
         self.expected_success(200, resp.status)
@@ -90,10 +84,17 @@
         self.expected_success(202, resp.status)
         return service_client.ResponseBody(resp, body)
 
-    def list_volume_types_extra_specs(self, vol_type_id, params=None):
-        """List all the volume_types extra specs created."""
+    def list_volume_types_extra_specs(self, vol_type_id, **params):
+        """List all the volume_types extra specs created.
+
+        TODO: Current api-site doesn't contain this API description.
+        After fixing the api-site, we need to fix here also for putting
+        the link to api-site.
+
+
+        """
         url = 'types/%s/extra_specs' % str(vol_type_id)
-        if params is not None:
+        if params:
             url += '?%s' % urllib.urlencode(params)
 
         resp, body = self.get(url)
@@ -101,23 +102,23 @@
         self.expected_success(200, resp.status)
         return service_client.ResponseBody(resp, body)
 
-    def show_volume_type_extra_specs(self, vol_type_id, extra_spec_name):
+    def show_volume_type_extra_specs(self, vol_type_id, extra_specs_name):
         """Returns the details of a single volume_type extra spec."""
         url = "types/%s/extra_specs/%s" % (str(vol_type_id),
-                                           str(extra_spec_name))
+                                           str(extra_specs_name))
         resp, body = self.get(url)
         body = json.loads(body)
         self.expected_success(200, resp.status)
         return service_client.ResponseBody(resp, body)
 
-    def create_volume_type_extra_specs(self, vol_type_id, extra_spec):
+    def create_volume_type_extra_specs(self, vol_type_id, extra_specs):
         """Creates a new Volume_type extra spec.
 
         vol_type_id: Id of volume_type.
         extra_specs: A dictionary of values to be used as extra_specs.
         """
         url = "types/%s/extra_specs" % str(vol_type_id)
-        post_body = json.dumps({'extra_specs': extra_spec})
+        post_body = json.dumps({'extra_specs': extra_specs})
         resp, body = self.post(url, post_body)
         body = json.loads(body)
         self.expected_success(200, resp.status)
@@ -131,7 +132,7 @@
         return service_client.ResponseBody(resp, body)
 
     def update_volume_type_extra_specs(self, vol_type_id, extra_spec_name,
-                                       extra_spec):
+                                       extra_specs):
         """Update a volume_type extra spec.
 
         vol_type_id: Id of volume_type.
@@ -141,7 +142,7 @@
         """
         url = "types/%s/extra_specs/%s" % (str(vol_type_id),
                                            str(extra_spec_name))
-        put_body = json.dumps(extra_spec)
+        put_body = json.dumps(extra_specs)
         resp, body = self.put(url, put_body)
         body = json.loads(body)
         self.expected_success(200, resp.status)
@@ -159,18 +160,14 @@
         return service_client.ResponseBody(resp, body)
 
     def create_encryption_type(self, vol_type_id, **kwargs):
-        """Create a new encryption type for the specified volume type.
+        """Create encryption type.
 
-        vol_type_id: Id of volume_type.
-        provider: Class providing encryption support.
-        cipher: Encryption algorithm/mode to use.
-        key_size: Size of the encryption key, in bits.
-        control_location: Notional service where encryption is performed.
+        TODO: Current api-site doesn't contain this API description.
+        After fixing the api-site, we need to fix here also for putting
+        the link to api-site.
         """
         url = "/types/%s/encryption" % str(vol_type_id)
-        post_body = {}
-        post_body.update(kwargs)
-        post_body = json.dumps({'encryption': post_body})
+        post_body = json.dumps({'encryption': kwargs})
         resp, body = self.post(url, post_body)
         body = json.loads(body)
         self.expected_success(200, resp.status)