diff --git a/cinder/cmd/manage.py b/cinder/cmd/manage.py index 0cf92d38aa4..1a1c1555c01 100644 --- a/cinder/cmd/manage.py +++ b/cinder/cmd/manage.py @@ -455,8 +455,15 @@ class ConfigCommands(object): class GetLogCommands(object): """Get logging information.""" + deprecation_msg = ('DEPRECATED: The log commands are deprecated ' + 'since Queens and are not maintained. They will be ' + 'removed in an upcoming release.') + def errors(self): """Get all of the errors from the log files.""" + + print(self.deprecation_msg) + error_found = 0 if CONF.log_dir: logs = [x for x in os.listdir(CONF.log_dir) if x.endswith('.log')] @@ -480,6 +487,9 @@ class GetLogCommands(object): help='Number of entries to list (default: %(default)d)') def syslog(self, num_entries=10): """Get of the cinder syslog events.""" + + print(self.deprecation_msg) + entries = int(num_entries) count = 0 log_file = '' diff --git a/cinder/tests/unit/test_cmd.py b/cinder/tests/unit/test_cmd.py index cc575596968..240e8669735 100644 --- a/cinder/tests/unit/test_cmd.py +++ b/cinder/tests/unit/test_cmd.py @@ -493,7 +493,10 @@ class TestCinderManageCmd(test.TestCase): get_log_cmds = cinder_manage.GetLogCommands() get_log_cmds.errors() - self.assertEqual(expected_out, fake_out.getvalue()) + out_lines = fake_out.getvalue().splitlines(True) + + self.assertTrue(out_lines[0].startswith('DEPRECATED')) + self.assertEqual(expected_out, out_lines[1]) @mock.patch('six.moves.builtins.open') @mock.patch('os.listdir') @@ -504,13 +507,18 @@ class TestCinderManageCmd(test.TestCase): with mock.patch('sys.stdout', new=six.StringIO()) as fake_out: open.return_value = six.StringIO( '[ ERROR ] fake-error-message') - expected_out = ('fake-dir/fake-error.log:-\n' - 'Line 1 : [ ERROR ] fake-error-message\n') + expected_out = ['fake-dir/fake-error.log:-\n', + 'Line 1 : [ ERROR ] fake-error-message\n'] get_log_cmds = cinder_manage.GetLogCommands() get_log_cmds.errors() - self.assertEqual(expected_out, fake_out.getvalue()) + out_lines = fake_out.getvalue().splitlines(True) + + self.assertTrue(out_lines[0].startswith('DEPRECATED')) + self.assertEqual(expected_out[0], out_lines[1]) + self.assertEqual(expected_out[1], out_lines[2]) + open.assert_called_once_with('fake-dir/fake-error.log', 'r') listdir.assert_called_once_with(CONF.log_dir) diff --git a/releasenotes/notes/deprecate_logs_commands-a0d59cb7535a2138.yaml b/releasenotes/notes/deprecate_logs_commands-a0d59cb7535a2138.yaml new file mode 100644 index 00000000000..85d6ba17541 --- /dev/null +++ b/releasenotes/notes/deprecate_logs_commands-a0d59cb7535a2138.yaml @@ -0,0 +1,6 @@ +--- + +deprecations: + - | + Deprecate the "cinder-manage logs" commands. These will be removed + in a later release.