Merge "Deprecate cinder-manage logs commands"
This commit is contained in:
commit
34287736f7
@ -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 <num_entries> of the cinder syslog events."""
|
||||
|
||||
print(self.deprecation_msg)
|
||||
|
||||
entries = int(num_entries)
|
||||
count = 0
|
||||
log_file = ''
|
||||
|
@ -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)
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
|
||||
deprecations:
|
||||
- |
|
||||
Deprecate the "cinder-manage logs" commands. These will be removed
|
||||
in a later release.
|
Loading…
x
Reference in New Issue
Block a user