Fixes for broken asa_config module (#27218)

* Fixes for broken asa_config module

* strip() prompt before checking
This commit is contained in:
Patrick Ogenstad 2017-08-11 17:42:42 +02:00 committed by Peter Sprygada
commit 089226e372
5 changed files with 136 additions and 50 deletions

View file

@ -36,11 +36,22 @@ class TerminalModule(TerminalBase):
terminal_stderr_re = [
re.compile(r"error:", re.I),
re.compile(r"^Removing.* not allowed")
re.compile(br"Removing.* not allowed, it is being used")
]
def on_authorize(self, passwd=None):
def on_open_shell(self):
if self._get_prompt().endswith(b'#'):
self.disable_pager()
def disable_pager(self):
cmd = {u'command': u'no terminal pager'}
try:
self._exec_cli_command(u'no terminal pager')
except AnsibleConnectionFailure:
raise AnsibleConnectionFailure('unable to disable terminal pager')
def on_authorize(self, passwd=None):
if self._get_prompt().strip().endswith(b'#'):
return
cmd = {u'command': u'enable'}
@ -52,6 +63,7 @@ class TerminalModule(TerminalBase):
try:
self._exec_cli_command(to_bytes(json.dumps(cmd), errors='surrogate_or_strict'))
self._exec_cli_command(u'no terminal pager')
except AnsibleConnectionFailure:
raise AnsibleConnectionFailure('unable to elevate privilege to enable mode')
self.disable_pager()