Correcting heat resource drill down
Previous commit broken heat resource drill down:
f38ddf2032 (diff-15e3003726d7b90816528ee8248b000f)
This patch fixes the ID attribute, correctly specifies the template,
alters the page to match other detail page styles, and adds a UT to
prevent regression.
Change-Id: Ie3f76d6666f4e3154fbcb5808c8f8b841e650a02
Co-Authored-By: Rob Cresswell <robert.cresswell@outlook.com>
Closes-bug: #1531341
This commit is contained in:
parent
4e6ef55229
commit
d69fe09bc7
@ -1,15 +1,9 @@
|
||||
{% load i18n sizeformat %}
|
||||
|
||||
<h3>{% trans "Resource Overview" %}</h3>
|
||||
|
||||
<div class="info row detail">
|
||||
<h4>{% trans "Information" %}</h4>
|
||||
<hr class="header_rule">
|
||||
<div class="detail">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>{% trans "Stack Resource ID" %}</dt>
|
||||
<dd>{{ resource.resource_name }}</dd>
|
||||
</dl>
|
||||
<dl class="dl-horizontal">
|
||||
<dt>{% trans "Resource ID" %}</dt>
|
||||
<dd>
|
||||
{% if resource_url %}
|
||||
@ -20,18 +14,12 @@
|
||||
{{ resource.physical_resource_id }}
|
||||
{% endif %}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="dl-horizontal">
|
||||
<dt>{% trans "Stack Resource Type" %}</dt>
|
||||
<dd>{{ resource.resource_type }}</dd>
|
||||
</dl>
|
||||
<dl class="dl-horizontal">
|
||||
<dt>{% trans "Description" %}</dt>
|
||||
<dd>{{ resource.description }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="status row detail">
|
||||
<h4>{% trans "Status" %}</h4>
|
||||
<hr class="header_rule">
|
||||
<dl class="dl-horizontal">
|
||||
@ -42,9 +30,7 @@
|
||||
{% blocktrans with resource_status=resource.resource_status|title|replace_underscores resource_status_reason=resource.resource_status_reason %}{{ resource_status }}: {{ resource_status_reason }}{% endblocktrans %}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="status row detail">
|
||||
<h4>{% trans "Resource Metadata" %}</h4>
|
||||
<hr class="header_rule">
|
||||
<pre>{{ metadata }}
|
||||
|
@ -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):
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user