From 6dd8a4cf78d4fe4216a842a461871bade9a9b5a2 Mon Sep 17 00:00:00 2001 From: Kei Nohguchi Date: Mon, 29 May 2017 05:44:17 -0700 Subject: [PATCH] openvswitch_bridge.py: Avoid runtime error with no external_ids (#25128) This happens when there is external_ids configured on the existing OvS bridge, though playbook doesn't. --- lib/ansible/modules/network/ovs/openvswitch_bridge.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/network/ovs/openvswitch_bridge.py b/lib/ansible/modules/network/ovs/openvswitch_bridge.py index 85595e7881..4e4b4c6645 100644 --- a/lib/ansible/modules/network/ovs/openvswitch_bridge.py +++ b/lib/ansible/modules/network/ovs/openvswitch_bridge.py @@ -157,11 +157,12 @@ def map_obj_to_commands(want, have, module): templatized_command = ("%(ovs-vsctl)s -t %(timeout)s" " br-set-external-id %(bridge)s") command = templatized_command % module.params - for k, v in iteritems(want['external_ids']): - if (k not in have['external_ids'] - or want['external_ids'][k] != have['external_ids'][k]): - command += " " + k + " " + v - commands.append(command) + if want['external_ids']: + for k, v in iteritems(want['external_ids']): + if (k not in have['external_ids'] + or want['external_ids'][k] != have['external_ids'][k]): + command += " " + k + " " + v + commands.append(command) else: templatized_command = ("%(ovs-vsctl)s -t %(timeout)s add-br" " %(bridge)s")