Browse Source

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 fddcb9e075)
tags/11.5.1
Alex Schultz 1 month ago
parent
commit
ffb86df965

+ 3
- 3
tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py View File

@@ -889,7 +889,7 @@ class TestDeployUndercloud(TestPluginV1):
889 889
             env
890 890
         )
891 891
 
892
-    @mock.patch('tripleoclient.utils.send_cmdline_erase_sequence')
892
+    @mock.patch('tripleoclient.utils.reset_cmdline')
893 893
     @mock.patch('tripleo_common.actions.ansible.'
894 894
                 'write_default_ansible_cfg')
895 895
     # TODO(cjeanner) drop once we have proper oslo.privsep
@@ -975,7 +975,7 @@ class TestDeployUndercloud(TestPluginV1):
975 975
         self.assertEqual(mock_killheat.call_count, 2)
976 976
         mock_cmdline.assert_called_once()
977 977
 
978
-    @mock.patch('tripleoclient.utils.send_cmdline_erase_sequence')
978
+    @mock.patch('tripleoclient.utils.reset_cmdline')
979 979
     @mock.patch('tripleoclient.utils.ansible_symlink')
980 980
     def test_take_action(self, mock_slink, mock_cmdline):
981 981
         mock_slink.side_effect = 'fake-cmd'
@@ -988,7 +988,7 @@ class TestDeployUndercloud(TestPluginV1):
988 988
                           self.cmd.take_action, parsed_args)
989 989
         mock_cmdline.assert_called_once()
990 990
 
991
-    @mock.patch('tripleoclient.utils.send_cmdline_erase_sequence')
991
+    @mock.patch('tripleoclient.utils.reset_cmdline')
992 992
     @mock.patch('tripleoclient.v1.tripleo_deploy.Deploy._standalone_deploy',
993 993
                 return_value=1)
994 994
     @mock.patch('tripleoclient.utils.ansible_symlink')

+ 6
- 4
tripleoclient/utils.py View File

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

+ 1
- 1
tripleoclient/v1/tripleo_deploy.py View File

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

Loading…
Cancel
Save