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
This commit is contained in:

committed by
Sean McGinnis

parent
0f56085c02
commit
8d56668900
@@ -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')
|
||||
|
@@ -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'}
|
||||
|
@@ -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,
|
||||
|
@@ -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',
|
||||
|
@@ -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,
|
||||
}}
|
||||
|
||||
|
@@ -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
|
||||
}}
|
||||
|
Reference in New Issue
Block a user