mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
feature to implement localized cli prompts to eos
This change localizes the cli prompt regexps to the eos shared module instead of the common prompts implemented in shell
This commit is contained in:
parent
5338d6af28
commit
d211b4c962
1 changed files with 18 additions and 2 deletions
|
@ -31,6 +31,23 @@ NET_COMMON_ARGS = dict(
|
||||||
provider=dict(type='dict')
|
provider=dict(type='dict')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
CLI_PROMPTS_RE = [
|
||||||
|
re.compile(r"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"),
|
||||||
|
re.compile(r"\[\w+\@[\w\-\.]+(?: [^\]])\] ?[>#\$] ?$")
|
||||||
|
]
|
||||||
|
|
||||||
|
CLI_ERRORS_RE = [
|
||||||
|
re.compile(r"% ?Error"),
|
||||||
|
re.compile(r"^% \w+", re.M),
|
||||||
|
re.compile(r"% ?Bad secret"),
|
||||||
|
re.compile(r"invalid input", re.I),
|
||||||
|
re.compile(r"(?:incomplete|ambiguous) command", re.I),
|
||||||
|
re.compile(r"connection timed out", re.I),
|
||||||
|
re.compile(r"[^\r\n]+ not found", re.I),
|
||||||
|
re.compile(r"'[^']' +returned error code: ?\d+"),
|
||||||
|
re.compile(r"[^\r\n]\/bin\/(?:ba)?sh")
|
||||||
|
]
|
||||||
|
|
||||||
def to_list(val):
|
def to_list(val):
|
||||||
if isinstance(val, (list, tuple)):
|
if isinstance(val, (list, tuple)):
|
||||||
return list(val)
|
return list(val)
|
||||||
|
@ -123,9 +140,8 @@ class Cli(object):
|
||||||
username = self.module.params['username']
|
username = self.module.params['username']
|
||||||
password = self.module.params['password']
|
password = self.module.params['password']
|
||||||
|
|
||||||
self.shell = Shell()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
self.shell = Shell(CLI_PROMPTS_RE, CLI_ERRORS_RE)
|
||||||
self.shell.open(host, port=port, username=username, password=password)
|
self.shell.open(host, port=port, username=username, password=password)
|
||||||
except Exception, exc:
|
except Exception, exc:
|
||||||
msg = 'failed to connecto to %s:%s - %s' % (host, port, str(exc))
|
msg = 'failed to connecto to %s:%s - %s' % (host, port, str(exc))
|
||||||
|
|
Loading…
Reference in a new issue