From 24c0f6f87223d466443a38f6caa28b55ac0a4f4a Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Thu, 7 Jun 2018 19:05:07 +0530 Subject: [PATCH] Fix ios_user integration test failure (#41252) * If the command input is dict from module in that case the check to see if command is end or `!` to exclude it from executing on remote host is wrong. Fix the logic to check `end` and `!` commands --- lib/ansible/plugins/cliconf/ios.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/ansible/plugins/cliconf/ios.py b/lib/ansible/plugins/cliconf/ios.py index 5e2e79e71f..d4637bd759 100644 --- a/lib/ansible/plugins/cliconf/ios.py +++ b/lib/ansible/plugins/cliconf/ios.py @@ -119,29 +119,27 @@ class Cliconf(CliconfBase): @enable_mode def edit_config(self, candidate, check_mode=False, replace=None): - if not candidate: raise ValueError('must provide a candidate config to load') if check_mode not in (True, False): raise ValueError('`check_mode` must be a bool, got %s' % check_mode) - device_operations = self.get_device_operations() - options = self.get_options() + options = self.get_option_values() if replace and replace not in options['replace']: raise ValueError('`replace` value %s in invalid, valid values are %s' % (replace, options['replace'])) results = [] if not check_mode: for line in chain(['configure terminal'], to_list(candidate)): - if line != 'end' and line[0] != '!': - if not isinstance(line, collections.Mapping): - line = {'command': line} + if not isinstance(line, collections.Mapping): + line = {'command': line} - results.append(self.send_command(**line)) + cmd = line['command'] + if cmd != 'end' and cmd[0] != '!': + results.append(self.send_command(**line)) results.append(self.send_command('end')) - return results[1:-1] def get(self, command, prompt=None, answer=None, sendonly=False): @@ -182,7 +180,7 @@ class Cliconf(CliconfBase): 'supports_generate_diff': True, } - def get_options(self): + def get_option_values(self): return { 'format': ['text'], 'match': ['line', 'strict', 'exact', 'none'], @@ -195,7 +193,7 @@ class Cliconf(CliconfBase): result['network_api'] = 'cliconf' result['device_info'] = self.get_device_info() result['device_operations'] = self.get_device_operations() - result.update(self.get_options()) + result.update(self.get_option_values()) return json.dumps(result) def edit_banner(self, banners, multiline_delimiter="@", check_mode=False):