VMware: fix TypeError while get console log
nova.privsep.path.last_bytes needs path instead of FILE.
Change-Id: Ifad71b4583b23ff018d757760a7b79f7f838c755
Closes-Bug: #1752824
(cherry picked from commit 87a6bb4184
)
This commit is contained in:
parent
ff200e12ef
commit
997b38503b
|
@ -1705,16 +1705,14 @@ class VMwareAPIVMTestCase(test.NoDBTestCase,
|
|||
self._create_instance()
|
||||
with test.nested(
|
||||
mock.patch('os.path.exists', return_value=True),
|
||||
mock.patch('{}.open'.format(driver.__name__), create=True),
|
||||
mock.patch('nova.privsep.path.last_bytes')
|
||||
) as (fake_exists, fake_open, fake_last_bytes):
|
||||
fake_open.return_value = mock.MagicMock()
|
||||
fake_fd = fake_open.return_value.__enter__.return_value
|
||||
) as (fake_exists, fake_last_bytes):
|
||||
fake_last_bytes.return_value = b'fira', 0
|
||||
output = self.conn.get_console_output(self.context, self.instance)
|
||||
fname = self.instance.uuid.replace('-', '')
|
||||
fake_exists.assert_called_once_with('/opt/vspc/{}'.format(fname))
|
||||
fake_last_bytes.assert_called_once_with(fake_fd,
|
||||
fpath = '/opt/vspc/{}'.format(fname)
|
||||
fake_exists.assert_called_once_with(fpath)
|
||||
fake_last_bytes.assert_called_once_with(fpath,
|
||||
driver.MAX_CONSOLE_BYTES)
|
||||
self.assertEqual(b'fira', output)
|
||||
|
||||
|
|
|
@ -284,10 +284,9 @@ class VMwareVCDriver(driver.ComputeDriver):
|
|||
LOG.warning('The console log is missing. Check your VSPC '
|
||||
'configuration', instance=instance)
|
||||
return b""
|
||||
with open(path, 'rb') as fp:
|
||||
read_log_data, remaining = nova.privsep.path.last_bytes(
|
||||
fp, MAX_CONSOLE_BYTES)
|
||||
return read_log_data
|
||||
read_log_data, remaining = nova.privsep.path.last_bytes(
|
||||
path, MAX_CONSOLE_BYTES)
|
||||
return read_log_data
|
||||
|
||||
def _get_vcenter_uuid(self):
|
||||
"""Retrieves the vCenter UUID."""
|
||||
|
|
Loading…
Reference in New Issue