mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-04 15:40:20 -07:00
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
|
@enable_mode
|
||||||
def edit_config(self, candidate, check_mode=False, replace=None):
|
def edit_config(self, candidate, check_mode=False, replace=None):
|
||||||
|
|
||||||
if not candidate:
|
if not candidate:
|
||||||
raise ValueError('must provide a candidate config to load')
|
raise ValueError('must provide a candidate config to load')
|
||||||
|
|
||||||
if check_mode not in (True, False):
|
if check_mode not in (True, False):
|
||||||
raise ValueError('`check_mode` must be a bool, got %s' % check_mode)
|
raise ValueError('`check_mode` must be a bool, got %s' % check_mode)
|
||||||
|
|
||||||
device_operations = self.get_device_operations()
|
options = self.get_option_values()
|
||||||
options = self.get_options()
|
|
||||||
if replace and replace not in options['replace']:
|
if replace and replace not in options['replace']:
|
||||||
raise ValueError('`replace` value %s in invalid, valid values are %s' % (replace, options['replace']))
|
raise ValueError('`replace` value %s in invalid, valid values are %s' % (replace, options['replace']))
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
if not check_mode:
|
if not check_mode:
|
||||||
for line in chain(['configure terminal'], to_list(candidate)):
|
for line in chain(['configure terminal'], to_list(candidate)):
|
||||||
if line != 'end' and line[0] != '!':
|
if not isinstance(line, collections.Mapping):
|
||||||
if not isinstance(line, collections.Mapping):
|
line = {'command': line}
|
||||||
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'))
|
results.append(self.send_command('end'))
|
||||||
|
|
||||||
return results[1:-1]
|
return results[1:-1]
|
||||||
|
|
||||||
def get(self, command, prompt=None, answer=None, sendonly=False):
|
def get(self, command, prompt=None, answer=None, sendonly=False):
|
||||||
|
@ -182,7 +180,7 @@ class Cliconf(CliconfBase):
|
||||||
'supports_generate_diff': True,
|
'supports_generate_diff': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_options(self):
|
def get_option_values(self):
|
||||||
return {
|
return {
|
||||||
'format': ['text'],
|
'format': ['text'],
|
||||||
'match': ['line', 'strict', 'exact', 'none'],
|
'match': ['line', 'strict', 'exact', 'none'],
|
||||||
|
@ -195,7 +193,7 @@ class Cliconf(CliconfBase):
|
||||||
result['network_api'] = 'cliconf'
|
result['network_api'] = 'cliconf'
|
||||||
result['device_info'] = self.get_device_info()
|
result['device_info'] = self.get_device_info()
|
||||||
result['device_operations'] = self.get_device_operations()
|
result['device_operations'] = self.get_device_operations()
|
||||||
result.update(self.get_options())
|
result.update(self.get_option_values())
|
||||||
return json.dumps(result)
|
return json.dumps(result)
|
||||||
|
|
||||||
def edit_banner(self, banners, multiline_delimiter="@", check_mode=False):
|
def edit_banner(self, banners, multiline_delimiter="@", check_mode=False):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue