Fix bug in os_router.py when router is not actually updated. (#4107)

The shade update_router() call will return None if the router is
not actually updated. This will cause the module to fail if we
do not protect against that.
This commit is contained in:
David Shrewsbury 2016-07-11 10:01:20 -04:00 committed by Matt Clay
parent 72eaf0281a
commit 37edf33955

View file

@ -360,18 +360,23 @@ def main():
else:
if _needs_update(cloud, module, router, net, internal_ids):
kwargs = _build_kwargs(cloud, module, router, net)
router = cloud.update_router(**kwargs)
updated_router = cloud.update_router(**kwargs)
# Protect against update_router() not actually
# updating the router.
if not updated_router:
changed = False
# On a router update, if any internal interfaces were supplied,
# just detach all existing internal interfaces and attach the new.
if internal_ids:
elif internal_ids:
router = updated_router
ports = cloud.list_router_interfaces(router, 'internal')
for port in ports:
cloud.remove_router_interface(router, port_id=port['id'])
for internal_subnet_id in internal_ids:
cloud.add_router_interface(router, subnet_id=internal_subnet_id)
changed = True
changed = True
module.exit_json(changed=changed,
router=router,