Add general description field in image properties
It would be beneficial for us to be able to add descriptions to the image file. Change-Id: I8e5f9ce423f1bc76e559ffb437f255fd9717902e Fixes: bug #1180861
This commit is contained in:
parent
4903a9b43f
commit
8ded0be73d
@ -41,6 +41,9 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class CreateImageForm(forms.SelfHandlingForm):
|
class CreateImageForm(forms.SelfHandlingForm):
|
||||||
name = forms.CharField(max_length="255", label=_("Name"), required=True)
|
name = forms.CharField(max_length="255", label=_("Name"), required=True)
|
||||||
|
description = forms.CharField(widget=forms.widgets.Textarea(),
|
||||||
|
label=_("Description"),
|
||||||
|
required=False)
|
||||||
copy_from = forms.CharField(max_length="255",
|
copy_from = forms.CharField(max_length="255",
|
||||||
label=_("Image Location"),
|
label=_("Image Location"),
|
||||||
help_text=_("An external (HTTP) URL to load "
|
help_text=_("An external (HTTP) URL to load "
|
||||||
@ -121,8 +124,11 @@ class CreateImageForm(forms.SelfHandlingForm):
|
|||||||
'container_format': container_format,
|
'container_format': container_format,
|
||||||
'min_disk': (data['minimum_disk'] or 0),
|
'min_disk': (data['minimum_disk'] or 0),
|
||||||
'min_ram': (data['minimum_ram'] or 0),
|
'min_ram': (data['minimum_ram'] or 0),
|
||||||
'name': data['name']}
|
'name': data['name'],
|
||||||
|
'properties': {}}
|
||||||
|
|
||||||
|
if data['description']:
|
||||||
|
meta['properties']['description'] = data['description']
|
||||||
if settings.HORIZON_IMAGES_ALLOW_UPLOAD and data['image_file']:
|
if settings.HORIZON_IMAGES_ALLOW_UPLOAD and data['image_file']:
|
||||||
meta['data'] = self.files['image_file']
|
meta['data'] = self.files['image_file']
|
||||||
else:
|
else:
|
||||||
@ -141,6 +147,9 @@ class CreateImageForm(forms.SelfHandlingForm):
|
|||||||
class UpdateImageForm(forms.SelfHandlingForm):
|
class UpdateImageForm(forms.SelfHandlingForm):
|
||||||
image_id = forms.CharField(widget=forms.HiddenInput())
|
image_id = forms.CharField(widget=forms.HiddenInput())
|
||||||
name = forms.CharField(max_length="255", label=_("Name"))
|
name = forms.CharField(max_length="255", label=_("Name"))
|
||||||
|
description = forms.CharField(widget=forms.widgets.Textarea(),
|
||||||
|
label=_("Description"),
|
||||||
|
required=False)
|
||||||
kernel = forms.CharField(max_length="36", label=_("Kernel ID"),
|
kernel = forms.CharField(max_length="36", label=_("Kernel ID"),
|
||||||
required=False,
|
required=False,
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
@ -177,6 +186,8 @@ class UpdateImageForm(forms.SelfHandlingForm):
|
|||||||
'container_format': container_format,
|
'container_format': container_format,
|
||||||
'name': data['name'],
|
'name': data['name'],
|
||||||
'properties': {}}
|
'properties': {}}
|
||||||
|
if data['description']:
|
||||||
|
meta['properties']['description'] = data['description']
|
||||||
if data['kernel']:
|
if data['kernel']:
|
||||||
meta['properties']['kernel_id'] = data['kernel']
|
meta['properties']['kernel_id'] = data['kernel']
|
||||||
if data['ramdisk']:
|
if data['ramdisk']:
|
||||||
|
@ -48,6 +48,7 @@ class CreateImageFormTests(test.TestCase):
|
|||||||
"""
|
"""
|
||||||
post = {
|
post = {
|
||||||
'name': u'Ubuntu 11.10',
|
'name': u'Ubuntu 11.10',
|
||||||
|
'description': u'Login with admin/admin',
|
||||||
'disk_format': u'qcow2',
|
'disk_format': u'qcow2',
|
||||||
'minimum_disk': 15,
|
'minimum_disk': 15,
|
||||||
'minimum_ram': 512,
|
'minimum_ram': 512,
|
||||||
@ -78,6 +79,7 @@ class ImageViewTests(test.TestCase):
|
|||||||
def test_image_create_post_copy_from(self):
|
def test_image_create_post_copy_from(self):
|
||||||
data = {
|
data = {
|
||||||
'name': u'Ubuntu 11.10',
|
'name': u'Ubuntu 11.10',
|
||||||
|
'description': u'Login with admin/admin',
|
||||||
'copy_from': u'http://cloud-images.ubuntu.com/releases/'
|
'copy_from': u'http://cloud-images.ubuntu.com/releases/'
|
||||||
u'oneiric/release/ubuntu-11.10-server-cloudimg'
|
u'oneiric/release/ubuntu-11.10-server-cloudimg'
|
||||||
u'-amd64-disk1.img',
|
u'-amd64-disk1.img',
|
||||||
@ -96,6 +98,8 @@ class ImageViewTests(test.TestCase):
|
|||||||
protected=False,
|
protected=False,
|
||||||
min_disk=data['minimum_disk'],
|
min_disk=data['minimum_disk'],
|
||||||
min_ram=data['minimum_ram'],
|
min_ram=data['minimum_ram'],
|
||||||
|
properties={
|
||||||
|
'description': data['description']},
|
||||||
name=data['name']). \
|
name=data['name']). \
|
||||||
AndReturn(self.images.first())
|
AndReturn(self.images.first())
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
@ -114,6 +118,7 @@ class ImageViewTests(test.TestCase):
|
|||||||
temp_file.seek(0)
|
temp_file.seek(0)
|
||||||
data = {
|
data = {
|
||||||
'name': u'Test Image',
|
'name': u'Test Image',
|
||||||
|
'description': u'Login with admin/admin',
|
||||||
'image_file': temp_file,
|
'image_file': temp_file,
|
||||||
'disk_format': u'qcow2',
|
'disk_format': u'qcow2',
|
||||||
'minimum_disk': 15,
|
'minimum_disk': 15,
|
||||||
@ -129,6 +134,8 @@ class ImageViewTests(test.TestCase):
|
|||||||
protected=False,
|
protected=False,
|
||||||
min_disk=data['minimum_disk'],
|
min_disk=data['minimum_disk'],
|
||||||
min_ram=data['minimum_ram'],
|
min_ram=data['minimum_ram'],
|
||||||
|
properties={
|
||||||
|
'description': data['description']},
|
||||||
name=data['name'],
|
name=data['name'],
|
||||||
data=IsA(InMemoryUploadedFile)). \
|
data=IsA(InMemoryUploadedFile)). \
|
||||||
AndReturn(self.images.first())
|
AndReturn(self.images.first())
|
||||||
|
@ -74,6 +74,7 @@ class UpdateView(forms.ModalFormView):
|
|||||||
image = self.get_object()
|
image = self.get_object()
|
||||||
return {'image_id': self.kwargs['image_id'],
|
return {'image_id': self.kwargs['image_id'],
|
||||||
'name': image.name,
|
'name': image.name,
|
||||||
|
'description': image.properties.get('description', ''),
|
||||||
'kernel': image.properties.get('kernel_id', ''),
|
'kernel': image.properties.get('kernel_id', ''),
|
||||||
'ramdisk': image.properties.get('ramdisk_id', ''),
|
'ramdisk': image.properties.get('ramdisk_id', ''),
|
||||||
'architecture': image.properties.get('architecture', ''),
|
'architecture': image.properties.get('architecture', ''),
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
<dl>
|
<dl>
|
||||||
<dt>{% trans "Name" %}</dt>
|
<dt>{% trans "Name" %}</dt>
|
||||||
<dd>{{ image.name|default:_("None") }}</dd>
|
<dd>{{ image.name|default:_("None") }}</dd>
|
||||||
|
{% if image.properties.description %}
|
||||||
|
<dt>{% trans "Description" %}</dt>
|
||||||
|
<dd>{{ image.properties.description }}</dd>
|
||||||
|
{% endif %}
|
||||||
<dt>{% trans "ID" %}</dt>
|
<dt>{% trans "ID" %}</dt>
|
||||||
<dd>{{ image.id|default:_("None") }}</dd>
|
<dd>{{ image.id|default:_("None") }}</dd>
|
||||||
<dt>{% trans "Status" %}</dt>
|
<dt>{% trans "Status" %}</dt>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user