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
This commit is contained in:
parent
b235cb8734
commit
24c0f6f872
1 changed files with 8 additions and 10 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue