* Fix_module_correction
This commit is contained in:
abirami-n 2018-07-20 21:49:21 +05:30 committed by John R Barker
parent 87f004c503
commit 1152f86ba1
5 changed files with 13 additions and 11 deletions

View file

@ -1,5 +1,6 @@
#
# (c) 2015 Peter Sprygada, <psprygada@ansible.com>
# (c) 2017 Red Hat, Inc
#
# Copyright (c) 2016 Dell Inc.
#
@ -122,6 +123,7 @@ def load_config(module, commands):
for command in to_list(commands):
if command == 'end':
continue
# cmd = {'command': command, 'prompt': WARNING_PROMPTS_RE, 'answer': 'yes'}
rc, out, err = exec_command(module, command)
if rc != 0:
module.fail_json(msg=to_text(err, errors='surrogate_or_strict'), command=command, rc=rc)
@ -168,7 +170,7 @@ def os6_parse(lines, indent=None, comment_tokens=None):
re.compile(r'template.*$'),
re.compile(r'address-family.*$'),
re.compile(r'spanning-tree mst configuration.*$'),
re.compile(r'logging.*$'),
re.compile(r'logging (?!.*(cli-command|buffered|console|email|facility|file|monitor|protocol|snmp|source-interface|traps|web-session)).*$'),
re.compile(r'(radius-server|tacacs-server) host.*$')]
childline = re.compile(r'^exit$')

View file

@ -263,7 +263,7 @@ def main():
commands = dumps(configobjs, 'commands')
if ((isinstance((module.params['lines']), list)) and
(isinstance((module.params['lines'][0]), dict)) and
(['prompt', 'answer'].issubset(module.params['lines'][0]))):
(set(['prompt', 'answer']).issubset(module.params['lines'][0]))):
cmd = {'command': commands,
'prompt': module.params['lines'][0]['prompt'],

View file

@ -262,7 +262,7 @@ def main():
commands = dumps(configobjs, 'commands')
if ((isinstance(module.params['lines'], list)) and
(isinstance(module.params['lines'][0], dict)) and
['prompt', 'answer'].issubset(module.params['lines'][0])):
set(['prompt', 'answer']).issubset(module.params['lines'][0])):
cmd = {'command': commands,
'prompt': module.params['lines'][0]['prompt'],
'answer': module.params['lines'][0]['answer']}
@ -287,7 +287,7 @@ def main():
result['changed'] = True
if not module.check_mode:
cmd = {'command': 'copy running-config startup-config',
'prompt': r'\(y/n\)$', 'answer': 'yes'}
'prompt': r'\(y/n\)\s?$', 'answer': 'yes'}
run_commands(module, [cmd])
result['saved'] = True
else:

View file

@ -270,7 +270,7 @@ def main():
commands = dumps(configobjs, 'commands')
if ((isinstance(module.params['lines'], list)) and
(isinstance(module.params['lines'][0], dict)) and
['prompt', 'answer'].issubset(module.params['lines'][0])):
set(['prompt', 'answer']).issubset(module.params['lines'][0])):
cmd = {'command': commands,
'prompt': module.params['lines'][0]['prompt'],

View file

@ -37,17 +37,17 @@ class TerminalModule(TerminalBase):
]
terminal_stderr_re = [
re.compile(br"% ?Error: (?:(?!\bdoes not exist\b)(?!\balready exists\b)(?!\bHost not found\b)(?!\bnot active\b).)*$"),
re.compile(br"% ?Bad secret"),
re.compile(br"(\bInterface is part of a port-channel\b)|(\bAn invalid interface has been used for this function\b)"),
re.compile(br"(\bThe maximum number of users have already been created\b)|(\bVLAN ID is out of range\b)|(\bUse '-' for range\b)"),
re.compile(br"(\binvalid input\b)|(\bVLAN ID not found\b)"),
re.compile(br"(\bInvalid access level. Access level can be either 0, 1 or 15\b)|(\bValue is out of range\b)"),
re.compile(br"Cannot add(.+)\s(\S+)"),
re.compile(br"(\bInterface is part of a port-channel\b)"),
re.compile(br"(\bThe maximum number of users have already been created\b)|(\bUse '-' for range\b)"),
re.compile(br"Error:(.+)\s(\S+)"),
re.compile(br"(?:incomplete|ambiguous) command", re.I),
re.compile(br"connection timed out", re.I),
re.compile(br"'[^']' +returned error code: ?\d+"),
re.compile(br"Invalid|invalid.*$", re.I),
re.compile(br"((\bout of range\b)|(\bnot found\b)|(\bCould not\b)|(\bUnable to\b)|(\bCannot\b)).*", re.I),
re.compile(br"((\balready exists\b)|(\bdoes not exist\b)|(\bnot active\b)|(\bFailed\b)|(\bIncorrect\b)|(\bnot enabled\b)).*", re.I),
]
def on_become(self, passwd=None):