Make Image Service image formats configurable

Allow configuration of the available image formats
for image creation (corresponds to a feature added
Glance).

Incidentally fixes a test issue where the domain_get
call wasn't being properly stubbed out.

Fixes bug 1216157

Change-Id: Ifc72915d34767ce83f9d85b92ddeae0c2c00b8c6
This commit is contained in:
Gabriel Hurley 2013-09-03 11:54:58 -07:00
parent 57a8af95af
commit 47757ada08
5 changed files with 44 additions and 21 deletions

View File

@ -189,7 +189,8 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
@test.create_stubs({api.keystone: ('get_default_role',
'user_list',
'group_list',
'role_list'),
'role_list',
'domain_get'),
api.neutron: ('is_extension_supported',
'tenant_quota_get'),
quotas: ('get_default_quota_data',)})
@ -237,7 +238,8 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
'tenant_create',
'user_list',
'group_list',
'role_list'),
'role_list',
'domain_get'),
quotas: ('get_default_quota_data',),
api.cinder: ('tenant_quota_update',),
api.nova: ('tenant_quota_update',)})

View File

@ -36,6 +36,10 @@ from horizon import messages
from openstack_dashboard import api
IMAGE_BACKEND_SETTINGS = getattr(settings, 'OPENSTACK_IMAGE_BACKEND', {})
IMAGE_FORMAT_CHOICES = IMAGE_BACKEND_SETTINGS.get('image_formats', [])
LOG = logging.getLogger(__name__)
@ -71,24 +75,7 @@ class CreateImageForm(forms.SelfHandlingForm):
required=False)
disk_format = forms.ChoiceField(label=_('Format'),
required=True,
choices=[('', ''),
('aki',
_('AKI - Amazon Kernel '
'Image')),
('ami',
_('AMI - Amazon Machine '
'Image')),
('ari',
_('ARI - Amazon Ramdisk '
'Image')),
('iso',
_('ISO - Optical Disk Image')),
('qcow2',
_('QCOW2 - QEMU Emulator')),
('raw', 'Raw'),
('vdi', 'VDI'),
('vhd', 'VHD'),
('vmdk', 'VMDK')],
choices=[],
widget=forms.Select(attrs={'class':
'switchable'}))
minimum_disk = forms.IntegerField(label=_("Minimum Disk (GB)"),
@ -112,6 +99,7 @@ class CreateImageForm(forms.SelfHandlingForm):
super(CreateImageForm, self).__init__(*args, **kwargs)
if not settings.HORIZON_IMAGES_ALLOW_UPLOAD:
self.fields['image_file'].widget = HiddenInput()
self.fields['disk_format'].choices = IMAGE_FORMAT_CHOICES
def clean(self):
data = super(CreateImageForm, self).clean()

View File

@ -159,6 +159,24 @@ OPENSTACK_NEUTRON_NETWORK = {
'enable_security_group': True,
}
# The OPENSTACK_IMAGE_BACKEND settings can be used to customize features
# in the OpenStack Dashboard related to the Image service, such as the list
# of supported image formats.
OPENSTACK_IMAGE_BACKEND = {
'image_formats': [
('', ''),
('aki', _('AKI - Amazon Kernel Image')),
('ami', _('AMI - Amazon Machine Image')),
('ari', _('ARI - Amazon Ramdisk Image')),
('iso', _('ISO - Optical Disk Image')),
('qcow2', _('QCOW2 - QEMU Emulator')),
('raw', _('Raw')),
('vdi', _('VDI')),
('vhd', _('VHD')),
('vmdk', _('VMDK'))
]
}
# OPENSTACK_ENDPOINT_TYPE specifies the endpoint type to use for the endpoints
# in the Keystone service catalog. Use this setting when Horizon is running
# external to the OpenStack environment. The default is 'publicURL'.

View File

@ -91,6 +91,21 @@ OPENSTACK_HYPERVISOR_FEATURES = {
'can_set_mount_point': True,
}
OPENSTACK_IMAGE_BACKEND = {
'image_formats': [
('', ''),
('aki', _('AKI - Amazon Kernel Image')),
('ami', _('AMI - Amazon Machine Image')),
('ari', _('ARI - Amazon Ramdisk Image')),
('iso', _('ISO - Optical Disk Image')),
('qcow2', _('QCOW2 - QEMU Emulator')),
('raw', _('Raw')),
('vdi', _('VDI')),
('vhd', _('VHD')),
('vmdk', _('VMDK'))
]
}
LOGGING['loggers']['openstack_dashboard'] = {
'handlers': ['test'],
'propagate': False,

View File

@ -6,7 +6,7 @@ set -o errexit
# Increment me any time the environment should be rebuilt.
# This includes dependncy changes, directory renames, etc.
# Simple integer secuence: 1, 2, 3...
environment_version=39
environment_version=40
#--------------------------------------------------------#
function usage {