From 0ee88956cc1fcf0e004e74ab601939de27a49ce4 Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 15 Apr 2016 14:08:49 -0600 Subject: [PATCH] Add router L3 agent info to info page This change tries to lookup the L3 agent location for a router to assist admins in locating where a router resides. Change-Id: I62bedcc587791df3a101b9d81a03ba2540dfa033 Implements: blueprint admin-neutron-l3-agents --- openstack_dashboard/api/neutron.py | 6 +++++ .../dashboards/admin/routers/tests.py | 5 ++++ .../dashboards/admin/routers/views.py | 12 ++++++++- .../dashboards/project/routers/tabs.py | 6 ++++- .../templates/routers/_detail_overview.html | 27 +++++++++++++++++++ .../dashboards/project/routers/tests.py | 9 +++++-- ...in-neutron-l3-agents-dd6274467572906b.yaml | 8 ++++++ 7 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/admin-neutron-l3-agents-dd6274467572906b.yaml diff --git a/openstack_dashboard/api/neutron.py b/openstack_dashboard/api/neutron.py index cdd0c40729..3ca9f77ea8 100644 --- a/openstack_dashboard/api/neutron.py +++ b/openstack_dashboard/api/neutron.py @@ -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) diff --git a/openstack_dashboard/dashboards/admin/routers/tests.py b/openstack_dashboard/dashboards/admin/routers/tests.py index 7ee8772f28..39a0c9654e 100644 --- a/openstack_dashboard/dashboards/admin/routers/tests.py +++ b/openstack_dashboard/dashboards/admin/routers/tests.py @@ -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): diff --git a/openstack_dashboard/dashboards/admin/routers/views.py b/openstack_dashboard/dashboards/admin/routers/views.py index ec1da4d2a8..f348edd5ba 100644 --- a/openstack_dashboard/dashboards/admin/routers/views.py +++ b/openstack_dashboard/dashboards/admin/routers/views.py @@ -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 diff --git a/openstack_dashboard/dashboards/project/routers/tabs.py b/openstack_dashboard/dashboards/project/routers/tabs.py index 04046eb75c..bec790364d 100644 --- a/openstack_dashboard/dashboards/project/routers/tabs.py +++ b/openstack_dashboard/dashboards/project/routers/tabs.py @@ -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): diff --git a/openstack_dashboard/dashboards/project/routers/templates/routers/_detail_overview.html b/openstack_dashboard/dashboards/project/routers/templates/routers/_detail_overview.html index 3f511b9d75..ed353626a5 100644 --- a/openstack_dashboard/dashboards/project/routers/templates/routers/_detail_overview.html +++ b/openstack_dashboard/dashboards/project/routers/templates/routers/_detail_overview.html @@ -20,6 +20,33 @@
{% trans "High Availability Mode" %}
{{ router.ha|yesno|capfirst }}
{% endif %} + {% if router.l3_host_agents %} +
{% trans "L3 Agent" %}
+
+ + + + + + {% if ha_supported %} + + {% endif %} + + + + {% for agent in router.l3_host_agents %} + + + + {% if ha_supported %} + + {% endif %} + + {% endfor %} + +
{% trans "Host" %}{% trans "ID" %}{% trans "High Availability Status" %}
{{ agent.host }}{{ agent.id }}{{ agent.ha_state|default:_("None") }}
+
+ {% endif %} {% if router.external_gateway_info %} diff --git a/openstack_dashboard/dashboards/project/routers/tests.py b/openstack_dashboard/dashboards/project/routers/tests.py index ebc367589a..cd247ec818 100644 --- a/openstack_dashboard/dashboards/project/routers/tests.py +++ b/openstack_dashboard/dashboards/project/routers/tests.py @@ -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' diff --git a/releasenotes/notes/admin-neutron-l3-agents-dd6274467572906b.yaml b/releasenotes/notes/admin-neutron-l3-agents-dd6274467572906b.yaml new file mode 100644 index 0000000000..30689bde48 --- /dev/null +++ b/releasenotes/notes/admin-neutron-l3-agents-dd6274467572906b.yaml @@ -0,0 +1,8 @@ +--- +features: + - > + [`blueprint 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.