mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 14:01:42 -07:00
Fixes for broken asa_config module (#27218)
* Fixes for broken asa_config module * strip() prompt before checking
This commit is contained in:
parent
40eb349ac6
commit
089226e372
5 changed files with 136 additions and 50 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue