summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project/stacks/tabs.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstack_dashboard/dashboards/project/stacks/tabs.py')
-rw-r--r--openstack_dashboard/dashboards/project/stacks/tabs.py173
1 files changed, 0 insertions, 173 deletions
diff --git a/openstack_dashboard/dashboards/project/stacks/tabs.py b/openstack_dashboard/dashboards/project/stacks/tabs.py
deleted file mode 100644
index 1e6c92b..0000000
--- a/openstack_dashboard/dashboards/project/stacks/tabs.py
+++ /dev/null
@@ -1,173 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13import logging
14
15from django.utils.translation import ugettext_lazy as _
16
17from horizon import messages
18from horizon import tabs
19from openstack_dashboard import api
20from openstack_dashboard import policy
21
22from openstack_dashboard.dashboards.project.stacks \
23 import api as project_api
24from openstack_dashboard.dashboards.project.stacks import mappings
25from openstack_dashboard.dashboards.project.stacks \
26 import tables as project_tables
27
28
29LOG = logging.getLogger(__name__)
30
31
32class StackTopologyTab(tabs.Tab):
33 name = _("Topology")
34 slug = "topology"
35 template_name = "project/stacks/_detail_topology.html"
36 preload = False
37
38 def allowed(self, request):
39 return policy.check(
40 (("orchestration", "stacks:template"),
41 ("orchestration", "stacks:lookup"),
42 ("orchestration", "stacks:show"),
43 ("orchestration", "resource:index"),),
44 request)
45
46 def get_context_data(self, request):
47 context = {}
48 stack = self.tab_group.kwargs['stack']
49 context['stack_id'] = stack.id
50 context['d3_data'] = project_api.d3_data(request, stack_id=stack.id)
51 return context
52
53
54class StackOverviewTab(tabs.Tab):
55 name = _("Overview")
56 slug = "overview"
57 template_name = "project/stacks/_detail_overview.html"
58
59 def allowed(self, request):
60 return policy.check(
61 (("orchestration", "stacks:template"),
62 ("orchestration", "stacks:lookup"),
63 ("orchestration", "stacks:show"),),
64 request)
65
66 def get_context_data(self, request):
67 return {"stack": self.tab_group.kwargs['stack']}
68
69
70class ResourceOverviewTab(tabs.Tab):
71 name = _("Overview")
72 slug = "resource_overview"
73 template_name = "project/stacks/_resource_overview.html"
74
75 def get_context_data(self, request):
76 resource = self.tab_group.kwargs['resource']
77 resource_url = mappings.resource_to_url(resource)
78 return {
79 "resource": resource,
80 "resource_url": resource_url,
81 "metadata": self.tab_group.kwargs['metadata']}
82
83
84class StackEventsTab(tabs.Tab):
85 name = _("Events")
86 slug = "events"
87 template_name = "project/stacks/_detail_events.html"
88 preload = False
89
90 def allowed(self, request):
91 return policy.check(
92 (("orchestration", "stacks:template"),
93 ("orchestration", "stacks:lookup"),
94 ("orchestration", "stacks:show"),
95 ("orchestration", "events:index"),),
96 request)
97
98 def get_context_data(self, request):
99 stack = self.tab_group.kwargs['stack']
100 try:
101 stack_identifier = '%s/%s' % (stack.stack_name, stack.id)
102 events = api.heat.events_list(self.request, stack_identifier)
103 LOG.debug('got events %s', events)
104 # The stack id is needed to generate the resource URL.
105 for event in events:
106 event.stack_id = stack.id
107 except Exception:
108 events = []
109 messages.error(request, _(
110 'Unable to get events for stack "%s".') % stack.stack_name)
111 return {"stack": stack,
112 "table": project_tables.EventsTable(request, data=events), }
113
114
115class StackResourcesTab(tabs.Tab):
116 name = _("Resources")
117 slug = "resources"
118 template_name = "project/stacks/_detail_resources.html"
119 preload = False
120
121 def allowed(self, request):
122 return policy.check(
123 (("orchestration", "stacks:template"),
124 ("orchestration", "stacks:lookup"),
125 ("orchestration", "stacks:show"),
126 ("orchestration", "resource:index"),),
127 request)
128
129 def get_context_data(self, request):
130 stack = self.tab_group.kwargs['stack']
131 try:
132 stack_identifier = '%s/%s' % (stack.stack_name, stack.id)
133 resources = api.heat.resources_list(self.request, stack_identifier)
134 LOG.debug('got resources %s', resources)
135 # The stack id is needed to generate the resource URL.
136 for r in resources:
137 r.stack_id = stack.id
138 except Exception:
139 resources = []
140 messages.error(request, _(
141 'Unable to get resources for stack "%s".') % stack.stack_name)
142 return {"stack": stack,
143 "table": project_tables.ResourcesTable(
144 request, data=resources, stack=stack), }
145
146
147class StackTemplateTab(tabs.Tab):
148 name = _("Template")
149 slug = "stack_template"
150 template_name = "project/stacks/_stack_template.html"
151
152 def allowed(self, request):
153 return policy.check(
154 (("orchestration", "stacks:template"),
155 ("orchestration", "stacks:lookup"),
156 ("orchestration", "stacks:show"),),
157 request)
158
159 def get_context_data(self, request):
160 return {"stack_template": self.tab_group.kwargs['stack_template']}
161
162
163class StackDetailTabs(tabs.TabGroup):
164 slug = "stack_details"
165 tabs = (StackTopologyTab, StackOverviewTab, StackResourcesTab,
166 StackEventsTab, StackTemplateTab)
167 sticky = True
168
169
170class ResourceDetailTabs(tabs.TabGroup):
171 slug = "resource_details"
172 tabs = (ResourceOverviewTab,)
173 sticky = True