From ffb86df96519357430a8bd38da5a58cd8789ccd7 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Mon, 19 Aug 2019 14:43:31 -0600 Subject: [PATCH] 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. Conflicts: tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py Change-Id: Id9aa7910032588605977f4725385503cf0a235bc Closes-Bug: #1833302 (cherry picked from commit fddcb9e0755beec8eff3b7246a3b7b799a8ec7f2) --- tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py | 6 +++--- tripleoclient/utils.py | 10 ++++++---- tripleoclient/v1/tripleo_deploy.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py b/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py index 0d4fc2b89..df113b4eb 100644 --- a/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py +++ b/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py @@ -889,7 +889,7 @@ class TestDeployUndercloud(TestPluginV1): env ) - @mock.patch('tripleoclient.utils.send_cmdline_erase_sequence') + @mock.patch('tripleoclient.utils.reset_cmdline') @mock.patch('tripleo_common.actions.ansible.' 'write_default_ansible_cfg') # TODO(cjeanner) drop once we have proper oslo.privsep @@ -975,7 +975,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' @@ -988,7 +988,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') diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index 90f621027..5d97d2eff 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -2034,8 +2034,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() diff --git a/tripleoclient/v1/tripleo_deploy.py b/tripleoclient/v1/tripleo_deploy.py index c220e271f..2ee4409ff 100644 --- a/tripleoclient/v1/tripleo_deploy.py +++ b/tripleoclient/v1/tripleo_deploy.py @@ -1382,4 +1382,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()