summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeha Alhat <neha.alhat@nttdata.com>2018-06-07 18:22:16 +0530
committerSean McGinnis <sean.mcginnis@gmail.com>2018-07-26 11:29:08 -0500
commit8d566689001a442c2312e366acc167af88888fd3 (patch)
tree343193bb65fb86b99bb827fd9e7a7c05e3a6918b
parent0f56085c0286a022c31258689d9a416f77979d90 (diff)
downloadpython-cinderclient-8d566689001a442c2312e366acc167af88888fd3.tar.gz
Remove unnecessary parameters from volume create APIs
As per Cinder code, following parameters are not required to be passed in the request body of create volume API. * status * user_id * attach_status * project_id * source_replica If you pass these parameters, previously it was ignored but in the schema validation changes[1] we don't allow additionalProperties to be passed in the request body. If user passes additional parameters which are not as per API specs[2], then it will be rejected with 400 error. On patch[3], tempest tests: test_volume_snapshot_create_get_list_delete, test_volume_create_get_delete" are failing because of these unnecessary parameters. This patch removes these unnecessary parameters passed to the create Volume API. [1]https://blueprints.launchpad.net/cinder/+spec/json-schema-validation [2]https://review.openstack.org/#/c/507386/ [3]https://review.openstack.org/#/c/573093/ Change-Id: I37744bfd0b0bc59682c3e680c1200f608ad3991b
-rw-r--r--cinderclient/tests/unit/v2/test_shell.py37
-rw-r--r--cinderclient/tests/unit/v2/test_volumes.py7
-rw-r--r--cinderclient/tests/unit/v3/test_shell.py10
-rw-r--r--cinderclient/tests/unit/v3/test_volumes.py7
-rw-r--r--cinderclient/v2/volumes.py9
-rw-r--r--cinderclient/v3/volumes.py9
6 files changed, 9 insertions, 70 deletions
diff --git a/cinderclient/tests/unit/v2/test_shell.py b/cinderclient/tests/unit/v2/test_shell.py
index df60d10..fd301a6 100644
--- a/cinderclient/tests/unit/v2/test_shell.py
+++ b/cinderclient/tests/unit/v2/test_shell.py
@@ -94,13 +94,8 @@ class ShellTest(utils.TestCase):
self.run_command('create --metadata key1="--test1" 1')
self.assert_called('GET', '/volumes/1234')
expected = {'volume': {'imageRef': None,
- 'project_id': None,
- 'status': 'creating',
'size': 1,
- 'user_id': None,
'availability_zone': None,
- 'source_replica': None,
- 'attach_status': 'detached',
'source_volid': None,
'consistencygroup_id': None,
'name': None,
@@ -115,13 +110,8 @@ class ShellTest(utils.TestCase):
self.run_command('create --metadata key1="--t1" --name="t" 1')
self.assert_called('GET', '/volumes/1234')
expected = {'volume': {'imageRef': None,
- 'project_id': None,
- 'status': 'creating',
'size': 1,
- 'user_id': None,
'availability_zone': None,
- 'source_replica': None,
- 'attach_status': 'detached',
'source_volid': None,
'consistencygroup_id': None,
'name': '"t"',
@@ -135,13 +125,8 @@ class ShellTest(utils.TestCase):
def test_delimit_metadata_args(self):
self.run_command('create --metadata key1="test1" key2="test2" 1')
expected = {'volume': {'imageRef': None,
- 'project_id': None,
- 'status': 'creating',
'size': 1,
- 'user_id': None,
'availability_zone': None,
- 'source_replica': None,
- 'attach_status': 'detached',
'source_volid': None,
'consistencygroup_id': None,
'name': None,
@@ -157,13 +142,8 @@ class ShellTest(utils.TestCase):
self.run_command('create --metadata key1="t1" --name="t" 1')
self.assert_called('GET', '/volumes/1234')
expected = {'volume': {'imageRef': None,
- 'project_id': None,
- 'status': 'creating',
'size': 1,
- 'user_id': None,
'availability_zone': None,
- 'source_replica': None,
- 'attach_status': 'detached',
'source_volid': None,
'consistencygroup_id': None,
'name': '"t"',
@@ -345,19 +325,9 @@ class ShellTest(utils.TestCase):
self.assert_called_anytime('POST', '/volumes', partial_body=expected)
self.assert_called('GET', '/volumes/1234')
- def test_create_volume_from_replica(self):
- expected = {'volume': {'size': None}}
-
- expected['volume']['source_replica'] = '1234'
- self.run_command('create --source-replica=1234')
- self.assert_called_anytime('POST', '/volumes', partial_body=expected)
- self.assert_called('GET', '/volumes/1234')
-
def test_create_volume_from_image(self):
- expected = {'volume': {'status': 'creating',
- 'size': 1,
- 'imageRef': '1234',
- 'attach_status': 'detached'}}
+ expected = {'volume': {'size': 1,
+ 'imageRef': '1234'}}
self.run_command('create --image=1234 1')
self.assert_called_anytime('POST', '/volumes', partial_body=expected)
self.assert_called('GET', '/volumes/1234')
@@ -386,8 +356,7 @@ class ShellTest(utils.TestCase):
self.assertRaises(SystemExit, self.run_command, 'create')
def test_create_size_zero_if_not_snapshot_or_clone(self):
- expected = {'volume': {'status': 'creating',
- 'size': 0}}
+ expected = {'volume': {'size': 0}}
self.run_command('create 0')
self.assert_called_anytime('POST', '/volumes', partial_body=expected)
self.assert_called('GET', '/volumes/1234')
diff --git a/cinderclient/tests/unit/v2/test_volumes.py b/cinderclient/tests/unit/v2/test_volumes.py
index 6e5fd2f..78d67ea 100644
--- a/cinderclient/tests/unit/v2/test_volumes.py
+++ b/cinderclient/tests/unit/v2/test_volumes.py
@@ -90,20 +90,15 @@ class VolumesTest(utils.TestCase):
def test_create_volume_with_hint(self):
vol = cs.volumes.create(1, scheduler_hints='uuid')
- expected = {'volume': {'status': 'creating',
- 'description': None,
+ expected = {'volume': {'description': None,
'availability_zone': None,
'source_volid': None,
'snapshot_id': None,
'size': 1,
- 'user_id': None,
'name': None,
'imageRef': None,
- 'attach_status': 'detached',
'volume_type': None,
- 'project_id': None,
'metadata': {},
- 'source_replica': None,
'consistencygroup_id': None,
'multiattach': False},
'OS-SCH-HNT:scheduler_hints': 'uuid'}
diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py
index 1811397..e06dedc 100644
--- a/cinderclient/tests/unit/v3/test_shell.py
+++ b/cinderclient/tests/unit/v3/test_shell.py
@@ -592,13 +592,8 @@ class ShellTest(utils.TestCase):
'--volume-type 4321 1')
self.assert_called('GET', '/volumes/1234')
expected = {'volume': {'imageRef': None,
- 'project_id': None,
- 'status': 'creating',
'size': 1,
- 'user_id': None,
'availability_zone': None,
- 'source_replica': None,
- 'attach_status': 'detached',
'source_volid': None,
'consistencygroup_id': None,
'group_id': '5678',
@@ -621,13 +616,8 @@ class ShellTest(utils.TestCase):
self.run_command(cmd)
self.assert_called('GET', '/volumes/1234')
expected = {'volume': {'imageRef': None,
- 'project_id': None,
- 'status': 'creating',
- 'user_id': None,
'size': None,
'availability_zone': None,
- 'source_replica': None,
- 'attach_status': 'detached',
'source_volid': None,
'consistencygroup_id': None,
'name': None,
diff --git a/cinderclient/tests/unit/v3/test_volumes.py b/cinderclient/tests/unit/v3/test_volumes.py
index b7b1c12..42e649b 100644
--- a/cinderclient/tests/unit/v3/test_volumes.py
+++ b/cinderclient/tests/unit/v3/test_volumes.py
@@ -73,20 +73,15 @@ class VolumesTest(utils.TestCase):
def test_create_volume(self):
cs = fakes.FakeClient(api_versions.APIVersion('3.13'))
vol = cs.volumes.create(1, group_id='1234', volume_type='5678')
- expected = {'volume': {'status': 'creating',
- 'description': None,
+ expected = {'volume': {'description': None,
'availability_zone': None,
'source_volid': None,
'snapshot_id': None,
'size': 1,
- 'user_id': None,
'name': None,
'imageRef': None,
- 'attach_status': 'detached',
'volume_type': '5678',
- 'project_id': None,
'metadata': {},
- 'source_replica': None,
'consistencygroup_id': None,
'multiattach': False,
'group_id': '1234',
diff --git a/cinderclient/v2/volumes.py b/cinderclient/v2/volumes.py
index 53229ab..d8365df 100644
--- a/cinderclient/v2/volumes.py
+++ b/cinderclient/v2/volumes.py
@@ -251,8 +251,8 @@ class VolumeManager(base.ManagerWithFind):
:param name: Name of the volume
:param description: Description of the volume
:param volume_type: Type of volume
- :param user_id: User id derived from context
- :param project_id: Project id derived from context
+ :param user_id: User id derived from context (IGNORED)
+ :param project_id: Project id derived from context (IGNORED)
:param availability_zone: Availability Zone to use
:param metadata: Optional metadata to set on volume creation
:param imageRef: reference to an image stored in glance
@@ -282,15 +282,10 @@ class VolumeManager(base.ManagerWithFind):
'name': name,
'description': description,
'volume_type': volume_type,
- 'user_id': user_id,
- 'project_id': project_id,
'availability_zone': availability_zone,
- 'status': "creating",
- 'attach_status': "detached",
'metadata': volume_metadata,
'imageRef': imageRef,
'source_volid': source_volid,
- 'source_replica': source_replica,
'multiattach': multiattach,
}}
diff --git a/cinderclient/v3/volumes.py b/cinderclient/v3/volumes.py
index a8c2e49..90cf066 100644
--- a/cinderclient/v3/volumes.py
+++ b/cinderclient/v3/volumes.py
@@ -87,8 +87,8 @@ class VolumeManager(volumes.VolumeManager):
:param name: Name of the volume
:param description: Description of the volume
:param volume_type: Type of volume
- :param user_id: User id derived from context
- :param project_id: Project id derived from context
+ :param user_id: User id derived from context (IGNORED)
+ :param project_id: Project id derived from context (IGNORED)
:param availability_zone: Availability Zone to use
:param metadata: Optional metadata to set on volume creation
:param imageRef: reference to an image stored in glance
@@ -119,15 +119,10 @@ class VolumeManager(volumes.VolumeManager):
'name': name,
'description': description,
'volume_type': volume_type,
- 'user_id': user_id,
- 'project_id': project_id,
'availability_zone': availability_zone,
- 'status': "creating",
- 'attach_status': "detached",
'metadata': volume_metadata,
'imageRef': imageRef,
'source_volid': source_volid,
- 'source_replica': source_replica,
'multiattach': multiattach,
'backup_id': backup_id
}}