Send terminal erase sequence on tripleo deploy

We're seeing some escape sequences being dropped when we run the
deployment via the undercloud. This causes a user to have to run a reset
after the undercloud installation in order to be able to use their shell
command line again.  We can avoid this if we send an terminal erase line
sequence to trim the rest of the line at the end of the deploy.

Change-Id: Ibb74bfebfaab2cd122abe1bc3cd5bbd2562ccfc5
Closes-Bug: #1833302
This commit is contained in:
Alex Schultz 2019-06-18 15:21:46 -06:00
parent 189281993b
commit e1a051d6ac
3 changed files with 29 additions and 10 deletions

View File

@ -887,6 +887,7 @@ class TestDeployUndercloud(TestPluginV1):
env env
) )
@mock.patch('tripleoclient.utils.send_cmdline_erase_sequence')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.' @mock.patch('tripleoclient.v1.tripleo_deploy.Deploy.'
'_download_stack_outputs') '_download_stack_outputs')
@mock.patch('tripleo_common.actions.ansible.' @mock.patch('tripleo_common.actions.ansible.'
@ -939,7 +940,8 @@ class TestDeployUndercloud(TestPluginV1):
mock_cleanupdirs, mock_launchansible, mock_cleanupdirs, mock_launchansible,
mock_tarball, mock_templates_dir, mock_tarball, mock_templates_dir,
mock_open, mock_os, mock_user, mock_cc, mock_open, mock_os, mock_user, mock_cc,
mock_chmod, mock_ac, mock_outputs): mock_chmod, mock_ac, mock_outputs,
mock_cmdline):
mock_slink.side_effect = 'fake-cmd' mock_slink.side_effect = 'fake-cmd'
parsed_args = self.check_parser(self.cmd, parsed_args = self.check_parser(self.cmd,
['--local-ip', '127.0.0.1', ['--local-ip', '127.0.0.1',
@ -972,9 +974,11 @@ class TestDeployUndercloud(TestPluginV1):
mock_tarball.assert_called_once() mock_tarball.assert_called_once()
mock_cleanupdirs.assert_called_once() mock_cleanupdirs.assert_called_once()
self.assertEqual(mock_killheat.call_count, 2) self.assertEqual(mock_killheat.call_count, 2)
mock_cmdline.assert_called_once()
@mock.patch('tripleoclient.utils.send_cmdline_erase_sequence')
@mock.patch('tripleoclient.utils.ansible_symlink') @mock.patch('tripleoclient.utils.ansible_symlink')
def test_take_action(self, mock_slink): def test_take_action(self, mock_slink, mock_cmdline):
mock_slink.side_effect = 'fake-cmd' mock_slink.side_effect = 'fake-cmd'
parsed_args = self.check_parser(self.cmd, parsed_args = self.check_parser(self.cmd,
['--local-ip', '127.0.0.1', ['--local-ip', '127.0.0.1',
@ -983,11 +987,13 @@ class TestDeployUndercloud(TestPluginV1):
'--output-dir', '/my'], []) '--output-dir', '/my'], [])
self.assertRaises(exceptions.DeploymentError, self.assertRaises(exceptions.DeploymentError,
self.cmd.take_action, parsed_args) self.cmd.take_action, parsed_args)
mock_cmdline.assert_called_once()
@mock.patch('tripleoclient.utils.send_cmdline_erase_sequence')
@mock.patch('tripleoclient.v1.tripleo_deploy.Deploy._standalone_deploy', @mock.patch('tripleoclient.v1.tripleo_deploy.Deploy._standalone_deploy',
return_value=1) return_value=1)
@mock.patch('tripleoclient.utils.ansible_symlink') @mock.patch('tripleoclient.utils.ansible_symlink')
def test_take_action_failure(self, mock_slink, mock_deploy): def test_take_action_failure(self, mock_slink, mock_deploy, mock_cmdline):
mock_slink.side_effect = 'fake-cmd' mock_slink.side_effect = 'fake-cmd'
parsed_args = self.check_parser(self.cmd, parsed_args = self.check_parser(self.cmd,
['--local-ip', '127.0.0.1', ['--local-ip', '127.0.0.1',
@ -997,6 +1003,7 @@ class TestDeployUndercloud(TestPluginV1):
'--standalone'], []) '--standalone'], [])
self.assertRaises(exceptions.DeploymentError, self.assertRaises(exceptions.DeploymentError,
self.cmd.take_action, parsed_args) self.cmd.take_action, parsed_args)
mock_cmdline.assert_called_once()
@mock.patch('os.path.isfile', return_value=False) @mock.patch('os.path.isfile', return_value=False)
def test_set_stack_action_default_create(self, mock_isfile): def test_set_stack_action_default_create(self, mock_isfile):

View File

@ -1924,3 +1924,10 @@ def check_file_for_enabled_service(env_file):
def check_deprecated_service_is_enabled(environment_files): def check_deprecated_service_is_enabled(environment_files):
for env_file in environment_files: for env_file in environment_files:
check_file_for_enabled_service(env_file) 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')
sys.stdout.flush()

View File

@ -1400,6 +1400,7 @@ class Deploy(command.Command):
raise exceptions.UndercloudUpgradeNotConfirmed("(ctrl-d) %s" % raise exceptions.UndercloudUpgradeNotConfirmed("(ctrl-d) %s" %
unconf_msg) unconf_msg)
try:
if parsed_args.standalone: if parsed_args.standalone:
if self._standalone_deploy(parsed_args) != 0: if self._standalone_deploy(parsed_args) != 0:
msg = _('Deployment failed.') msg = _('Deployment failed.')
@ -1409,3 +1410,7 @@ class Deploy(command.Command):
msg = _('Non-standalone is currently not supported') msg = _('Non-standalone is currently not supported')
self.log.error(msg) self.log.error(msg)
raise exceptions.DeploymentError(msg) raise exceptions.DeploymentError(msg)
finally:
# send erase sequence to reset the cmdline if paunch/ansible
# mangled some escape sequences
utils.send_cmdline_erase_sequence()