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:
parent
72eaf0281a
commit
37edf33955
1 changed files with 9 additions and 4 deletions
|
@ -360,18 +360,23 @@ def main():
|
||||||
else:
|
else:
|
||||||
if _needs_update(cloud, module, router, net, internal_ids):
|
if _needs_update(cloud, module, router, net, internal_ids):
|
||||||
kwargs = _build_kwargs(cloud, module, router, net)
|
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,
|
# On a router update, if any internal interfaces were supplied,
|
||||||
# just detach all existing internal interfaces and attach the new.
|
# 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')
|
ports = cloud.list_router_interfaces(router, 'internal')
|
||||||
for port in ports:
|
for port in ports:
|
||||||
cloud.remove_router_interface(router, port_id=port['id'])
|
cloud.remove_router_interface(router, port_id=port['id'])
|
||||||
for internal_subnet_id in internal_ids:
|
for internal_subnet_id in internal_ids:
|
||||||
cloud.add_router_interface(router, subnet_id=internal_subnet_id)
|
cloud.add_router_interface(router, subnet_id=internal_subnet_id)
|
||||||
|
changed = True
|
||||||
changed = True
|
|
||||||
|
|
||||||
module.exit_json(changed=changed,
|
module.exit_json(changed=changed,
|
||||||
router=router,
|
router=router,
|
||||||
|
|
Loading…
Add table
Reference in a new issue