Merge "Add option for image formats config"

This commit is contained in:
Zuul 2018-01-06 10:03:05 +00:00 committed by Gerrit Code Review
commit e8febc0eb6
6 changed files with 115 additions and 48 deletions

View File

@ -350,3 +350,19 @@ options:
workflow for image and instance snapshot sources when launching an
instance. This option has an effect only to Ocata or newer
releases.
image-formats:
type: string
default: ""
description: |
The image-formats setting can be used to alter the default list of
advertised image formats. Many installations cannot use all the formats
that Glance recognizes, restricting the list here prevents unwanted
formats from being listed in Horizon which can lead to confusion.
.
This setting takes a space separated list, for example: iso qcow2 raw
.
Supported formats are: aki, ami, ari, docker, iso, ova, qcow2, raw, vdi,
vhd, vmdk.
.
If not provided, leave the option unconfigured which enables all of the
above.

View File

@ -204,6 +204,7 @@ class HorizonContext(OSContextGenerator):
'default_domain': config('default-domain'),
'multi_domain': False if config('default-domain') else True,
"default_create_volume": config("default-create-volume"),
'image_formats': config('image-formats'),
}
return ctxt

View File

@ -364,22 +364,25 @@ OPENSTACK_HEAT_STACK = {
# 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': [
# ('', _('Select format')),
# ('aki', _('AKI - Amazon Kernel Image')),
# ('ami', _('AMI - Amazon Machine Image')),
# ('ari', _('ARI - Amazon Ramdisk Image')),
# ('docker', _('Docker')),
# ('iso', _('ISO - Optical Disk Image')),
# ('ova', _('OVA - Open Virtual Appliance')),
# ('qcow2', _('QCOW2 - QEMU Emulator')),
# ('raw', _('Raw')),
# ('vdi', _('VDI - Virtual Disk Image')),
# ('vhd', _('VHD - Virtual Hard Disk')),
# ('vmdk', _('VMDK - Virtual Machine Disk')),
# ],
#}
{% if image_formats -%}
OPENSTACK_IMAGE_BACKEND = {
'image_formats': [
('', _('Select format')),
{% if 'aki' in image_formats -%}('aki', _('AKI - Amazon Kernel Image')),{% endif %}
{% if 'ami' in image_formats -%}('ami', _('AMI - Amazon Machine Image')),{% endif %}
{% if 'ari' in image_formats -%}('ari', _('ARI - Amazon Ramdisk Image')),{% endif %}
{% if 'docker' in image_formats -%}('docker', _('Docker')),{% endif %}
{% if 'iso' in image_formats -%}('iso', _('ISO - Optical Disk Image')),{% endif %}
{% if 'ova' in image_formats -%}('ova', _('OVA - Open Virtual Appliance')),{% endif %}
{% if 'qcow2' in image_formats -%}('qcow2', _('QCOW2 - QEMU Emulator')),{% endif %}
{% if 'raw' in image_formats -%}('raw', _('Raw')),{% endif %}
{% if 'vdi' in image_formats -%}('vdi', _('VDI - Virtual Disk Image')),{% endif %}
{% if 'vhd' in image_formats -%}('vhd', _('VHD - Virtual Hard Disk')),{% endif %}
{% if 'vmdk' in image_formats -%}('vmdk', _('VMDK - Virtual Machine Disk')),{% endif %}
],
}
{% endif -%}
# The IMAGE_CUSTOM_PROPERTY_TITLES settings is used to customize the titles for
# image custom property attributes that appear on image detail pages.

View File

@ -393,22 +393,25 @@ OPENSTACK_HEAT_STACK = {
# 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': [
# ('', _('Select format')),
# ('aki', _('AKI - Amazon Kernel Image')),
# ('ami', _('AMI - Amazon Machine Image')),
# ('ari', _('ARI - Amazon Ramdisk Image')),
# ('docker', _('Docker')),
# ('iso', _('ISO - Optical Disk Image')),
# ('ova', _('OVA - Open Virtual Appliance')),
# ('qcow2', _('QCOW2 - QEMU Emulator')),
# ('raw', _('Raw')),
# ('vdi', _('VDI - Virtual Disk Image')),
# ('vhd', _('VHD - Virtual Hard Disk')),
# ('vmdk', _('VMDK - Virtual Machine Disk')),
# ],
#}
{% if image_formats -%}
OPENSTACK_IMAGE_BACKEND = {
'image_formats': [
('', _('Select format')),
{% if 'aki' in image_formats -%}('aki', _('AKI - Amazon Kernel Image')),{% endif %}
{% if 'ami' in image_formats -%}('ami', _('AMI - Amazon Machine Image')),{% endif %}
{% if 'ari' in image_formats -%}('ari', _('ARI - Amazon Ramdisk Image')),{% endif %}
{% if 'docker' in image_formats -%}('docker', _('Docker')),{% endif %}
{% if 'iso' in image_formats -%}('iso', _('ISO - Optical Disk Image')),{% endif %}
{% if 'ova' in image_formats -%}('ova', _('OVA - Open Virtual Appliance')),{% endif %}
{% if 'qcow2' in image_formats -%}('qcow2', _('QCOW2 - QEMU Emulator')),{% endif %}
{% if 'raw' in image_formats -%}('raw', _('Raw')),{% endif %}
{% if 'vdi' in image_formats -%}('vdi', _('VDI - Virtual Disk Image')),{% endif %}
{% if 'vhd' in image_formats -%}('vhd', _('VHD - Virtual Hard Disk')),{% endif %}
{% if 'vmdk' in image_formats -%}('vmdk', _('VMDK - Virtual Machine Disk')),{% endif %}
],
}
{% endif -%}
# The IMAGE_CUSTOM_PROPERTY_TITLES settings is used to customize the titles for
# image custom property attributes that appear on image detail pages.

View File

@ -397,22 +397,24 @@ OPENSTACK_HEAT_STACK = {
# 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': [
# ('', _('Select format')),
# ('aki', _('AKI - Amazon Kernel Image')),
# ('ami', _('AMI - Amazon Machine Image')),
# ('ari', _('ARI - Amazon Ramdisk Image')),
# ('docker', _('Docker')),
# ('iso', _('ISO - Optical Disk Image')),
# ('ova', _('OVA - Open Virtual Appliance')),
# ('qcow2', _('QCOW2 - QEMU Emulator')),
# ('raw', _('Raw')),
# ('vdi', _('VDI - Virtual Disk Image')),
# ('vhd', _('VHD - Virtual Hard Disk')),
# ('vmdk', _('VMDK - Virtual Machine Disk')),
# ],
#}
{% if image_formats -%}
OPENSTACK_IMAGE_BACKEND = {
'image_formats': [
('', _('Select format')),
{% if 'aki' in image_formats -%}('aki', _('AKI - Amazon Kernel Image')),{% endif %}
{% if 'ami' in image_formats -%}('ami', _('AMI - Amazon Machine Image')),{% endif %}
{% if 'ari' in image_formats -%}('ari', _('ARI - Amazon Ramdisk Image')),{% endif %}
{% if 'docker' in image_formats -%}('docker', _('Docker')),{% endif %}
{% if 'iso' in image_formats -%}('iso', _('ISO - Optical Disk Image')),{% endif %}
{% if 'ova' in image_formats -%}('ova', _('OVA - Open Virtual Appliance')),{% endif %}
{% if 'qcow2' in image_formats -%}('qcow2', _('QCOW2 - QEMU Emulator')),{% endif %}
{% if 'raw' in image_formats -%}('raw', _('Raw')),{% endif %}
{% if 'vdi' in image_formats -%}('vdi', _('VDI - Virtual Disk Image')),{% endif %}
{% if 'vhd' in image_formats -%}('vhd', _('VHD - Virtual Hard Disk')),{% endif %}
{% if 'vmdk' in image_formats -%}('vmdk', _('VMDK - Virtual Machine Disk')),{% endif %}
],
}
{% endif -%}
# The IMAGE_CUSTOM_PROPERTY_TITLES settings is used to customize the titles for
# image custom property attributes that appear on image detail pages.

View File

@ -139,6 +139,7 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
@ -164,6 +165,7 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": False,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
@ -189,6 +191,7 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
@ -214,6 +217,7 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
@ -240,6 +244,7 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
@ -269,6 +274,7 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
@ -294,6 +300,7 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
@ -319,6 +326,7 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
@ -349,6 +357,7 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
@ -374,6 +383,7 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
@ -399,10 +409,12 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": '',
}
)
def test_HorizonContext_password_autocompletion(self):
self.maxDiff = 900
self.test_config.set('allow-password-autocompletion', True)
self.assertEqual(horizon_contexts.HorizonContext()(),
{'compress_offline': True, 'debug': False,
@ -424,10 +436,12 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": True,
"default_create_volume": True,
"image_formats": '',
}
)
def test_HorizonContext_default_create_volume(self):
self.maxDiff = 900
self.test_config.set('default-create-volume', False)
self.assertEqual(horizon_contexts.HorizonContext()(),
{'compress_offline': True, 'debug': False,
@ -449,6 +463,34 @@ class TestHorizonContexts(CharmTestCase):
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": False,
"image_formats": '',
}
)
def test_HorizonContext_image_formats(self):
self.maxDiff = 900
self.test_config.set('image-formats', 'iso qcow2 raw')
self.assertEqual(horizon_contexts.HorizonContext()(),
{'compress_offline': True, 'debug': False,
'customization_module': '',
'default_role': 'Member', 'webroot': '/horizon',
'ubuntu_theme': True,
'default_theme': None,
'virtualenv': None,
'secret': 'secret',
'support_profile': None,
"neutron_network_dvr": False,
"neutron_network_l3ha": False,
"neutron_network_lb": False,
"neutron_network_firewall": False,
"neutron_network_vpn": False,
"cinder_backup": False,
"password_retrieve": False,
"default_domain": None,
"multi_domain": True,
"allow_password_autocompletion": False,
"default_create_volume": True,
"image_formats": 'iso qcow2 raw',
}
)