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):