diff options
author | David Shrewsbury <Shrews@users.noreply.github.com> | 2016-07-11 10:01:20 -0400 |
---|---|---|
committer | Rene Moser <mail@renemoser.net> | 2016-07-11 16:03:58 +0200 |
commit | 1165bfa6b6e3f129afcab3dc3f88d37ec04f7fe2 (patch) | |
tree | 2d5627bec0726613331d61b3046629d93a6f29be | |
parent | 9a0474a63d701050652d5fb6df7c826d789780e5 (diff) | |
download | ansible-modules-core-1165bfa6b6e3f129afcab3dc3f88d37ec04f7fe2.tar.gz |
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.
-rw-r--r-- | cloud/openstack/os_router.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/cloud/openstack/os_router.py b/cloud/openstack/os_router.py index ed606f8e..2c1fb19c 100644 --- a/cloud/openstack/os_router.py +++ b/cloud/openstack/os_router.py @@ -322,18 +322,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, |