Sanitize the output from ovs get-fail-mode (#24208)

If a bridge does not have a fail mode set, it returns nothing, i.e.
empty string.
This causes a failure when doing the want vs have compare in plays
where the fail-mode is missing, as we compare "" vs None respectively.
This commit is contained in:
Ricardo Carrillo Cruz 2017-05-02 17:04:33 +02:00 committed by GitHub
parent e67eba877e
commit 9e246a857c

View file

@ -116,6 +116,12 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems from ansible.module_utils.six import iteritems
from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.pycompat24 import get_exception
def _fail_mode_to_str(text):
if not text:
return None
else:
return text.strip()
def _external_ids_to_dict(text): def _external_ids_to_dict(text):
if not text: if not text:
return None return None
@ -216,7 +222,7 @@ def map_config_to_obj(module):
" %(bridge)s") " %(bridge)s")
command = templatized_command % module.params command = templatized_command % module.params
rc, out, err = module.run_command(command, check_rc=True) rc, out, err = module.run_command(command, check_rc=True)
obj['fail_mode'] = out.strip() obj['fail_mode'] = _fail_mode_to_str(out)
templatized_command = ("%(ovs-vsctl)s -t %(timeout)s br-get-external-id" templatized_command = ("%(ovs-vsctl)s -t %(timeout)s br-get-external-id"
" %(bridge)s") " %(bridge)s")