summaryrefslogtreecommitdiff
blob: 70a6ac58fee6b533b7be28aa1555d352bd5128e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
diff -urN horizon-2012.1.1.orig/horizon/dashboards/nova/instances_and_volumes/tests.py horizon-2012.1.1/horizon/dashboards/nova/instances_and_volumes/tests.py
--- horizon-2012.1.1.orig/horizon/dashboards/nova/instances_and_volumes/tests.py	2012-09-17 14:42:01.691620470 +0200
+++ horizon-2012.1.1/horizon/dashboards/nova/instances_and_volumes/tests.py	2012-09-17 14:43:11.002618777 +0200
@@ -18,7 +18,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from copy import deepcopy
 from django import http
 from django.core.urlresolvers import reverse
 from mox import IsA
@@ -43,50 +42,7 @@
         self.assertTemplateUsed(res,
             'nova/instances_and_volumes/index.html')
         instances = res.context['instances_table'].data
-        volumes = res.context['volumes_table'].data
-
         self.assertItemsEqual(instances, self.servers.list())
-        self.assertItemsEqual(volumes, self.volumes.list())
-
-    def test_attached_volume(self):
-        volumes = deepcopy(self.volumes.list())
-        attached_volume = deepcopy(self.volumes.list()[0])
-        attached_volume.id = "2"
-        attached_volume.display_name = "Volume2 name"
-        attached_volume.size = "80"
-        attached_volume.status = "in-use"
-        attached_volume.attachments = [{"server_id": "1",
-                                        "device": "/dev/hdn"}]
-        volumes.append(attached_volume)
-
-        self.mox.StubOutWithMock(api, 'server_list')
-        self.mox.StubOutWithMock(api, 'volume_list')
-        api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
-        api.volume_list(IsA(http.HttpRequest)).AndReturn(volumes)
-
-        self.mox.ReplayAll()
-
-        res = self.client.get(
-            reverse('horizon:nova:instances_and_volumes:index'))
-
-        self.assertTemplateUsed(res,
-            'nova/instances_and_volumes/index.html')
-        instances = res.context['instances_table'].data
-        resp_volumes = res.context['volumes_table'].data
-
-        self.assertItemsEqual(instances, self.servers.list())
-        self.assertItemsEqual(resp_volumes, volumes)
-
-        self.assertContains(res, ">Volume name<", 1, 200)
-        self.assertContains(res, ">40 GB<", 1, 200)
-        self.assertContains(res, ">Available<", 1, 200)
-
-        self.assertContains(res, ">Volume2 name<", 1, 200)
-        self.assertContains(res, ">80 GB<", 1, 200)
-        self.assertContains(res, ">In-Use<", 1, 200)
-        self.assertContains(res,
-                            ">Instance server_1 (1)</a>&nbsp;on /dev/hdn",
-                            1, 200)
 
     def test_index_server_list_exception(self):
         self.mox.StubOutWithMock(api, 'server_list')
@@ -94,7 +50,6 @@
         exception = novaclient_exceptions.ClientException('apiException')
         api.server_list(IsA(http.HttpRequest)).AndRaise(exception)
         api.volume_list(IsA(http.HttpRequest)).AndReturn(self.volumes.list())
-        api.server_list(IsA(http.HttpRequest)).AndReturn(self.servers.list())
 
         self.mox.ReplayAll()
 
diff -urN horizon-2012.1.1.orig/horizon/dashboards/nova/instances_and_volumes/views.py horizon-2012.1.1/horizon/dashboards/nova/instances_and_volumes/views.py
--- horizon-2012.1.1.orig/horizon/dashboards/nova/instances_and_volumes/views.py	2012-09-17 14:42:01.690620470 +0200
+++ horizon-2012.1.1/horizon/dashboards/nova/instances_and_volumes/views.py	2012-09-17 14:44:19.782617090 +0200
@@ -46,7 +46,7 @@
     def get_instances_data(self):
         # Gather our instances
         try:
-            instances = self._get_instances()
+            instances = api.server_list(self.request)
         except:
             instances = []
             exceptions.handle(self.request, _('Unable to retrieve instances.'))
@@ -67,18 +67,8 @@
         # Gather our volumes
         try:
             volumes = api.volume_list(self.request)
-            instances = SortedDict([(inst.id, inst) for inst in
-                                    self._get_instances()])
-            for volume in volumes:
-                for att in volume.attachments:
-                    att['instance'] = instances[att['server_id']]
         except novaclient_exceptions.ClientException, e:
             volumes = []
             LOG.exception("ClientException in volume index")
             messages.error(self.request, _('Unable to fetch volumes: %s') % e)
         return volumes
-
-    def _get_instances(self):
-        if not hasattr(self, "_instances_list"):
-            self._instances_list = api.server_list(self.request)
-        return self._instances_list
diff -urN horizon-2012.1.1.orig/horizon/dashboards/nova/instances_and_volumes/volumes/tables.py horizon-2012.1.1/horizon/dashboards/nova/instances_and_volumes/volumes/tables.py
--- horizon-2012.1.1.orig/horizon/dashboards/nova/instances_and_volumes/volumes/tables.py	2012-09-17 14:42:01.691620470 +0200
+++ horizon-2012.1.1/horizon/dashboards/nova/instances_and_volumes/volumes/tables.py	2012-09-17 14:45:45.039615013 +0200
@@ -85,16 +85,16 @@
 
 def get_attachment(volume):
     attachments = []
-    link = '<a href="%(url)s">Instance %(name)s (%(instance)s)</a>&nbsp;' \
-           'on %(dev)s'
+    link = '<a href="%(url)s">Instance %(instance)s&nbsp;' \
+           '<small>(%(dev)s)</small></a>'
     # Filter out "empty" attachments which the client returns...
     for attachment in [att for att in volume.attachments if att]:
         url = reverse("%s:instances:detail" % URL_PREFIX,
                       args=(attachment["server_id"],))
         # TODO(jake): Make "instance" the instance name
         vals = {"url": url,
-                "name": attachment["instance"].name,
-                "instance": attachment["server_id"],
+                
+		"instance": attachment["server_id"],
                 "dev": attachment["device"]}
         attachments.append(link % vals)
     return safestring.mark_safe(", ".join(attachments))