libvirt: guest: introduce blockStats instead of domain.blockStats
We should use nova.virt.libvirt.Guest instead of call from a virDomain object. Change-Id: Ifa8fe1b19980cc9e986d26b284d2fb093466d30c Signed-off-by: Chen Hanxiao <chenhx@certusnet.com.cn>
This commit is contained in:
parent
054e24702f
commit
f1e937e6a6
|
@ -813,6 +813,10 @@ class GuestBlockTestCase(test.NoDBTestCase):
|
|||
self.assertRaises(fakelibvirt.libvirtError,
|
||||
self.gblock.is_job_complete)
|
||||
|
||||
def test_blockStats(self):
|
||||
self.gblock.blockStats()
|
||||
self.domain.blockStats.assert_called_once_with('vda')
|
||||
|
||||
|
||||
class JobInfoTestCase(test.NoDBTestCase):
|
||||
|
||||
|
|
|
@ -6390,12 +6390,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
"""Note that this function takes an instance name."""
|
||||
try:
|
||||
guest = self._host.get_guest(instance)
|
||||
|
||||
# TODO(sahid): We are converting all calls from a
|
||||
# virDomain object to use nova.virt.libvirt.Guest.
|
||||
# We should be able to remove domain at the end.
|
||||
domain = guest._domain
|
||||
return domain.blockStats(disk_id)
|
||||
dev = guest.get_block_device(disk_id)
|
||||
return dev.blockStats()
|
||||
except libvirt.libvirtError as e:
|
||||
errcode = e.get_error_code()
|
||||
LOG.info('Getting block stats failed, device might have '
|
||||
|
|
|
@ -861,6 +861,10 @@ class BlockDevice(object):
|
|||
|
||||
return False
|
||||
|
||||
def blockStats(self):
|
||||
"""Extracts block device statistics for a domain"""
|
||||
return self._guest._domain.blockStats(self._disk)
|
||||
|
||||
|
||||
class VCPUInfo(object):
|
||||
def __init__(self, id, cpu, state, time):
|
||||
|
|
Loading…
Reference in New Issue