Merge "Move get_info to taking an instance."
This commit is contained in:
@@ -282,7 +282,8 @@ class ProxyBareMetalTestCase(test.TestCase):
|
||||
|
||||
# Code under test
|
||||
conn = proxy.get_connection(True)
|
||||
info = conn.get_info('instance-00000001')
|
||||
# TODO: this is not a very good fake instance
|
||||
info = conn.get_info({'name': 'instance-00000001'})
|
||||
|
||||
# Expected values
|
||||
self.assertEquals(info['mem'], 16777216)
|
||||
|
@@ -2208,10 +2208,10 @@ class LibvirtConnectionTestCase(test.TestCase):
|
||||
"""Test for nova.virt.libvirt.connection.LivirtConnection
|
||||
._wait_for_running. """
|
||||
|
||||
def fake_get_info(instance_name):
|
||||
if instance_name == "not_found":
|
||||
def fake_get_info(instance):
|
||||
if instance['name'] == "not_found":
|
||||
raise exception.NotFound
|
||||
elif instance_name == "running":
|
||||
elif instance['name'] == "running":
|
||||
return {'state': power_state.RUNNING}
|
||||
else:
|
||||
return {'state': power_state.SHUTOFF}
|
||||
@@ -2222,15 +2222,18 @@ class LibvirtConnectionTestCase(test.TestCase):
|
||||
""" instance not found case """
|
||||
self.assertRaises(utils.LoopingCallDone,
|
||||
self.libvirtconnection._wait_for_running,
|
||||
"not_found")
|
||||
{'name': 'not_found',
|
||||
'uuid': 'not_found_uuid'})
|
||||
|
||||
""" instance is running case """
|
||||
self.assertRaises(utils.LoopingCallDone,
|
||||
self.libvirtconnection._wait_for_running,
|
||||
"running")
|
||||
{'name': 'running',
|
||||
'uuid': 'running_uuid'})
|
||||
|
||||
""" else case """
|
||||
self.libvirtconnection._wait_for_running("else")
|
||||
self.libvirtconnection._wait_for_running({'name': 'else',
|
||||
'uuid': 'other_uuid'})
|
||||
|
||||
def test_finish_migration(self):
|
||||
"""Test for nova.virt.libvirt.connection.LivirtConnection
|
||||
|
@@ -245,7 +245,7 @@ class _VirtDriverTestCase(test.TestCase):
|
||||
@catch_notimplementederror
|
||||
def test_get_info(self):
|
||||
instance_ref, network_info = self._get_running_instance()
|
||||
info = self.connection.get_info(instance_ref['name'])
|
||||
info = self.connection.get_info(instance_ref)
|
||||
self.assertIn('state', info)
|
||||
self.assertIn('max_mem', info)
|
||||
self.assertIn('mem', info)
|
||||
@@ -255,7 +255,8 @@ class _VirtDriverTestCase(test.TestCase):
|
||||
@catch_notimplementederror
|
||||
def test_get_info_for_unknown_instance(self):
|
||||
self.assertRaises(exception.NotFound,
|
||||
self.connection.get_info, 'I just made this name up')
|
||||
self.connection.get_info,
|
||||
{'name': 'I just made this name up'})
|
||||
|
||||
@catch_notimplementederror
|
||||
def test_get_diagnostics(self):
|
||||
|
@@ -114,7 +114,7 @@ class VMWareAPIVMTestCase(test.TestCase):
|
||||
self.assertEquals(len(instances), 1)
|
||||
|
||||
# Get Nova record for VM
|
||||
vm_info = self.conn.get_info(1)
|
||||
vm_info = self.conn.get_info({'name': 1})
|
||||
|
||||
# Get record for VM
|
||||
vms = vmwareapi_fake._get_objects("VirtualMachine")
|
||||
@@ -157,15 +157,15 @@ class VMWareAPIVMTestCase(test.TestCase):
|
||||
|
||||
def test_spawn(self):
|
||||
self._create_vm()
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
|
||||
def test_snapshot(self):
|
||||
self._create_vm()
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
self.conn.snapshot(self.context, self.instance, "Test-Snapshot")
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
|
||||
def test_snapshot_non_existent(self):
|
||||
@@ -175,11 +175,11 @@ class VMWareAPIVMTestCase(test.TestCase):
|
||||
|
||||
def test_reboot(self):
|
||||
self._create_vm()
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
reboot_type = "SOFT"
|
||||
self.conn.reboot(self.instance, self.network_info, reboot_type)
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
|
||||
def test_reboot_non_existent(self):
|
||||
@@ -188,19 +188,19 @@ class VMWareAPIVMTestCase(test.TestCase):
|
||||
|
||||
def test_reboot_not_poweredon(self):
|
||||
self._create_vm()
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
self.conn.suspend(self.instance)
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.PAUSED)
|
||||
self.assertRaises(Exception, self.conn.reboot, self.instance)
|
||||
|
||||
def test_suspend(self):
|
||||
self._create_vm()
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
self.conn.suspend(self.instance)
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.PAUSED)
|
||||
|
||||
def test_suspend_non_existent(self):
|
||||
@@ -209,13 +209,13 @@ class VMWareAPIVMTestCase(test.TestCase):
|
||||
|
||||
def test_resume(self):
|
||||
self._create_vm()
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
self.conn.suspend(self.instance)
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.PAUSED)
|
||||
self.conn.resume(self.instance)
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
|
||||
def test_resume_non_existent(self):
|
||||
@@ -224,18 +224,18 @@ class VMWareAPIVMTestCase(test.TestCase):
|
||||
|
||||
def test_resume_not_suspended(self):
|
||||
self._create_vm()
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
self.assertRaises(Exception, self.conn.resume, self.instance)
|
||||
|
||||
def test_get_info(self):
|
||||
self._create_vm()
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
|
||||
def test_destroy(self):
|
||||
self._create_vm()
|
||||
info = self.conn.get_info(1)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
instances = self.conn.list_instances()
|
||||
self.assertEquals(len(instances), 1)
|
||||
|
@@ -332,7 +332,7 @@ class XenAPIVMTestCase(test.TestCase):
|
||||
self.assertEquals(instances, [str(instance_id)])
|
||||
|
||||
# Get Nova record for VM
|
||||
vm_info = conn.get_info(instance_id)
|
||||
vm_info = conn.get_info({'name': instance_id})
|
||||
# Get XenAPI record for VM
|
||||
vms = [rec for ref, rec
|
||||
in xenapi_fake.get_all_records('VM').iteritems()
|
||||
|
Reference in New Issue
Block a user