~ubuntu-branches/ubuntu/trusty/horizon/trusty-updates

« back to all changes in this revision

Viewing changes to openstack_dashboard/dashboards/admin/info/tabs.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-03-06 16:53:28 UTC
  • mfrom: (1.1.37)
  • Revision ID: package-import@ubuntu.com-20140306165328-w2vgmtfriqlhp27m
Tags: 1:2014.1~b3-0ubuntu1
* New upstream milestone release.
* d/static/*: Refreshed assets for new upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
1
# Copyright 2012 Nebula, Inc.
4
2
#
5
3
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
24
22
from openstack_dashboard.api import neutron
25
23
from openstack_dashboard.api import nova
26
24
 
 
25
from openstack_dashboard.dashboards.admin.info import constants
27
26
from openstack_dashboard.dashboards.admin.info import tables
28
27
 
29
28
 
31
30
    table_classes = (tables.ServicesTable,)
32
31
    name = _("Services")
33
32
    slug = "services"
34
 
    template_name = ("horizon/common/_detail_table.html")
 
33
    template_name = constants.INFO_DETAIL_TEMPLATE_NAME
35
34
 
36
35
    def get_services_data(self):
37
36
        request = self.tab_group.request
43
42
        return services
44
43
 
45
44
 
46
 
class ZonesTab(tabs.TableTab):
47
 
    table_classes = (tables.ZonesTable,)
48
 
    name = _("Availability Zones")
49
 
    slug = "zones"
50
 
    template_name = ("horizon/common/_detail_table.html")
51
 
 
52
 
    def get_zones_data(self):
53
 
        request = self.tab_group.request
54
 
        zones = []
55
 
        try:
56
 
            zones = nova.availability_zone_list(request, detailed=True)
57
 
        except Exception:
58
 
            msg = _('Unable to retrieve availability zone data.')
59
 
            exceptions.handle(request, msg)
60
 
        return zones
61
 
 
62
 
 
63
 
class HostAggregatesTab(tabs.TableTab):
64
 
    table_classes = (tables.AggregatesTable,)
65
 
    name = _("Host Aggregates")
66
 
    slug = "aggregates"
67
 
    template_name = ("horizon/common/_detail_table.html")
68
 
 
69
 
    def get_aggregates_data(self):
70
 
        aggregates = []
71
 
        try:
72
 
            aggregates = nova.aggregate_list(self.tab_group.request)
73
 
        except Exception:
74
 
            exceptions.handle(self.request,
75
 
                _('Unable to retrieve host aggregates list.'))
76
 
        return aggregates
77
 
 
78
 
 
79
45
class NovaServicesTab(tabs.TableTab):
80
46
    table_classes = (tables.NovaServicesTable,)
81
47
    name = _("Compute Services")
82
48
    slug = "nova_services"
83
 
    template_name = ("horizon/common/_detail_table.html")
 
49
    template_name = constants.INFO_DETAIL_TEMPLATE_NAME
84
50
 
85
51
    def get_nova_services_data(self):
86
52
        try:
87
53
            services = nova.service_list(self.tab_group.request)
88
54
        except Exception:
89
 
            services = []
90
55
            msg = _('Unable to get nova services list.')
91
56
            exceptions.check_message(["Connection", "refused"], msg)
92
57
            raise
98
63
    table_classes = (tables.NetworkAgentsTable,)
99
64
    name = _("Network Agents")
100
65
    slug = "network_agents"
101
 
    template_name = ("horizon/common/_detail_table.html")
 
66
    template_name = constants.INFO_DETAIL_TEMPLATE_NAME
102
67
 
103
68
    def allowed(self, request):
104
69
        return base.is_service_enabled(request, 'network')
107
72
        try:
108
73
            agents = neutron.agent_list(self.tab_group.request)
109
74
        except Exception:
110
 
            agents = []
111
75
            msg = _('Unable to get network agents list.')
112
76
            exceptions.check_message(["Connection", "refused"], msg)
113
77
            raise
118
82
class SystemInfoTabs(tabs.TabGroup):
119
83
    slug = "system_info"
120
84
    tabs = (ServicesTab, NovaServicesTab,
121
 
            ZonesTab, HostAggregatesTab,
122
85
            NetworkAgentsTab)
123
86
    sticky = True