14
14
# License for the specific language governing permissions and limitations
15
15
# under the License.
17
from django.utils.translation import ugettext_lazy as _
17
from django.utils.translation import ugettext_lazy as _ # noqa
19
19
from horizon import exceptions
20
20
from horizon import tabs
22
from openstack_dashboard.api import base
22
23
from openstack_dashboard.api import keystone
23
from openstack_dashboard.usage import quotas
25
from openstack_dashboard.dashboards.admin.info.tables import QuotasTable
26
from openstack_dashboard.dashboards.admin.info.tables import ServicesTable
29
class DefaultQuotasTab(tabs.TableTab):
30
table_classes = (QuotasTable,)
31
name = _("Default Quotas")
33
template_name = ("horizon/common/_detail_table.html")
35
def get_quotas_data(self):
36
request = self.tab_group.request
38
quota_set = quotas.get_default_quota_data(request)
39
data = quota_set.items
42
exceptions.handle(self.request, _('Unable to get quota info.'))
24
from openstack_dashboard.api import neutron
25
from openstack_dashboard.api import nova
27
from openstack_dashboard.dashboards.admin.info import tables
46
30
class ServicesTab(tabs.TableTab):
47
table_classes = (ServicesTable,)
31
table_classes = (tables.ServicesTable,)
48
32
name = _("Services")
50
34
template_name = ("horizon/common/_detail_table.html")
46
class ZonesTab(tabs.TableTab):
47
table_classes = (tables.ZonesTable,)
48
name = _("Availability Zones")
50
template_name = ("horizon/common/_detail_table.html")
52
def get_zones_data(self):
53
request = self.tab_group.request
56
zones = nova.availability_zone_list(request, detailed=True)
58
msg = _('Unable to retrieve availability zone data.')
59
exceptions.handle(request, msg)
63
class HostAggregatesTab(tabs.TableTab):
64
table_classes = (tables.AggregatesTable,)
65
name = _("Host Aggregates")
67
template_name = ("horizon/common/_detail_table.html")
69
def get_aggregates_data(self):
72
aggregates = nova.aggregate_list(self.tab_group.request)
74
exceptions.handle(self.request,
75
_('Unable to retrieve host aggregates list.'))
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")
85
def get_nova_services_data(self):
87
services = nova.service_list(self.tab_group.request)
90
msg = _('Unable to get nova services list.')
91
exceptions.check_message(["Connection", "refused"], msg)
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")
103
def allowed(self, request):
104
return base.is_service_enabled(request, 'network')
106
def get_network_agents_data(self):
108
agents = neutron.agent_list(self.tab_group.request)
111
msg = _('Unable to get network agents list.')
112
exceptions.check_message(["Connection", "refused"], msg)
62
118
class SystemInfoTabs(tabs.TabGroup):
63
119
slug = "system_info"
64
tabs = (ServicesTab, DefaultQuotasTab,)
120
tabs = (ServicesTab, NovaServicesTab,
121
ZonesTab, HostAggregatesTab,