[openstack-dev] [Neutron][Client] How do I list interfaces on a router?

Jay Pipes jaypipes at gmail.com
Mon Oct 7 16:00:30 UTC 2013


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/neutron.py 
lines 660-708



More information about the OpenStack-dev mailing list