From ee62c8ffbc096ce88ed0583fba405bd0d04f31f6 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Mon, 23 Jul 2018 13:06:41 -0400 Subject: [PATCH] Actually fix eos_facts feature detection --- lib/ansible/module_utils/network/eos/eos.py | 6 +++--- lib/ansible/modules/network/eos/eos_facts.py | 2 +- lib/ansible/plugins/cliconf/eos.py | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/ansible/module_utils/network/eos/eos.py b/lib/ansible/module_utils/network/eos/eos.py index f4ddd02e730..de873bb6d5f 100644 --- a/lib/ansible/module_utils/network/eos/eos.py +++ b/lib/ansible/module_utils/network/eos/eos.py @@ -280,7 +280,7 @@ class Eapi: return response - def run_commands(self, commands): + def run_commands(self, commands, check_rc=True): """Runs list of commands on remote device and returns results """ output = None @@ -431,9 +431,9 @@ def get_config(module, flags=None): return conn.get_config(flags) -def run_commands(module, commands): +def run_commands(module, commands, check_rc=True): conn = get_connection(module) - return conn.run_commands(to_command(module, commands)) + return conn.run_commands(to_command(module, commands), check_rc) def load_config(module, config, commit=False, replace=False): diff --git a/lib/ansible/modules/network/eos/eos_facts.py b/lib/ansible/modules/network/eos/eos_facts.py index ee1c54e0da2..189a868f3f1 100644 --- a/lib/ansible/modules/network/eos/eos_facts.py +++ b/lib/ansible/modules/network/eos/eos_facts.py @@ -153,7 +153,7 @@ class FactsBase(object): self.responses = None def populate(self): - self.responses = run_commands(self.module, list(self.COMMANDS)) + self.responses = run_commands(self.module, list(self.COMMANDS), check_rc=False) class Default(FactsBase): diff --git a/lib/ansible/plugins/cliconf/eos.py b/lib/ansible/plugins/cliconf/eos.py index 5a8e9736206..6312188da9a 100644 --- a/lib/ansible/plugins/cliconf/eos.py +++ b/lib/ansible/plugins/cliconf/eos.py @@ -25,7 +25,7 @@ import time from itertools import chain from ansible.errors import AnsibleConnectionFailure -from ansible.module_utils._text import to_bytes +from ansible.module_utils._text import to_bytes, to_text from ansible.module_utils.network.common.utils import to_list from ansible.plugins.cliconf import CliconfBase, enable_mode from ansible.plugins.connection.network_cli import Connection as NetworkCli @@ -137,12 +137,13 @@ class Cliconf(CliconfBase): if check_rc: raise out = getattr(e, 'err', e) + out = to_text(out, errors='surrogate_or_strict') if out is not None: try: out = json.loads(out) except ValueError: - out = str(out).strip() + out = out.strip() responses.append(out)