[openstack-dev] [Neutron][Client] How do I list interfaces on a router?
Edgar Magana
emagana at plumgrid.com
Mon Oct 7 16:21:25 UTC 2013
Jay,
You need to find out if the router has ports active, for instance take a
look to this code:
def delete(self, request, obj_id):
try:
router_id = self.table.kwargs['router_id']
port = api.neutron.port_get(request, obj_id)
if port['device_owner'] == 'network:router_gateway':
api.neutron.router_remove_gateway(request, router_id)
else:
api.neutron.router_remove_interface(request, router_id, port_id=obj_id)
Regards,
Edgar
On 10/7/13 9:00 AM, "Jay Pipes" <jaypipes at gmail.com> wrote:
>Hi all,
>
>I've got code that is checking to see if a particular router has a
>public gateway set up, and if not, it wires up the gateway:
>
>print "Checking %s router setup ... " % zone.upper(),
> try:
> router = qc.list_routers(name="demorouter")['routers']
> router = router[0]
> print "OK"
> except IndexError:
> print "MISSING"
> print "--> Creating missing router ... ",
> router_data = dict(name="demorouter", admin_state_up=True)
> router = qc.create_router(dict(router=router_data))['router']
> print "OK"
>
>print "Checking %s router gateway ... " % zone.upper(),
>if router['external_gateway_info'] is None:
> print "NOT SET"
> print "--> Setting external gateway for router ... ",
> pub_net_id = qc.list_networks(name="public")['networks'][0]['id']
> net_dict = dict(network_id=pub_net_id)
> qc.add_gateway_router(router['id'], net_dict)
> print "OK"
>else:
> print "OK"
>
>The above code works just fine. The next thing I need to check is
>whether the private subnet is wired into the router. I cannot seem to
>determine how to list interfaces for a particular router.
>
>I checked Horizon and it doesn't seem to have any idea how to do this
>either [1]. Is this just something that is missing from the Neutron API?
>If so, how do you suggest I determine if the demo router has been
>connected to the private subnet?
>
>Thanks in advance for any help,
>-jay
>
>https://github.com/openstack/horizon/blob/master/openstack_dashboard/api/n
>eutron.py
>lines 660-708
>
>_______________________________________________
>OpenStack-dev mailing list
>OpenStack-dev at lists.openstack.org
>http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
More information about the OpenStack-dev
mailing list