Use reset to fix cmdline

Reset is an application provided via ncurses which is useful in
resetting a terminal when things go wrong. Since podman is eating some
of the terminal output, it can leave the cmdline in a broken state at
the end of the undercloud install. We tried to address it outselves but
let's reuse an existing application instead. -I being passed to reset
skips the initialization strings which can erase the output.

Change-Id: Id9aa7910032588605977f4725385503cf0a235bc
Closes-Bug: #1833302
This commit is contained in:
Alex Schultz 2019-08-19 14:43:31 -06:00
parent 5a66fe5446
commit fddcb9e075
3 changed files with 10 additions and 8 deletions

View File

@ -887,7 +887,7 @@ class TestDeployUndercloud(TestPluginV1):
env
)
@mock.patch('tripleoclient.utils.send_cmdline_erase_sequence')
@mock.patch('tripleoclient.utils.reset_cmdline')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_download_stack_outputs')
@mock.patch('tripleo_common.actions.ansible.'
@ -974,7 +974,7 @@ class TestDeployUndercloud(TestPluginV1):
self.assertEqual(mock_killheat.call_count, 2)
mock_cmdline.assert_called_once()
@mock.patch('tripleoclient.utils.send_cmdline_erase_sequence')
@mock.patch('tripleoclient.utils.reset_cmdline')
@mock.patch('tripleoclient.utils.ansible_symlink')
def test_take_action(self, mock_slink, mock_cmdline):
mock_slink.side_effect = 'fake-cmd'
@ -987,7 +987,7 @@ class TestDeployUndercloud(TestPluginV1):
self.cmd.take_action, parsed_args)
mock_cmdline.assert_called_once()
@mock.patch('tripleoclient.utils.send_cmdline_erase_sequence')
@mock.patch('tripleoclient.utils.reset_cmdline')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy._standalone_deploy',
return_value=1)
@mock.patch('tripleoclient.utils.ansible_symlink')

View File

@ -1929,8 +1929,10 @@ def check_deprecated_service_is_enabled(environment_files):
check_file_for_enabled_service(env_file)
def send_cmdline_erase_sequence():
# Send's an erase in line sequence to the output
# https://www.vt100.net/docs/vt100-ug/chapter3.html#EL
sys.stdout.write(u'\u001b[0K')
def reset_cmdline():
"""Run reset to cleanup cmdline"""
# only try to reset if stdout is a terminal, skip if not (e.g. CI)
if not sys.stdout.isatty():
return
sys.stdout.write(run_command(['reset', '-I']))
sys.stdout.flush()

View File

@ -1420,4 +1420,4 @@ class Deploy(command.Command):
finally:
# send erase sequence to reset the cmdline if paunch/ansible
# mangled some escape sequences
utils.send_cmdline_erase_sequence()
utils.reset_cmdline()