~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): Adam Gandelman
  • Date: 2013-09-06 11:59:43 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20130906115943-h3td0l7tp16mb9oc
Tags: 1:2013.2~b3-0ubuntu1
* New upstream release.
* debian/control: Minimum python-openstack-auth version >= 1.1.1.
* debian/control: Add python-troveclient.
* debian/static: Refresh static assets for 2013.2~b3.
* debian/patches: ubuntu_local_settings.patch -> ubuntu_settings.patch, also
  patch location of secret key in openstack_dashboard/settings.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#    License for the specific language governing permissions and limitations
15
15
#    under the License.
16
16
 
17
 
from django.utils.translation import ugettext_lazy as _
 
17
from django.utils.translation import ugettext_lazy as _  # noqa
18
18
 
19
19
from horizon import exceptions
20
20
from horizon import tabs
21
21
 
 
22
from openstack_dashboard.api import base
22
23
from openstack_dashboard.api import keystone
23
 
from openstack_dashboard.usage import quotas
24
 
 
25
 
from openstack_dashboard.dashboards.admin.info.tables import QuotasTable
26
 
from openstack_dashboard.dashboards.admin.info.tables import ServicesTable
27
 
 
28
 
 
29
 
class DefaultQuotasTab(tabs.TableTab):
30
 
    table_classes = (QuotasTable,)
31
 
    name = _("Default Quotas")
32
 
    slug = "quotas"
33
 
    template_name = ("horizon/common/_detail_table.html")
34
 
 
35
 
    def get_quotas_data(self):
36
 
        request = self.tab_group.request
37
 
        try:
38
 
            quota_set = quotas.get_default_quota_data(request)
39
 
            data = quota_set.items
40
 
        except:
41
 
            data = []
42
 
            exceptions.handle(self.request, _('Unable to get quota info.'))
43
 
        return data
 
24
from openstack_dashboard.api import neutron
 
25
from openstack_dashboard.api import nova
 
26
 
 
27
from openstack_dashboard.dashboards.admin.info import tables
44
28
 
45
29
 
46
30
class ServicesTab(tabs.TableTab):
47
 
    table_classes = (ServicesTable,)
 
31
    table_classes = (tables.ServicesTable,)
48
32
    name = _("Services")
49
33
    slug = "services"
50
34
    template_name = ("horizon/common/_detail_table.html")
59
43
        return services
60
44
 
61
45
 
 
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
class NovaServicesTab(tabs.TableTab):
 
80
    table_classes = (tables.NovaServicesTable,)
 
81
    name = _("Compute Services")
 
82
    slug = "nova_services"
 
83
    template_name = ("horizon/common/_detail_table.html")
 
84
 
 
85
    def get_nova_services_data(self):
 
86
        try:
 
87
            services = nova.service_list(self.tab_group.request)
 
88
        except Exception:
 
89
            services = []
 
90
            msg = _('Unable to get nova services list.')
 
91
            exceptions.check_message(["Connection", "refused"], msg)
 
92
            raise
 
93
 
 
94
        return services
 
95
 
 
96
 
 
97
class NetworkAgentsTab(tabs.TableTab):
 
98
    table_classes = (tables.NetworkAgentsTable,)
 
99
    name = _("Network Agents")
 
100
    slug = "network_agents"
 
101
    template_name = ("horizon/common/_detail_table.html")
 
102
 
 
103
    def allowed(self, request):
 
104
        return base.is_service_enabled(request, 'network')
 
105
 
 
106
    def get_network_agents_data(self):
 
107
        try:
 
108
            agents = neutron.agent_list(self.tab_group.request)
 
109
        except Exception:
 
110
            agents = []
 
111
            msg = _('Unable to get network agents list.')
 
112
            exceptions.check_message(["Connection", "refused"], msg)
 
113
            raise
 
114
 
 
115
        return agents
 
116
 
 
117
 
62
118
class SystemInfoTabs(tabs.TabGroup):
63
119
    slug = "system_info"
64
 
    tabs = (ServicesTab, DefaultQuotasTab,)
 
120
    tabs = (ServicesTab, NovaServicesTab,
 
121
            ZonesTab, HostAggregatesTab,
 
122
            NetworkAgentsTab)
65
123
    sticky = True