Add ability to mark image with custom type

Change-Id: Ieee95aea134ec41daa6efb0e3803e7a4ef882a92
Closes-bug: #1622599
This commit is contained in:
Valerii Kovalchuk 2016-09-14 19:12:32 +03:00
parent 97a2c6d2bf
commit 266accb26a
2 changed files with 25 additions and 4 deletions

View File

@ -50,12 +50,27 @@ class MarkImageForm(horizon_forms.SelfHandlingForm):
_metadata = {
'windows.2012': ' Windows Server 2012',
'linux': 'Generic Linux',
'cirros.demo': 'CirrOS for Murano Demo'
'cirros.demo': 'CirrOS for Murano Demo',
'custom': "Custom type"
}
image = forms.ChoiceField(label=_('Image'))
title = forms.CharField(max_length="255", label=_("Title"))
type = forms.ChoiceField(label=_("Type"), choices=_metadata.items())
type = forms.ChoiceField(
label=_("Type"),
choices=_metadata.items(),
initial='custom',
widget=forms.Select(attrs={
'class': 'switchable',
'data-slug': 'type'}))
custom_type = forms.CharField(
max_length="255",
label=_("Custom Type"),
widget=forms.TextInput(attrs={
'class': 'switched',
'data-switch-on': 'type',
'data-type-custom': _('Custom Type')}),
required=False)
existing_titles = forms.CharField(widget=forms.HiddenInput)
def __init__(self, request, *args, **kwargs):
@ -83,10 +98,12 @@ class MarkImageForm(horizon_forms.SelfHandlingForm):
LOG.debug('Marking image with specified metadata: {0}'.format(data))
image_id = data['image']
image_type = data['type'] if data['type'] != 'custom' else \
data['custom_type']
properties = glance.image_get(request, image_id).properties
properties['murano_image_info'] = json.dumps({
'title': data['title'],
'type': data['type']
'type': image_type
})
try:

View File

@ -14,7 +14,11 @@
</p>
<p>
<strong>{% trans "Image Type" %}:</strong>
{% trans "Select an image type supported by Murano." %}
{% trans "Select an image type supported by Murano. Choose 'Custom type' to enter type manually." %}
</p>
<p>
<strong>{% trans "Custom Type" %}:</strong>
{% trans "Enter an image type supported by Murano." %}
</p>
{% endblock %}