From bb1e7e6a5a3f0517ed8178a2572783eeaee17434 Mon Sep 17 00:00:00 2001 From: Tihomir Trifonov Date: Sun, 1 Apr 2012 12:04:13 +0300 Subject: [PATCH] volume.volumeId property used wrongly as .volume_id Fixes bug 969162 Also, the created_at property was used as createdAt, which lead to object reloading during template render due to missing prop. See bug desc for more details. Also, in the volume details template, the url link for instance details was wrong - it was the link for volume details instead. Fixes Bug 971150 Change-Id: If5cfd515d0726a9ab85021b904a53e94b80205ea --- .../nova/instances_and_volumes/instances/views.py | 8 ++------ .../nova/instances_and_volumes/volumes/tests.py | 11 ++++++++++- .../instances/_detail_overview.html | 4 ++-- .../volumes/_detail_overview.html | 10 +++++----- horizon/tests/test_data/nova_data.py | 3 ++- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/horizon/dashboards/nova/instances_and_volumes/instances/views.py b/horizon/dashboards/nova/instances_and_volumes/instances/views.py index e48b58591..79f74b6dc 100644 --- a/horizon/dashboards/nova/instances_and_volumes/instances/views.py +++ b/horizon/dashboards/nova/instances_and_volumes/instances/views.py @@ -103,12 +103,8 @@ class DetailView(tabs.TabView): instance = api.server_get(self.request, instance_id) instance.volumes = api.volume_instance_list(self.request, instance_id) - # Gather our flavors and images and correlate our instances to - # them. Exception handling happens in the parent class. - flavors = api.flavor_list(self.request) - full_flavors = SortedDict([(str(flavor.id), flavor) for \ - flavor in flavors]) - instance.full_flavor = full_flavors[instance.flavor["id"]] + instance.full_flavor = api.flavor_get(self.request, + instance.flavor["id"]) instance.security_groups = api.server_security_groups( self.request, instance_id) except: diff --git a/horizon/dashboards/nova/instances_and_volumes/volumes/tests.py b/horizon/dashboards/nova/instances_and_volumes/volumes/tests.py index b6bf901ec..9f4807cfe 100644 --- a/horizon/dashboards/nova/instances_and_volumes/volumes/tests.py +++ b/horizon/dashboards/nova/instances_and_volumes/volumes/tests.py @@ -59,5 +59,14 @@ class VolumeViewTests(test.TestCase): url = reverse('horizon:nova:instances_and_volumes:volumes:detail', args=[volume.id]) res = self.client.get(url) - self.assertEqual(res.status_code, 200) + + self.assertContains(res, "
Volume name
", 1, 200) + self.assertContains(res, "
1
", 1, 200) + self.assertContains(res, "
Available
", 1, 200) + self.assertContains(res, "
40 GB
", 1, 200) + self.assertContains(res, "
04/01/12 at 10:30:00
", 1, 200) + self.assertContains(res, "Instance server_1 " + "(1)", 1, 200) + self.assertNoMessages() diff --git a/horizon/dashboards/nova/templates/nova/instances_and_volumes/instances/_detail_overview.html b/horizon/dashboards/nova/templates/nova/instances_and_volumes/instances/_detail_overview.html index 759649f47..aacb429be 100644 --- a/horizon/dashboards/nova/templates/nova/instances_and_volumes/instances/_detail_overview.html +++ b/horizon/dashboards/nova/templates/nova/instances_and_volumes/instances/_detail_overview.html @@ -82,8 +82,8 @@ {% for volume in instance.volumes %}
{% trans "Volume" %}
- - {{ volume.volume_id }} ({{ volume.device }}) + + {{ volume.volumeId }} ({{ volume.device }})
{% endfor %} diff --git a/horizon/dashboards/nova/templates/nova/instances_and_volumes/volumes/_detail_overview.html b/horizon/dashboards/nova/templates/nova/instances_and_volumes/volumes/_detail_overview.html index b1adf6bab..c3d78db7f 100644 --- a/horizon/dashboards/nova/templates/nova/instances_and_volumes/volumes/_detail_overview.html +++ b/horizon/dashboards/nova/templates/nova/instances_and_volumes/volumes/_detail_overview.html @@ -9,7 +9,7 @@
{% trans "Name" %}
{{ volume.display_name }}
{% trans "ID" %}
-
{{ volume.id }} +
{{ volume.id }}
{% if volume.display_description %}
{% trans "Description" %}
{{ volume.display_description }}
@@ -26,7 +26,7 @@
{% trans "Size" %}
{{ volume.size }} {% trans "GB" %}
{% trans "Created" %}
-
{{ volume.createdAt|parse_date }}
+
{{ volume.created_at|parse_date }}
@@ -37,9 +37,9 @@
{% trans "Attached To" %}
- {% url horizon:nova:instances_and_volumes:volumes:detail attachment.server_id as instance_url%} - {% trans "Instance" %} {{ attachment.instance.id }} ({{ attachment.instance.name }}) - {% trans "on" %} {{ attachment.device }} + {% url horizon:nova:instances_and_volumes:instances:detail attachment.server_id as instance_url%} + {% trans "Instance" %} {{ attachment.instance.name }} ({{ attachment.instance.id }}) + {% trans "on" %} {{ attachment.device }}
{% empty %} diff --git a/horizon/tests/test_data/nova_data.py b/horizon/tests/test_data/nova_data.py index 2f9afc60b..dd6de1fe4 100644 --- a/horizon/tests/test_data/nova_data.py +++ b/horizon/tests/test_data/nova_data.py @@ -148,7 +148,8 @@ def data(TEST): name='test_volume', status='available', size=40, - display_name='', + display_name='Volume name', + created_at='2012-04-01 10:30:00', attachments={})) TEST.volumes.add(volume)