diff --git a/openstack_dashboard/dashboards/project/stacks/templates/stacks/_resource_overview.html b/openstack_dashboard/dashboards/project/stacks/templates/stacks/_resource_overview.html index 3d39e1a3fc..ef1ca25e5d 100644 --- a/openstack_dashboard/dashboards/project/stacks/templates/stacks/_resource_overview.html +++ b/openstack_dashboard/dashboards/project/stacks/templates/stacks/_resource_overview.html @@ -1,15 +1,9 @@ {% load i18n sizeformat %} -
{{ metadata }} diff --git a/openstack_dashboard/dashboards/project/stacks/tests.py b/openstack_dashboard/dashboards/project/stacks/tests.py index b82850f8d2..fa3d55b42f 100644 --- a/openstack_dashboard/dashboards/project/stacks/tests.py +++ b/openstack_dashboard/dashboards/project/stacks/tests.py @@ -889,6 +889,27 @@ class StackTests(test.TestCase): self.assertIn(json.loads(template.validate)['Description'], template_data) + @test.create_stubs({api.heat: ('resource_get', 'resource_metadata_get')}) + def test_resource_view(self): + stack = self.stacks.first() + resource = self.heat_resources.first() + metadata = {} + api.heat.resource_get( + IsA(http.HttpRequest), stack.id, resource.resource_name) \ + .AndReturn(resource) + api.heat.resource_metadata_get( + IsA(http.HttpRequest), stack.id, resource.resource_name) \ + .AndReturn(metadata) + self.mox.ReplayAll() + + url = reverse('horizon:project:stacks:resource', + args=[stack.id, resource.resource_name]) + res = self.client.get(url) + self.assertTemplateUsed(res, 'horizon/common/_detail.html') + self.assertTemplateUsed(res, 'project/stacks/_resource_overview.html') + self.assertEqual(res.context['resource'].logical_resource_id, + resource.logical_resource_id) + class TemplateFormTests(test.TestCase): diff --git a/openstack_dashboard/dashboards/project/stacks/views.py b/openstack_dashboard/dashboards/project/stacks/views.py index ab031dde32..3275bcae8a 100644 --- a/openstack_dashboard/dashboards/project/stacks/views.py +++ b/openstack_dashboard/dashboards/project/stacks/views.py @@ -314,8 +314,9 @@ class DetailView(tabs.TabView): class ResourceView(tabs.TabView): tab_group_class = project_tabs.ResourceDetailTabs - template_name = 'project/stacks/resource.html' - page_title = "{{ resource.resource_name|default:resource.id }}" + template_name = 'horizon/common/_detail.html' + page_title = "{{ resource.resource_name|"\ + "default:resource.logical_resource_id }}" def get_context_data(self, **kwargs): context = super(ResourceView, self).get_context_data(**kwargs) diff --git a/openstack_dashboard/test/test_data/heat_data.py b/openstack_dashboard/test/test_data/heat_data.py index 110b819615..33893eac34 100644 --- a/openstack_dashboard/test/test_data/heat_data.py +++ b/openstack_dashboard/test/test_data/heat_data.py @@ -11,6 +11,7 @@ # under the License. from heatclient.v1 import resource_types +from heatclient.v1 import resources from heatclient.v1 import services from heatclient.v1 import stacks @@ -337,6 +338,7 @@ def data(TEST): TEST.stack_templates = utils.TestDataContainer() TEST.stack_environments = utils.TestDataContainer() TEST.resource_types = utils.TestDataContainer() + TEST.heat_resources = utils.TestDataContainer() TEST.heat_services = utils.TestDataContainer() # Services @@ -380,8 +382,8 @@ def data(TEST): "links": [{ "href": "http://192.168.1.70:8004/v1/" "051c727ee67040d6a7b7812708485a97/" - "stacks/stack-1211-38/" - "05b4f39f-ea96-4d91-910c-e758c078a089", + "stacks/stack-test{0}/" + "05b4f39f-ea96-4d91-910c-e758c078a089{0}".format(i), "rel": "self" }], "parameters": { @@ -461,3 +463,33 @@ def data(TEST): resource_types.ResourceTypeManager(None), rt['resource_type']) TEST.resource_types.add(r_type) TEST.api_resource_types.add(rt) + + # Resources + resource_1 = resources.Resource(resources.ResourceManager(None), { + "logical_resource_id": "my_resource", + "physical_resource_id": "7b5e29b1-c94d-402d-b69c-df9ac6dfc0ce", + "resource_name": "my_resource", + "links": [ + { + "href": "http://192.168.1.70:8004/v1/" + "051c727ee67040d6a7b7812708485a97/" + "stacks/%s/%s/resources/my_resource" % + (TEST.stacks.first().stack_name, + TEST.stacks.first().id), + "rel": "self" + }, + { + "href": "http://192.168.1.70:8004/v1/" + "051c727ee67040d6a7b7812708485a97/" + "stacks/%s/%s" % + (TEST.stacks.first().stack_name, + TEST.stacks.first().id), + "rel": "stack" + } + ], + "attributes": { + "metadata": {} + } + }) + + TEST.heat_resources.add(resource_1)