Trivial: Fixes serial console minor nits

Commit [1] suggested that reversed() should be used
instead of [::-1].

Commit [2] suggested that a comment should be added with
the expected pipe_path format.

[1] f554c3f777
[2] f98af85eb2

Change-Id: I29e87a665d6bbcfc2f3c0d635b2d0fe252f3229b
This commit is contained in:
Claudiu Belu
2016-05-24 10:40:48 -07:00
parent 14d6a424ff
commit 9fb086a019
3 changed files with 5 additions and 3 deletions

View File

@@ -93,14 +93,14 @@ class SerialConsoleOpsTestCase(test_base.HyperVBaseTestCase):
@mock.patch("os.path.exists")
def test_get_console_output_exception(self, fake_path_exists, fake_open):
self._serialops._pathutils.get_vm_console_log_paths.return_value = [
mock.sentinel.log_path]
mock.sentinel.log_path_1, mock.sentinel.log_path_2]
fake_open.side_effect = IOError
fake_path_exists.return_value = True
self.assertRaises(exception.ConsoleLogOutputException,
self._serialops.get_console_output,
mock.sentinel.instance_name)
fake_open.assert_called_once_with(mock.sentinel.log_path, 'rb')
fake_open.assert_called_once_with(mock.sentinel.log_path_2, 'rb')
@mock.patch('os.path.exists')
@mock.patch.object(serialconsoleops.SerialConsoleOps,

View File

@@ -145,6 +145,8 @@ class SerialConsoleHandler(object):
# as we can't use the serial port ElementName attribute because of
# a Hyper-V bug.
for pipe_path in serial_port_conns:
# expected pipe_path:
# '\\.\pipe\fc1bcc91-c7d3-4116-a210-0cd151e019cd_rw'
port_type = pipe_path[-2:]
if port_type in [constants.SERIAL_PORT_TYPE_RO,
constants.SERIAL_PORT_TYPE_RW]:

View File

@@ -93,7 +93,7 @@ class SerialConsoleOps(object):
try:
log = b''
# Start with the oldest console log file.
for log_path in console_log_paths[::-1]:
for log_path in reversed(console_log_paths):
if os.path.exists(log_path):
with open(log_path, 'rb') as fp:
log += fp.read()