Merge "Use the list when get information from libvirt"
This commit is contained in:
commit
23158ad8b3
|
@ -6443,6 +6443,28 @@ class LibvirtConnTestCase(test.TestCase):
|
|||
self.mox.ReplayAll()
|
||||
self.assertTrue(conn._is_storage_shared_with('foo', '/path'))
|
||||
|
||||
def test_get_domain_info_with_more_return(self):
|
||||
mock_domain = libvirt.virDomain('qemu:///system', None)
|
||||
instance = {"name": "instancename", "id": "instanceid",
|
||||
"uuid": "875a8070-d0b9-4949-8b31-104d125c9a64"}
|
||||
|
||||
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
with contextlib.nested(
|
||||
mock.patch.object(mock_domain, 'info',
|
||||
return_value=[1, 2048, 737, 8, 12345, 888888]),
|
||||
mock.patch.object(mock_domain, 'ID', return_value="123456"),
|
||||
mock.patch.object(conn, '_lookup_by_name',
|
||||
return_value=mock_domain),
|
||||
) as (mock_info, mock_ID, mock_domain):
|
||||
info = conn.get_info(instance)
|
||||
expect = {'state': 1,
|
||||
'max_mem': 2048,
|
||||
'mem': 737,
|
||||
'num_cpu': 8,
|
||||
'cpu_time': 12345,
|
||||
'id': '123456'}
|
||||
self.assertEqual(expect, info)
|
||||
|
||||
def test_create_domain_define_xml_fails(self):
|
||||
"""Tests that the xml is logged when defining the domain fails."""
|
||||
fake_xml = "<test>this is a test</test>"
|
||||
|
|
|
@ -891,8 +891,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
# If the instance is already shut off, we get this:
|
||||
# Code=55 Error=Requested operation is not valid:
|
||||
# domain is not running
|
||||
(state, _max_mem, _mem, _cpus, _t) = virt_dom.info()
|
||||
state = LIBVIRT_POWER_STATE[state]
|
||||
state = LIBVIRT_POWER_STATE[virt_dom.info()[0]]
|
||||
if state == power_state.SHUTDOWN:
|
||||
is_okay = True
|
||||
elif errcode == libvirt.VIR_ERR_OPERATION_TIMEOUT:
|
||||
|
@ -1495,8 +1494,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
|
||||
snapshot_name = uuid.uuid4().hex
|
||||
|
||||
(state, _max_mem, _mem, _cpus, _t) = virt_dom.info()
|
||||
state = LIBVIRT_POWER_STATE[state]
|
||||
state = LIBVIRT_POWER_STATE[virt_dom.info()[0]]
|
||||
|
||||
# NOTE(rmk): Live snapshots require QEMU 1.3 and Libvirt 1.0.0.
|
||||
# These restrictions can be relaxed as other configurations
|
||||
|
@ -1998,8 +1996,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
:returns: True if the reboot succeeded
|
||||
"""
|
||||
dom = self._lookup_by_name(instance["name"])
|
||||
(state, _max_mem, _mem, _cpus, _t) = dom.info()
|
||||
state = LIBVIRT_POWER_STATE[state]
|
||||
state = LIBVIRT_POWER_STATE[dom.info()[0]]
|
||||
old_domid = dom.ID()
|
||||
# NOTE(vish): This check allows us to reboot an instance that
|
||||
# is already shutdown.
|
||||
|
@ -2012,8 +2009,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
pci_manager.get_instance_pci_devs(instance))
|
||||
for x in xrange(CONF.libvirt.wait_soft_reboot_seconds):
|
||||
dom = self._lookup_by_name(instance["name"])
|
||||
(state, _max_mem, _mem, _cpus, _t) = dom.info()
|
||||
state = LIBVIRT_POWER_STATE[state]
|
||||
state = LIBVIRT_POWER_STATE[dom.info()[0]]
|
||||
new_domid = dom.ID()
|
||||
|
||||
# NOTE(ivoks): By checking domain IDs, we make sure we are
|
||||
|
@ -3492,12 +3488,12 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
|
||||
"""
|
||||
virt_dom = self._lookup_by_name(instance['name'])
|
||||
(state, max_mem, mem, num_cpu, cpu_time) = virt_dom.info()
|
||||
return {'state': LIBVIRT_POWER_STATE[state],
|
||||
'max_mem': max_mem,
|
||||
'mem': mem,
|
||||
'num_cpu': num_cpu,
|
||||
'cpu_time': cpu_time,
|
||||
dom_info = virt_dom.info()
|
||||
return {'state': LIBVIRT_POWER_STATE[dom_info[0]],
|
||||
'max_mem': dom_info[1],
|
||||
'mem': dom_info[2],
|
||||
'num_cpu': dom_info[3],
|
||||
'cpu_time': dom_info[4],
|
||||
'id': virt_dom.ID()}
|
||||
|
||||
def _create_domain(self, xml=None, domain=None,
|
||||
|
|
Loading…
Reference in New Issue