Browse Source

Merge "Added detail view for images." into milestone-proposed

Jenkins 7 years ago
parent
commit
d755f7fe62

+ 2
- 1
horizon/dashboards/nova/images_and_snapshots/images/tables.py View File

@@ -66,7 +66,8 @@ def get_container_format(image):
66 66
 
67 67
 
68 68
 class ImagesTable(tables.DataTable):
69
-    name = tables.Column("name")
69
+    name = tables.Column("name", link="horizon:nova:images_and_snapshots:" \
70
+                                      "images:detail")
70 71
     image_type = tables.Column(get_image_type,
71 72
                                verbose_name=_("Type"),
72 73
                                filters=(filters.title,))

+ 14
- 0
horizon/dashboards/nova/images_and_snapshots/images/tests.py View File

@@ -210,3 +210,17 @@ class ImageViewTests(test.TestCase):
210 210
                       args=[image.id])
211 211
         res = self.client.post(url, form_data)
212 212
         self.assertRedirectsNoFollow(res, IMAGES_INDEX_URL)
213
+
214
+    def test_image_detail_get(self):
215
+        image = self.images.first()
216
+        self.mox.StubOutWithMock(api.glance, 'image_get_meta')
217
+        api.glance.image_get_meta(IsA(http.HttpRequest), str(image.id)) \
218
+                                 .AndReturn(self.images.first())
219
+        self.mox.ReplayAll()
220
+
221
+        res = self.client.get(
222
+        reverse('horizon:nova:images_and_snapshots:images:detail',
223
+                args=[image.id]))
224
+        self.assertTemplateUsed(res,
225
+                                'nova/images_and_snapshots/images/detail.html')
226
+        self.assertEqual(res.context['image'].name, image.name)

+ 3
- 2
horizon/dashboards/nova/images_and_snapshots/images/urls.py View File

@@ -20,12 +20,13 @@
20 20
 
21 21
 from django.conf.urls.defaults import patterns, url
22 22
 
23
-from .views import UpdateView, LaunchView
23
+from .views import UpdateView, LaunchView, DetailView
24 24
 
25 25
 VIEWS_MOD = 'horizon.dashboards.nova.images_and_snapshots.images.views'
26 26
 
27 27
 
28 28
 urlpatterns = patterns(VIEWS_MOD,
29 29
     url(r'^(?P<image_id>[^/]+)/launch/$', LaunchView.as_view(), name='launch'),
30
-    url(r'^(?P<image_id>[^/]+)/update/$', UpdateView.as_view(), name='update')
30
+    url(r'^(?P<image_id>[^/]+)/update/$', UpdateView.as_view(), name='update'),
31
+    url(r'^(?P<image_id>[^/]+)/$', DetailView.as_view(), name='detail'),
31 32
 )

+ 17
- 0
horizon/dashboards/nova/images_and_snapshots/images/views.py View File

@@ -24,12 +24,14 @@ Views for managing Nova images.
24 24
 
25 25
 import logging
26 26
 
27
+from django import shortcuts
27 28
 from django.core.urlresolvers import reverse
28 29
 from django.utils.translation import ugettext as _
29 30
 
30 31
 from horizon import api
31 32
 from horizon import exceptions
32 33
 from horizon import forms
34
+from horizon import views
33 35
 from .forms import UpdateImageForm, LaunchForm
34 36
 
35 37
 
@@ -168,3 +170,18 @@ class UpdateView(forms.ModalFormView):
168 170
                 'architecture': properties.get('architecture', ''),
169 171
                 'container_format': self.object.get('container_format', ''),
170 172
                 'disk_format': self.object.get('disk_format', ''), }
173
+
174
+
175
+class DetailView(views.APIView):
176
+    template_name = 'nova/images_and_snapshots/images/detail.html'
177
+
178
+    def get_data(self, request, context, *args, **kwargs):
179
+        image_id = kwargs['image_id']
180
+        try:
181
+            image = api.glance.image_get_meta(self.request, kwargs['image_id'])
182
+        except:
183
+            exceptions.handle(request, _('Unable to retrieve details for '
184
+                                         'instance "%s".') % image_id,
185
+                                                             redirect=redirect)
186
+            shortcuts.redirect('horizon:nova:images_and_snapshots:index')
187
+        return {'image': image}

+ 55
- 0
horizon/dashboards/nova/templates/nova/images_and_snapshots/images/detail.html View File

@@ -0,0 +1,55 @@
1
+{% extends 'nova/base.html' %}
2
+{% load i18n sizeformat %}
3
+{% block title %}{% trans "Image Detail "%}{% endblock %}
4
+
5
+{% block page_header %}
6
+  {% include "horizon/common/_page_header.html" with title="Image Detail: "|add:image.name %}
7
+{% endblock page_header %}
8
+
9
+{% block dash_main %}
10
+  <ul class="item_detail dash_block">
11
+    <li class="status detail_section">
12
+      <h3>{% trans "Status" %}</h3>
13
+      <ul>
14
+        <li><label>{% trans "Image ID:" %}</label>{{ image.id|default:"None" }}</li>
15
+        <li><label>{% trans "Image Status:" %}</label> {{ image.status|default:"None" }}</li>
16
+        <li><label>{% trans "Image Name:" %}</label> {{ image.name|default:"None" }}</li>
17
+        <li><label>{% trans "Public:" %}</label> {{ image.is_public }}</li>
18
+        <li><label>{% trans "Checksum:" %}</label> {{ image.checksum|default:"None" }}</li>
19
+        <li><label>{% trans "Created At:" %}</label> {{ image.created_at|default:"None" }}</li>
20
+        <li><label>{% trans "Last Updated At:" %}</label> {{ image.updated_app|default:"None" }}</li>
21
+      </ul>
22
+    </li>
23
+    <li class="specs detail_section">
24
+        <h3>{% trans "Specs" %}</h3>
25
+        <ul>
26
+          <li><label>{% trans "Size:" %}</label> {{ image.size|filesizeformat }}</li>
27
+          <li><label>{% trans "Container Format:" %}</label> {{ image.container_format|default:"None" }}</li>
28
+          <li><label>{% trans "Disk Format:" %}</label> {{ image.disk_format|default:"None" }}</li>
29
+        </ul>
30
+    </li>
31
+    <li class="custom_properties detail_section">
32
+        <h3>{% trans "Custom Properties" %}</h3>
33
+        <ul>
34
+          {% if image.properties.architecture %}
35
+            <li><label>{% trans "Architecture:" %}</label> {{ image.properties.architecture }}</li>
36
+          {% endif %}
37
+          {% if image.properties.kernel_id %}
38
+            <li><label>{% trans "Kernel ID:" %}</label> {{ image.properties.kernel_id }}</li>
39
+          {% endif %}
40
+          {% if image.properties.ramdisk_id %}
41
+            <li><label>{% trans "Ramdisk ID:" %}</label> {{ image.properties.ramdisk_id }}</li>
42
+          {% endif %}
43
+          {% if image.properties.image_state %}
44
+            <li><label>{% trans "Euca2ools state:" %}</label> {{ image.properties.image_state }}</li>
45
+          {% endif %}
46
+          {% if image.properties.project_id %}
47
+            <li><label>{% trans "Project ID:" %}</label> {{ image.properties.project_id }}</li>
48
+          {% endif %}
49
+          {% if image.properties.image_type %}
50
+            <li><label>{% trans "Image Type:" %}</label> {{ image.properties.image_type }}</li>
51
+          {% endif %}
52
+        </ul>
53
+    </li>
54
+  </ul>
55
+{% endblock %}

+ 11
- 4
openstack_dashboard/static/dashboard/css/style.css View File

@@ -852,10 +852,11 @@ iframe {
852 852
   border: none;
853 853
 }
854 854
 
855
-form .error {
856
-  background: #fce6e6;
857
-  color: #b94a48;
858
-  border: 1px solid #E9B1B0;
855
+.item_detail ul li label {
856
+  color: #000;
857
+  font-weight: bold;
858
+  display: block;
859
+  margin-top: 5px;
859 860
 }
860 861
 
861 862
 .progress_bar {
@@ -902,3 +903,9 @@ form .error {
902 903
 .header_rule {
903 904
   margin: 0 0 10px;
904 905
 }
906
+
907
+.item_detail .detail_section {
908
+  margin-bottom: 25px;
909
+  float: left;
910
+  margin-right: 50px;
911
+}

Loading…
Cancel
Save