fix bug of fail to create volume type encryption from dashboard
Due to the commit https://review.openstack.org/#/c/573093/, the body of create and update from dashboard for volume type encryption does not match the schemas of it's API. The schemas url is https://github.com/openstack/cinder/blob /master/cinder/api/schemas/volume_type_encryption.py So that, pop the volume_type_id and name from the data to match the schemas. Change-Id: I032e59251a0d54cd09ead8cf3b0ac2527d9261db Closes-Bug: #1783467
This commit is contained in:
parent
9a66accb1c
commit
633897ae54
@ -115,13 +115,16 @@ class CreateVolumeTypeEncryption(forms.SelfHandlingForm):
|
||||
if data['cipher'] == u'':
|
||||
data['cipher'] = None
|
||||
|
||||
volume_type_id = data.pop('volume_type_id')
|
||||
volume_type_name = data.pop('name')
|
||||
|
||||
# Create encryption for the volume type
|
||||
volume_type = cinder.\
|
||||
volume_encryption_type_create(request,
|
||||
data['volume_type_id'],
|
||||
volume_type_id,
|
||||
data)
|
||||
messages.success(request, _('Successfully created encryption for '
|
||||
'volume type: %s') % data['name'])
|
||||
'volume type: %s') % volume_type_name)
|
||||
return volume_type
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volume_types:index")
|
||||
@ -138,13 +141,16 @@ class UpdateVolumeTypeEncryption(CreateVolumeTypeEncryption):
|
||||
if data['cipher'] == u'':
|
||||
data['cipher'] = None
|
||||
|
||||
volume_type_id = data.pop('volume_type_id')
|
||||
volume_type_name = data.pop('name')
|
||||
|
||||
# Update encryption for the volume type
|
||||
volume_type = cinder.\
|
||||
volume_encryption_type_update(request,
|
||||
data['volume_type_id'],
|
||||
volume_type_id,
|
||||
data)
|
||||
messages.success(request, _('Successfully updated encryption for '
|
||||
'volume type: %s') % data['name'])
|
||||
'volume type: %s') % volume_type_name)
|
||||
return volume_type
|
||||
except NotImplementedError:
|
||||
messages.error(request, _('Updating encryption is not '
|
||||
|
@ -192,10 +192,16 @@ class VolumeTypeTests(test.BaseAdminViewTests):
|
||||
'admin/volume_types/create_volume_type_encryption.html')
|
||||
self.mock_volume_type_list.assert_called_once_with(
|
||||
test.IsHttpRequest())
|
||||
expected = {
|
||||
'provider': u'a-provider',
|
||||
'control_location': u'front-end',
|
||||
'cipher': u'a-cipher',
|
||||
'key_size': 512,
|
||||
}
|
||||
self.mock_volume_encryption_type_create.assert_called_once_with(
|
||||
test.IsHttpRequest(),
|
||||
formData['volume_type_id'],
|
||||
formData)
|
||||
volume_type1.id,
|
||||
expected)
|
||||
|
||||
@test.create_mocks({api.cinder: ('volume_encryption_type_get',
|
||||
'volume_type_list',)})
|
||||
@ -327,10 +333,16 @@ class VolumeTypeTests(test.BaseAdminViewTests):
|
||||
test.IsHttpRequest(), volume_type.id)
|
||||
self.mock_volume_type_list.assert_called_once_with(
|
||||
test.IsHttpRequest())
|
||||
expected = {
|
||||
'provider': u'a-provider',
|
||||
'control_location': u'front-end',
|
||||
'cipher': u'a-cipher',
|
||||
'key_size': 256,
|
||||
}
|
||||
self.mock_volume_encryption_type_update.assert_called_once_with(
|
||||
test.IsHttpRequest(),
|
||||
formData['volume_type_id'],
|
||||
formData)
|
||||
volume_type.id,
|
||||
expected)
|
||||
|
||||
@test.create_mocks({api.cinder: ('volume_type_get',
|
||||
'volume_type_access_list',
|
||||
|
Loading…
Reference in New Issue
Block a user