Merge "fix bug of fail to create volume type encryption from dashboard"
This commit is contained in:
commit
a4443f4be7
@ -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