Improve system info page

This change adds region info and all the url types,
and also removes enabled (which never did anything).

Change-Id: I7594d2b3d1e9826ec66bac379059171150155c4b
Closes-bug: #1497448
This commit is contained in:
eric 2015-09-18 15:21:09 -06:00 committed by Eric Peterson
parent 91443dfda1
commit 5934d83b04
6 changed files with 71 additions and 30 deletions

View File

@ -53,29 +53,38 @@ class SubServiceFilterAction(ServiceFilterAction):
filter_field = 'binary' filter_field = 'binary'
def get_status(service): def show_endpoints(datanum):
# if not configured in this region, neither option makes sense if 'endpoints' in datanum:
if service.host: template_name = 'admin/info/_cell_endpoints_v2.html'
return SERVICE_ENABLED if not service.disabled else SERVICE_DISABLED context = None
if (len(datanum['endpoints']) > 0 and
"publicURL" in datanum['endpoints'][0]):
context = datanum['endpoints'][0]
else:
# this is a keystone v3 version of endpoints
template_name = 'admin/info/_cell_endpoints_v3.html'
context = {'endpoints': datanum['endpoints']}
return template.loader.render_to_string(template_name,
context)
return None return None
class ServicesTable(tables.DataTable): class ServicesTable(tables.DataTable):
id = tables.Column('id', hidden=True) id = tables.Column('id', hidden=True)
name = tables.Column("name", verbose_name=_('Name')) name = tables.Column("name", verbose_name=_('Name'))
service_type = tables.Column('__unicode__', verbose_name=_('Service')) service_type = tables.Column('type', verbose_name=_('Service'))
host = tables.Column('host', verbose_name=_('Host')) region = tables.Column('region', verbose_name=_('Region'))
status = tables.Column(get_status, endpoints = tables.Column(show_endpoints, verbose_name=_('Endpoints'))
verbose_name=_('Status'),
status=True, def get_object_id(self, datum):
display_choices=SERVICE_STATUS_DISPLAY_CHOICES) # this method is need b/c the parent impl does not handle dicts
return datum.get('id')
class Meta(object): class Meta(object):
name = "services" name = "services"
verbose_name = _("Services") verbose_name = _("Services")
table_actions = (ServiceFilterAction,) table_actions = (ServiceFilterAction,)
multi_select = False multi_select = False
status_columns = ["status"]
def get_available(zone): def get_available(zone):

View File

@ -19,7 +19,6 @@ from horizon import tabs
from openstack_dashboard.api import base from openstack_dashboard.api import base
from openstack_dashboard.api import cinder from openstack_dashboard.api import cinder
from openstack_dashboard.api import heat from openstack_dashboard.api import heat
from openstack_dashboard.api import keystone
from openstack_dashboard.api import neutron from openstack_dashboard.api import neutron
from openstack_dashboard.api import nova from openstack_dashboard.api import nova
from openstack_dashboard.dashboards.admin.info import constants from openstack_dashboard.dashboards.admin.info import constants
@ -32,13 +31,27 @@ class ServicesTab(tabs.TableTab):
slug = tables.ServicesTable.Meta.name slug = tables.ServicesTable.Meta.name
template_name = constants.INFO_DETAIL_TEMPLATE_NAME template_name = constants.INFO_DETAIL_TEMPLATE_NAME
def generate_catalog_endpoints(self, catalog):
for i, service in enumerate(catalog):
regions = set(endpoint['region'] for endpoint
in service['endpoints'])
for region in regions:
endpoints = [endpoint for endpoint
in service['endpoints']
if endpoint['region'] == region]
# sort the endpoints, so they appear in consistent order
endpoints.sort(key=lambda endpoint: endpoint.get('interface'))
yield {'id': service['name'] + region,
'name': service['name'],
'type': service['type'],
'region': region,
'endpoints': endpoints,
}
def get_services_data(self): def get_services_data(self):
request = self.tab_group.request request = self.tab_group.request
services = [] catalog = request.user.service_catalog
for i, service in enumerate(request.user.service_catalog): services = list(self.generate_catalog_endpoints(catalog))
service['id'] = i
services.append(
keystone.Service(service, request.user.services_region))
return services return services

View File

@ -0,0 +1,9 @@
{% load i18n %}
<dl class="dl-horizontal">
<dt title="{% trans "Admin URL:" %}">{% trans "Admin URL:" %}</dt>
<dd>{{ adminURL }}</dd>
<dt title="{% trans "Internal URL:" %}">{% trans "Internal URL:" %}</dt>
<dd>{{ internalURL }}</dd>
<dt title="{% trans "Public URL:" %}">{% trans "Public URL:" %}</dt>
<dd>{{ publicURL }}</dd>
</dl>

View File

@ -0,0 +1,6 @@
<dl class="dl-horizontal">
{% for endpoint in endpoints %}
<dt title="{{ endpoint.interface|title }}">{{ endpoint.interface|title }}</dt>
<dd>{{ endpoint.url }}</dd>
{% endfor %}
</dl>

View File

@ -60,19 +60,9 @@ class SystemInfoViewTests(test.BaseAdminViewTests):
def test_index(self): def test_index(self):
res = self._test_base_index() res = self._test_base_index()
services_tab = res.context['tab_group'].get_tab('services') services_tab = res.context['tab_group'].get_tab('services')
self.assertQuerysetEqual( self.assertTrue("region" in services_tab._tables['services'].data[0])
services_tab._tables['services'].data, self.assertTrue("endpoints" in
['<Service: compute>', services_tab._tables['services'].data[0])
'<Service: volumev2>',
'<Service: image>',
'<Service: identity (native backend)>',
'<Service: object-store>',
'<Service: network>',
'<Service: ec2>',
'<Service: metering>',
'<Service: orchestration>',
])
self.mox.VerifyAll() self.mox.VerifyAll()
def test_neutron_index(self): def test_neutron_index(self):

View File

@ -51,6 +51,19 @@
.normal_column ul { .normal_column ul {
padding: 0; padding: 0;
} }
.dl-horizontal {
margin-bottom: 0;
@media (min-width: $grid-float-breakpoint) {
dt {
width: (($dl-horizontal-offset/2) - 20);
}
dd {
margin-left: $dl-horizontal-offset/2;
}
}
}
} }
// Sometimes the header is empty, lets keep the same look either way // Sometimes the header is empty, lets keep the same look either way
@ -145,3 +158,4 @@
.status_unknown .horizon-pending-bar-icon { .status_unknown .horizon-pending-bar-icon {
color: $text-color; color: $text-color;
} }