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.
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 ------- -+----- ------- ------- ------- ------- ------- ------- ------- ------- -----+ ------- -+----- ------- ------- ------- ------- ------- ------- ------- ------- -----+ 1ca0::1" } | ------- -+----- ------- ------- ------- ------- ------- ------- ------- ------- -----+
+------
| id | fixed_ips |
+------
| 2597d0aa-... | {"subnet_id": "c03e61b6-...", "ip_address": "10.0.0.1"} |
| d40960c3-... | {"subnet_id": "45dec6b6-...", "ip_address": "fd80:a290:
+------
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 10.224. 24.226: 9696/v2. 0/ports? network_ id=31c0cb78- a381-405f- 9349-6f2f944aec 25&device_ owner=network: router_ interface
[2] http://