Merge "Remove encryption option for volumes"

This commit is contained in:
Jenkins 2013-09-03 17:59:33 +00:00 committed by Gerrit Code Review
commit 57a8af95af
4 changed files with 0 additions and 130 deletions

View File

@ -34,7 +34,6 @@ class CreateForm(forms.SelfHandlingForm):
type = forms.ChoiceField(label=_("Type"),
required=False)
size = forms.IntegerField(min_value=1, label=_("Size (GB)"))
encryption = forms.ChoiceField(label=_("Encryption"), required=False)
volume_source_type = forms.ChoiceField(label=_("Volume Source"),
required=False)
snapshot_source = forms.ChoiceField(label=_("Use snapshot as a source"),
@ -62,24 +61,6 @@ class CreateForm(forms.SelfHandlingForm):
[(type.name, type.name)
for type in volume_types]
# Hide the volume encryption field if the hypervisor doesn't support it
# NOTE: as of Grizzly this is not yet supported in Nova so enabling
# this setting will not do anything useful
hypervisor_features = getattr(settings,
"OPENSTACK_HYPERVISOR_FEATURES",
{})
can_encrypt_volumes = hypervisor_features.get("can_encrypt_volumes",
False)
if can_encrypt_volumes:
# TODO(laura-glendenning) get from api call in future
encryption_options = {"LUKS": "dmcrypt LUKS"}
self.fields['encryption'].choices = [("", "")] + \
[(enc, display) for enc, display in encryption_options.items()]
else:
self.fields['encryption'].widget = forms.widgets.HiddenInput()
self.fields['encryption'].required = False
if ("snapshot_id" in request.GET):
try:
snapshot = self.get_snapshot(request,
@ -214,9 +195,6 @@ class CreateForm(forms.SelfHandlingForm):
metadata = {}
if data['encryption']:
metadata['encryption'] = data['encryption']
volume = cinder.volume_create(request,
data['size'],
data['name'],

View File

@ -508,106 +508,6 @@ class VolumeViewTests(test.TestCase):
' volumes.']
self.assertEqual(res.context['form'].errors['__all__'], expected_error)
@test.create_stubs({cinder: ('volume_create',
'volume_snapshot_list',
'volume_type_list',
'tenant_absolute_limits',
'volume_list',),
api.glance: ('image_list_detailed',)})
def test_create_volume_encrypted(self):
volume = self.volumes.first()
volume_type = self.volume_types.first()
usage_limit = {'maxTotalVolumeGigabytes': 250,
'gigabytesUsed': 20,
'maxTotalVolumes': 6}
formData = {'name': u'An Encrypted Volume',
'description': u'This volume has metadata for encryption.',
'method': u'CreateForm',
'type': volume_type.name,
'size': 50,
'snapshot_source': '',
'encryption': u'LUKS'}
# check normal operation with can_encrypt_volumes = true
PREV = settings.OPENSTACK_HYPERVISOR_FEATURES['can_encrypt_volumes']
settings.OPENSTACK_HYPERVISOR_FEATURES['can_encrypt_volumes'] = True
cinder.volume_type_list(IsA(http.HttpRequest)).\
AndReturn(self.volume_types.list())
cinder.tenant_absolute_limits(IsA(http.HttpRequest)).\
AndReturn(usage_limit)
cinder.volume_list(IsA(http.HttpRequest)).\
AndReturn(self.volumes.list())
cinder.volume_snapshot_list(IsA(http.HttpRequest)).\
AndReturn(self.volume_snapshots.list())
api.glance.image_list_detailed(IsA(http.HttpRequest),
filters={'is_public': True,
'status': 'active'}) \
.AndReturn([self.images.list(), False])
api.glance.image_list_detailed(IsA(http.HttpRequest),
filters={'property-owner_id': self.tenant.id,
'status': 'active'}) \
.AndReturn([[], False])
cinder.volume_create(IsA(http.HttpRequest),
formData['size'],
formData['name'],
formData['description'],
formData['type'],
metadata={'encryption': formData['encryption']},
snapshot_id=None,
image_id=None).AndReturn(volume)
self.mox.ReplayAll()
url = reverse('horizon:project:volumes:create')
res = self.client.post(url, formData)
redirect_url = reverse('horizon:project:volumes:index')
self.assertRedirectsNoFollow(res, redirect_url)
settings.OPENSTACK_HYPERVISOR_FEATURES['can_encrypt_volumes'] = PREV
@test.create_stubs({cinder: ('volume_snapshot_list', 'volume_type_list',
'tenant_absolute_limits', 'volume_list',),
api.glance: ('image_list_detailed',)})
def test_create_volume_cannot_encrypt(self):
# check that widget is hidden if can_encrypt_volumes = false
PREV = settings.OPENSTACK_HYPERVISOR_FEATURES['can_encrypt_volumes']
settings.OPENSTACK_HYPERVISOR_FEATURES['can_encrypt_volumes'] = False
usage_limit = {'maxTotalVolumeGigabytes': 250,
'gigabytesUsed': 20,
'maxTotalVolumes': 6}
cinder.volume_type_list(IsA(http.HttpRequest)).\
AndReturn(self.volume_types.list())
cinder.tenant_absolute_limits(IsA(http.HttpRequest)).\
AndReturn(usage_limit)
cinder.volume_list(IsA(http.HttpRequest)).\
AndReturn(self.volumes.list())
cinder.volume_snapshot_list(IsA(http.HttpRequest)).\
AndReturn(self.volume_snapshots.list())
api.glance.image_list_detailed(IsA(http.HttpRequest),
filters={'is_public': True,
'status': 'active'}) \
.AndReturn([self.images.list(), False])
api.glance.image_list_detailed(IsA(http.HttpRequest),
filters={'property-owner_id': self.tenant.id,
'status': 'active'}) \
.AndReturn([[], False])
self.mox.ReplayAll()
url = reverse('horizon:project:volumes:create')
res = self.client.get(url)
# Assert the encryption field is hidden.
form = res.context['form']
self.assertTrue(isinstance(form.fields['encryption'].widget,
widgets.HiddenInput))
settings.OPENSTACK_HYPERVISOR_FEATURES['can_encrypt_volumes'] = PREV
@test.create_stubs({cinder: ('volume_list',
'volume_delete',),
api.nova: ('server_list',),

View File

@ -148,10 +148,6 @@ OPENSTACK_KEYSTONE_BACKEND = {
OPENSTACK_HYPERVISOR_FEATURES = {
'can_set_mount_point': True,
# NOTE: as of Grizzly this is not yet supported in Nova so enabling this
# setting will not do anything useful
'can_encrypt_volumes': False
}
# The OPENSTACK_NEUTRON_NETWORK settings can be used to enable optional

View File

@ -89,10 +89,6 @@ OPENSTACK_NEUTRON_NETWORK = {
OPENSTACK_HYPERVISOR_FEATURES = {
'can_set_mount_point': True,
# NOTE: as of Grizzly this is not yet supported in Nova so enabling this
# setting will not do anything useful
'can_encrypt_volumes': False
}
LOGGING['loggers']['openstack_dashboard'] = {