summaryrefslogtreecommitdiff
path: root/openstack_dashboard/dashboards/project/stacks/resource_types/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstack_dashboard/dashboards/project/stacks/resource_types/views.py')
-rw-r--r--openstack_dashboard/dashboards/project/stacks/resource_types/views.py78
1 files changed, 0 insertions, 78 deletions
diff --git a/openstack_dashboard/dashboards/project/stacks/resource_types/views.py b/openstack_dashboard/dashboards/project/stacks/resource_types/views.py
deleted file mode 100644
index 8afcdf8..0000000
--- a/openstack_dashboard/dashboards/project/stacks/resource_types/views.py
+++ /dev/null
@@ -1,78 +0,0 @@
1# Licensed under the Apache License, Version 2.0 (the "License");
2# you may not use this file except in compliance with the License.
3# You may obtain 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,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10# implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import yaml
15
16from django.core.urlresolvers import reverse
17from django.utils.translation import ugettext_lazy as _
18
19from horizon import exceptions
20from horizon import tables
21from horizon import tabs
22
23from openstack_dashboard import api
24import openstack_dashboard.dashboards.project.stacks.resource_types.tables \
25 as project_tables
26import openstack_dashboard.dashboards.project.stacks.resource_types.tabs \
27 as project_tabs
28
29
30class ResourceTypesView(tables.DataTableView):
31 table_class = project_tables.ResourceTypesTable
32 page_title = _("Resource Types")
33
34 def get_data(self):
35 try:
36 filters = self.get_filters()
37 if 'name' in filters:
38 filters['name'] = '.*' + filters['name']
39 r_types = sorted(api.heat.resource_types_list(self.request,
40 filters=filters),
41 key=lambda resource: resource.resource_type)
42 except Exception:
43 r_types = []
44 msg = _('Unable to retrieve stack resource types.')
45 exceptions.handle(self.request, msg)
46 return r_types
47
48
49class DetailView(tabs.TabView):
50 tab_group_class = project_tabs.ResourceTypeDetailsTabs
51 template_name = 'horizon/common/_detail.html'
52 page_title = "{{ resource_type }}"
53
54 def get_resource_type(self, request, **kwargs):
55 try:
56 resource_type_overview = api.heat.resource_type_get(
57 request,
58 kwargs['resource_type'])
59 return resource_type_overview
60 except Exception:
61 msg = _('Unable to retrieve resource type details.')
62 exceptions.handle(request, msg, redirect=self.get_redirect_url())
63
64 def get_tabs(self, request, **kwargs):
65 resource_type_overview = self.get_resource_type(request, **kwargs)
66 r_type = resource_type_overview['resource_type']
67 r_type_attributes = resource_type_overview['attributes']
68 r_type_properties = resource_type_overview['properties']
69 return self.tab_group_class(
70 request,
71 rt=r_type,
72 rt_attributes=yaml.safe_dump(r_type_attributes, indent=2),
73 rt_properties=yaml.safe_dump(r_type_properties, indent=2),
74 **kwargs)
75
76 @staticmethod
77 def get_redirect_url():
78 return reverse('horizon:project:stacks.resources:index')