diff --git a/horizon/dashboards/nova/instances_and_volumes/instances/tests.py b/horizon/dashboards/nova/instances_and_volumes/instances/tests.py index e34af39e0..8ad7eaa05 100644 --- a/horizon/dashboards/nova/instances_and_volumes/instances/tests.py +++ b/horizon/dashboards/nova/instances_and_volumes/instances/tests.py @@ -274,6 +274,38 @@ class InstanceViewTests(test.TestCase): self.assertEquals(res.context['instance'].volumes[1].device, "/dev/hdk") + @test.create_stubs({api: ("server_get", "volume_instance_list", + "flavor_get", "server_security_groups")}) + def test_instance_details_metadata(self): + server = self.servers.first() + + api.server_get(IsA(http.HttpRequest), server.id).AndReturn(server) + api.volume_instance_list(IsA(http.HttpRequest), + server.id).AndReturn([]) + api.flavor_get(IsA(http.HttpRequest), + server.flavor['id']).AndReturn(self.flavors.first()) + api.server_security_groups(IsA(http.HttpRequest), + server.id).AndReturn(self.security_groups.list()) + + self.mox.ReplayAll() + + url = reverse('horizon:nova:instances_and_volumes:instances:detail', + args=[server.id]) + tg = InstanceDetailTabs(self.request, instance=server) + qs = "?%s=%s" % (tg.param_name, tg.get_tab("overview").get_id()) + res = self.client.get(url + qs) + # Key name + self.assertContains(res, "
keyName
", 1) + # Meta data + self.assertContains(res, "
someMetaLabel
", 1) + self.assertContains(res, "
someMetaData
", 1) + # Test escaping of html characters in names + self.assertContains(res, "
some<b>html</b>label
", + 1) + self.assertContains(res, "
<!--
", 1) + self.assertContains(res, "
empty
", 1) + self.assertContains(res, "
N/A
", 1) + def test_instance_log(self): server = self.servers.first() CONSOLE_OUTPUT = 'output' 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 d4abd3aaf..6cc5ac704 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 @@ -67,10 +67,14 @@
{% trans "Key Name" %}
-
{% if instance.key_name %}{{ instance.key_name }}{% else %}None{% endif %}
+
{{ instance.key_name|default:"None" }}
{% url horizon:nova:images_and_snapshots:images:detail instance.image.id as image_url %}
{% trans "Image Name" %}
{{ instance.image_name }}
+ {% for key, value in instance.metadata.items %} +
{{ key|force_escape }}
+
{{ value|force_escape|default:"N/A" }}
+ {% endfor%}
diff --git a/horizon/tests/test_data/nova_data.py b/horizon/tests/test_data/nova_data.py index c55fad996..8889d58a6 100644 --- a/horizon/tests/test_data/nova_data.py +++ b/horizon/tests/test_data/nova_data.py @@ -81,7 +81,9 @@ SERVER_DATA = """ "name": "%(name)s", "created": "2012-02-28T19:51:17Z", "tenant_id": "%(tenant_id)s", - "metadata": {} + "metadata": {"someMetaLabel": "someMetaData", + "somehtmllabel": "