Don't fail on unable to set terminal width on ios (#47290)
* Don't fail if ios can't set terminal width * Fix display importpull/4420/head
parent
4947936176
commit
7af405883f
|
@ -25,6 +25,9 @@ import re
|
||||||
from ansible.errors import AnsibleConnectionFailure
|
from ansible.errors import AnsibleConnectionFailure
|
||||||
from ansible.module_utils._text import to_text, to_bytes
|
from ansible.module_utils._text import to_text, to_bytes
|
||||||
from ansible.plugins.terminal import TerminalBase
|
from ansible.plugins.terminal import TerminalBase
|
||||||
|
from ansible.utils.display import Display
|
||||||
|
|
||||||
|
display = Display()
|
||||||
|
|
||||||
|
|
||||||
class TerminalModule(TerminalBase):
|
class TerminalModule(TerminalBase):
|
||||||
|
@ -52,11 +55,15 @@ class TerminalModule(TerminalBase):
|
||||||
|
|
||||||
def on_open_shell(self):
|
def on_open_shell(self):
|
||||||
try:
|
try:
|
||||||
for cmd in (b'terminal length 0', b'terminal width 512'):
|
self._exec_cli_command(b'terminal length 0')
|
||||||
self._exec_cli_command(cmd)
|
|
||||||
except AnsibleConnectionFailure:
|
except AnsibleConnectionFailure:
|
||||||
raise AnsibleConnectionFailure('unable to set terminal parameters')
|
raise AnsibleConnectionFailure('unable to set terminal parameters')
|
||||||
|
|
||||||
|
try:
|
||||||
|
self._exec_cli_command(b'terminal width 512')
|
||||||
|
except AnsibleConnectionFailure:
|
||||||
|
display.display('WARNING: Unable to set terminal width, command responses may be truncated')
|
||||||
|
|
||||||
def on_become(self, passwd=None):
|
def on_become(self, passwd=None):
|
||||||
if self._get_prompt().endswith(b'#'):
|
if self._get_prompt().endswith(b'#'):
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue