Merge "Add router L3 agent info to info page"

This commit is contained in:
Jenkins 2016-06-01 22:03:32 +00:00 committed by Gerrit Code Review
commit e77bbbc4cc
7 changed files with 69 additions and 4 deletions

View File

@ -1058,6 +1058,12 @@ def list_dhcp_agent_hosting_networks(request, network, **params):
return [Agent(a) for a in agents['agents']]
def list_l3_agent_hosting_router(request, router, **params):
agents = neutronclient(request).list_l3_agent_hosting_routers(router,
**params)
return [Agent(a) for a in agents['agents']]
def add_network_to_dhcp_agent(request, dhcp_agent, network_id):
body = {'network_id': network_id}
return neutronclient(request).add_network_to_dhcp_agent(dhcp_agent, body)

View File

@ -28,6 +28,11 @@ class RouterTests(test.BaseAdminViewTests, r_test.RouterTests):
INDEX_URL = reverse('horizon:%s:routers:index' % DASHBOARD)
DETAIL_PATH = 'horizon:%s:routers:detail' % DASHBOARD
def _get_detail(self, router, extraroute=True):
res = super(RouterTests, self)._get_detail(router, extraroute,
lookup_l3=True)
return res
@test.create_stubs({api.neutron: ('router_list', 'network_list'),
api.keystone: ('tenant_list',)})
def test_index(self):

View File

@ -71,7 +71,17 @@ class DetailView(r_views.DetailView):
context = super(DetailView, self).get_context_data(**kwargs)
table = rtbl.RoutersTable(self.request)
context["url"] = self.failure_url
context["actions"] = table.render_row_actions(context["router"])
router = context["router"]
# try to lookup the l3 agent location so we know where to troubleshoot
try:
agents = api.neutron.list_l3_agent_hosting_router(self.request,
router.id)
router.l3_host_agents = agents
except Exception:
exceptions.handle(self.request,
_('The L3 agent information could not '
'be located.'))
context["actions"] = table.render_row_actions(router)
return context

View File

@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _
from horizon import tabs
from openstack_dashboard import api
from openstack_dashboard.dashboards.project.routers.extensions.extraroutes\
import tabs as er_tabs
from openstack_dashboard.dashboards.project.routers.extensions.routerrules\
@ -29,7 +30,10 @@ class OverviewTab(tabs.Tab):
template_name = "project/routers/_detail_overview.html"
def get_context_data(self, request):
return {"router": self.tab_group.kwargs['router']}
return {"router": self.tab_group.kwargs['router'],
'ha_supported': api.neutron.
get_feature_permission(self.request, "l3-ha", "get")
}
class InterfacesTab(tabs.TableTab):

View File

@ -20,6 +20,33 @@
<dt>{% trans "High Availability Mode" %}</dt>
<dd>{{ router.ha|yesno|capfirst }}</dd>
{% endif %}
{% if router.l3_host_agents %}
<dt>{% trans "L3 Agent" %}</dt>
<dd>
<table class="table table-striped table-hover">
<thead>
<tr>
<th><strong>{% trans "Host" %}</strong></th>
<th><strong>{% trans "ID" %}</strong></th>
{% if ha_supported %}
<th><strong>{% trans "High Availability Status" %}</strong></th>
{% endif %}
</tr>
</thead>
<tbody>
{% for agent in router.l3_host_agents %}
<tr>
<td>{{ agent.host }}</td>
<td><a href="{% url 'horizon:admin:routers:l3_agent_list' l3_agent_id=agent.id %}">{{ agent.id }}</a></td>
{% if ha_supported %}
<td>{{ agent.ha_state|default:_("None") }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</dd>
{% endif %}
{% if router.external_gateway_info %}
</dl>

View File

@ -30,9 +30,10 @@ from openstack_dashboard.usage import quotas
class RouterMixin(object):
@test.create_stubs({
api.neutron: ('router_get', 'port_list',
'network_get', 'is_extension_supported'),
'network_get', 'is_extension_supported',
'list_l3_agent_hosting_router'),
})
def _get_detail(self, router, extraroute=True):
def _get_detail(self, router, extraroute=True, lookup_l3=False):
api.neutron.is_extension_supported(IsA(http.HttpRequest), 'extraroute')\
.MultipleTimes().AndReturn(extraroute)
api.neutron.router_get(IsA(http.HttpRequest), router.id)\
@ -41,6 +42,10 @@ class RouterMixin(object):
device_id=router.id)\
.AndReturn([self.ports.first()])
self._mock_external_network_get(router)
if lookup_l3:
agent = self.agents.list()[1]
api.neutron.list_l3_agent_hosting_router(IsA(http.HttpRequest), router.id)\
.AndReturn([agent])
self.mox.ReplayAll()
res = self.client.get(reverse('horizon:%s'

View File

@ -0,0 +1,8 @@
---
features:
- >
[`blueprint admin-neutron-l3-agent <https://blueprints.launchpad.net/horizon/+spec/admin-neutron-l3-agent>`_]
Add support for managing neutron L3 agent hosts. The admin screen for system information now provides
links / views to see what routers reside on what hosts. In addition, the admin view of routers
now also provides a list of where the router is hosted and the link to see what other routers are sharing
the same host.