handle routers without an external gateway in list_router_interfaces

list_router_interfaces would fail if called on a router with no external
gateway:

    File "/home/lars/.ansible/tmp/ansible-tmp-1445525437.55-149961620412652/os_router", line 343, in main
      ports = cloud.list_router_interfaces(router, 'internal')
    File "/usr/lib/python2.7/site-packages/shade/__init__.py", line 1922, in list_router_interfaces
      ext_fixed = router['external_gateway_info']['external_fixed_ips']
    TypeError: 'NoneType' object has no attribute '__getitem__'

This commit defaults `ext_fixed` to an empty list if there is no external gateway.

Change-Id: Idbcd5f005ebef47e11377e83a60d2adea7c3380b
This commit is contained in:
Lars Kellogg-Stedman 2015-10-22 10:54:52 -04:00
parent e057b0d071
commit bf792d7ff4
1 changed files with 3 additions and 1 deletions

View File

@ -1919,7 +1919,9 @@ class OpenStackCloud(object):
if interface_type:
filtered_ports = []
ext_fixed = router['external_gateway_info']['external_fixed_ips']
ext_fixed = (router['external_gateway_info']['external_fixed_ips']
if router['external_gateway_info']
else [])
# Compare the subnets (subnet_id, ip_address) on the ports with
# the subnets making up the router external gateway. Those ports