Add volume type encryption delete
This patch adds support to horizon for volume type encryption delete. The contents of this patch were originally a part of a combined volume type encryption update and delete patch, (https://review.openstack.org/#/c/72024/) but the delete portion has been moved to this patch since the pieces do not depend on each other. The modifications are made to the Admin Volume Type table, and add the Delete Encryption action to the action column. Unit tests are also included. Change-Id: Ide9109ca22a04b9121bc78eeea26be9ef2adbf97 Implements: blueprint integration-with-cinder-volume-encryption
This commit is contained in:
parent
926fa00073
commit
9f73f80e21
@ -400,6 +400,10 @@ def volume_encryption_type_create(request, volume_type_id, data):
|
||||
specs=data)
|
||||
|
||||
|
||||
def volume_encryption_type_delete(request, volume_type_id):
|
||||
return cinderclient(request).volume_encryption_types.delete(volume_type_id)
|
||||
|
||||
|
||||
def volume_encryption_type_get(request, volume_type_id):
|
||||
return cinderclient(request).volume_encryption_types.get(volume_type_id)
|
||||
|
||||
|
@ -75,10 +75,7 @@ class VolumeTests(test.BaseAdminViewTests):
|
||||
cinder.volume_encryption_type_list(IsA(http.HttpRequest))\
|
||||
.AndReturn(encryption_list)
|
||||
cinder.extension_supported(IsA(http.HttpRequest),
|
||||
'VolumeTypeEncryption')\
|
||||
.AndReturn(True)
|
||||
cinder.extension_supported(IsA(http.HttpRequest),
|
||||
'VolumeTypeEncryption')\
|
||||
'VolumeTypeEncryption').MultipleTimes()\
|
||||
.AndReturn(True)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
@ -84,6 +84,36 @@ class CreateVolumeTypeEncryption(tables.LinkAction):
|
||||
return False
|
||||
|
||||
|
||||
class DeleteVolumeTypeEncryption(tables.DeleteAction):
|
||||
name = "delete_encryption"
|
||||
policy_rules = (("volume", "volume_extension:volume_type_encryption"),)
|
||||
|
||||
@staticmethod
|
||||
def action_present(count):
|
||||
return ungettext_lazy(
|
||||
u"Delete Encryption",
|
||||
u"Delete Encryptions",
|
||||
count
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def action_past(count):
|
||||
return ungettext_lazy(
|
||||
u"Deleted Encryption",
|
||||
u"Deleted Encryptions",
|
||||
count
|
||||
)
|
||||
|
||||
def delete(self, request, volume_type_id):
|
||||
cinder.volume_encryption_type_delete(request,
|
||||
volume_type_id)
|
||||
|
||||
def allowed(self, request, volume_type=None):
|
||||
return (_is_vol_type_enc_possible(request) and
|
||||
hasattr(volume_type, 'encryption') and
|
||||
hasattr(volume_type.encryption, 'provider'))
|
||||
|
||||
|
||||
def _is_vol_type_enc_possible(request):
|
||||
try:
|
||||
supported = cinder.extension_supported(request,
|
||||
@ -126,6 +156,7 @@ class VolumeTypesTable(tables.DataTable):
|
||||
row_actions = (CreateVolumeTypeEncryption,
|
||||
ViewVolumeTypeExtras,
|
||||
ManageQosSpecAssociation,
|
||||
DeleteVolumeTypeEncryption,
|
||||
DeleteVolumeType,)
|
||||
|
||||
|
||||
|
@ -167,3 +167,38 @@ class VolumeTypeTests(test.BaseAdminViewTests):
|
||||
self.assertContains(res, "<dd>%s</dd>" % vol_enc_type.cipher, 1, 200)
|
||||
|
||||
self.assertNoMessages()
|
||||
|
||||
@test.create_stubs({cinder: ('extension_supported',
|
||||
'volume_type_list_with_qos_associations',
|
||||
'qos_spec_list',
|
||||
'volume_encryption_type_list',
|
||||
'volume_encryption_type_delete',)})
|
||||
def test_delete_volume_type_encryption(self):
|
||||
volume_type = self.volume_types.first()
|
||||
volume_type.id = u'1'
|
||||
formData = {'action': 'volume_types__delete_encryption__%s' %
|
||||
volume_type.id}
|
||||
encryption_list = (self.cinder_volume_encryption_types.list()[0],
|
||||
self.cinder_volume_encryption_types.list()[1])
|
||||
|
||||
cinder.extension_supported(IsA(http.HttpRequest),
|
||||
'VolumeTypeEncryption')\
|
||||
.AndReturn(True)
|
||||
cinder.volume_type_list_with_qos_associations(
|
||||
IsA(http.HttpRequest))\
|
||||
.AndReturn(self.volume_types.list())
|
||||
cinder.qos_spec_list(IsA(http.HttpRequest))\
|
||||
.AndReturn(self.cinder_qos_specs.list())
|
||||
cinder.volume_encryption_type_list(IsA(http.HttpRequest))\
|
||||
.AndReturn(encryption_list)
|
||||
cinder.volume_encryption_type_delete(IsA(http.HttpRequest),
|
||||
volume_type.id)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.post(
|
||||
reverse('horizon:admin:volumes:volume_types_tab'),
|
||||
formData)
|
||||
|
||||
redirect = reverse('horizon:admin:volumes:volume_types_tab')
|
||||
self.assertNoFormErrors(res)
|
||||
self.assertRedirectsNoFollow(res, redirect)
|
||||
|
Loading…
Reference in New Issue
Block a user