Added ability to use own title for image
Change-Id: I2ab9198c57aba9e55c7cba9f043d2d4dc4af3a63
This commit is contained in:
parent
78496587b3
commit
d04233aed5
|
@ -37,13 +37,14 @@ FORMS.extend(iterate_over_service_forms())
|
||||||
|
|
||||||
class MarkImageForm(SelfHandlingForm):
|
class MarkImageForm(SelfHandlingForm):
|
||||||
_metadata = {
|
_metadata = {
|
||||||
'windows.2012.standart': ' Windows Server 2012 Desktop',
|
'windows.2012': ' Windows Server 2012',
|
||||||
'linux': 'Generic Linux',
|
'linux': 'Generic Linux',
|
||||||
'cirros.demo': 'Murano Demo Image'
|
'cirros.demo': 'Murano Demo'
|
||||||
}
|
}
|
||||||
|
|
||||||
image = forms.ChoiceField(label='Image')
|
image = forms.ChoiceField(label='Image')
|
||||||
type = forms.ChoiceField(label="Metadata", choices=_metadata.items())
|
title = forms.CharField(max_length="255", label=_("Title"))
|
||||||
|
type = forms.ChoiceField(label="Type", choices=_metadata.items())
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(MarkImageForm, self).__init__(request, *args, **kwargs)
|
super(MarkImageForm, self).__init__(request, *args, **kwargs)
|
||||||
|
@ -60,18 +61,17 @@ class MarkImageForm(SelfHandlingForm):
|
||||||
def handle(self, request, data):
|
def handle(self, request, data):
|
||||||
log.debug('Marking image with specified metadata: {0}'.format(data))
|
log.debug('Marking image with specified metadata: {0}'.format(data))
|
||||||
|
|
||||||
image, mtype = (data['image'], data['type'])
|
image_id = data['image']
|
||||||
|
|
||||||
properties = {
|
properties = {
|
||||||
'murano_image_info': json.dumps({
|
'murano_image_info': json.dumps({
|
||||||
'title': self._metadata[mtype],
|
'title': data['title'],
|
||||||
'type': mtype
|
'type': data['type']
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
image = glance.image_update(request, image, properties=properties)
|
img = glance.image_update(request, image_id, properties=properties)
|
||||||
messages.success(request, _('Image successfully marked'))
|
messages.success(request, _('Image successfully marked'))
|
||||||
return image
|
return img
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(request, _('Unable to mark image'))
|
exceptions.handle(request, _('Unable to mark image'))
|
||||||
|
|
|
@ -20,8 +20,12 @@
|
||||||
{% blocktrans %}Select one of the images registered in the Glance{% endblocktrans %}
|
{% blocktrans %}Select one of the images registered in the Glance{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<strong>{% trans 'Metadata' %}:</strong>
|
<strong>{% trans 'Title' %}:</strong>
|
||||||
{% blocktrans %}Pick metadata from supported by Murano{% endblocktrans %}
|
{% blocktrans %}Image description which will help you to recognize the image during service creation{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>{% trans 'Type' %}:</strong>
|
||||||
|
{% blocktrans %}Pick image type from types supported by Murano{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue