1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tables
from horizon import tabs
from openstack_dashboard import api
from openstack_dashboard.dashboards.infrastructure. \
resource_management.nodes.tables import UnrackedNodesTable
from openstack_dashboard.dashboards.infrastructure. \
resource_management.nodes.tabs import NodeDetailTabs
class UnrackedView(tables.DataTableView):
table_class = UnrackedNodesTable
template_name = 'infrastructure/resource_management/nodes/unracked.html'
def get_data(self):
try:
nodes = api.tuskar.Node.list_unracked(self.request)
except:
nodes = []
exceptions.handle(self.request,
_('Unable to retrieve nodes.'))
return nodes
class DetailView(tabs.TabView):
tab_group_class = NodeDetailTabs
template_name = 'infrastructure/resource_management/nodes/detail.html'
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
context["node"] = self.get_data()
return context
def get_data(self):
if not hasattr(self, "_node"):
try:
node_id = self.kwargs['node_id']
node = api.tuskar.Node.get(self.request, node_id)
except:
redirect = reverse('horizon:infrastructure:'
'resource_management:index')
exceptions.handle(self.request,
_('Unable to retrieve details for '
'node "%s".')
% node_id,
redirect=redirect)
self._node = node
return self._node
def get_tabs(self, request, *args, **kwargs):
node = self.get_data()
return self.tab_group_class(request, node=node,
**kwargs)
|