It is difficult to find routers connected given a neutron network

Bug #1562067 reported by David Lawson
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
neutron
Won't Fix
Wishlist
Unassigned
python-neutronclient
Invalid
Wishlist
Unassigned
python-openstackclient
Fix Released
Undecided
Unassigned

Bug Description

Neutron net-show should display the router the network is attached to if it is attached to a router. There doesn't appear to be any way to start with a network name/ID and determine the router that network is using.

Tags: network
Changed in neutron:
importance: Undecided → Wishlist
Revision history for this message
Carl Baldwin (carl-baldwin) wrote :

We won't support this on the API. But, I don't think we'd need to anyway. Let me explain...

In the Neutron model, routers attach to subnets, a part of the network. If you show the network, it lists the subnets that belong to it:

$ neutron net-show private
+-------------------------+--------------+
| Field | Value |
+-------------------------+--------------+
...
| subnets | c03e61b6-... |
| | 45dec6b6-... |
...
+-------------------------+--------------+

Listing a router's ports will show the subnets to which it is attached:

$ neutron router-port-list router1
+--------------+------------------------------------------------------------------+
| id | fixed_ips |
+--------------+------------------------------------------------------------------+
| 2597d0aa-... | {"subnet_id": "c03e61b6-...", "ip_address": "10.0.0.1"} |
| d40960c3-... | {"subnet_id": "45dec6b6-...", "ip_address": "fd80:a290:1ca0::1"} |
+--------------+------------------------------------------------------------------+

From here, it is just a matter of iterating over routers which could be a pain if there are many routers but it is possible. The router-port-list command simply uses the port GET API [1] and passes the device_id of the router. Looking at that API, I see we could do better. By passing network_id instead of the router's device ID, we get a list of ports on the network. Filtering by device_owner="network:router_interface" should give just the router ports connected to the network. Within these ports, the device_id will be the router id of the router connected. I was able to prove this works with the existing API using this URL [2] against one of my devstacks. It worked! From here it is just a matter of iterating the ports in the result and gather the router id(s) and de-duplicating the list since one router can have multiple ports on the network.

If anything, this is a neutron client request.

[1] http://developer.openstack.org/api-ref-networking-v2.html#ports
[2] http://10.224.24.226:9696/v2.0/ports?network_id=31c0cb78-a381-405f-9349-6f2f944aec25&device_owner=network:router_interface

Changed in python-neutronclient:
importance: Undecided → Wishlist
Changed in neutron:
status: New → Won't Fix
summary: - neutron network-show should display the router
+ It is difficult to find routers connected given a neutron network
Changed in python-neutronclient:
assignee: nobody → Reedip (reedip-banerjee)
Revision history for this message
Reedip (reedip-banerjee-deactivatedaccount) wrote :

@Carl :
I agree with your proposal, the code via subnet would be difficult.
However, I think instead of changing the router-port-list, we can create a network-router-list CLI, which will do the same thing, but instead of modifying the currently working code of router-port-list, provide a new CLI to do the same work.

So if a user provides a network to the network-router-list, it will show the information of all the routers connected to the network.
It will take care of the deduplication as well , so that the user does not require any processing to be done at his end.

let me know if you agree with this solution in the following patch.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-neutronclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/299189

Changed in python-neutronclient:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-neutronclient (master)

Change abandoned by Reedip (<email address hidden>) on branch: master
Review: https://review.openstack.org/299189
Reason: See above comment :)

Changed in python-neutronclient:
status: In Progress → Invalid
assignee: Reedip (reedip-banerjee) → nobody
Changed in python-openstackclient:
status: New → Invalid
status: Invalid → New
Richard Theis (rtheis)
tags: added: network
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-openstackclient (master)

Reviewed: https://review.openstack.org/371908
Committed: https://git.openstack.org/cgit/openstack/python-openstackclient/commit/?id=554607eb3dab879da8e172eacb72930e54f0acf4
Submitter: Jenkins
Branch: master

commit 554607eb3dab879da8e172eacb72930e54f0acf4
Author: Reedip <email address hidden>
Date: Sat Sep 17 13:09:42 2016 +0530

    Provide support to list ports by network

    The new --network option provides a list of ports
    connected with the current network.

    Change-Id: I6a45184887b3e65f792391cb7e91f4ad85f29e03
    Partial-Bug:#1562067
    Partially-Implements: blueprint network-commands-options

Changed in python-openstackclient:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.