Merge "Recache or rebuild missing images on hard_reboot"
This commit is contained in:
@@ -486,7 +486,8 @@ class HyperVAPITestCase(test.TestCase):
|
||||
constants.HYPERV_VM_STATE_REBOOT)
|
||||
|
||||
self._mox.ReplayAll()
|
||||
self._conn.reboot(self._instance_data, network_info, None)
|
||||
self._conn.reboot(self._context, self._instance_data, network_info,
|
||||
None)
|
||||
self._mox.VerifyAll()
|
||||
|
||||
def test_destroy(self):
|
||||
|
||||
@@ -55,8 +55,8 @@ class _ImageTestCase(object):
|
||||
|
||||
def test_cache(self):
|
||||
self.mox.StubOutWithMock(os.path, 'exists')
|
||||
os.path.exists(self.PATH).AndReturn(False)
|
||||
os.path.exists(self.TEMPLATE_DIR).AndReturn(False)
|
||||
os.path.exists(self.PATH).AndReturn(False)
|
||||
os.path.exists(self.TEMPLATE_PATH).AndReturn(False)
|
||||
fn = self.mox.CreateMockAnything()
|
||||
fn(target=self.TEMPLATE_PATH)
|
||||
@@ -72,7 +72,9 @@ class _ImageTestCase(object):
|
||||
|
||||
def test_cache_image_exists(self):
|
||||
self.mox.StubOutWithMock(os.path, 'exists')
|
||||
os.path.exists(self.TEMPLATE_DIR).AndReturn(True)
|
||||
os.path.exists(self.PATH).AndReturn(True)
|
||||
os.path.exists(self.TEMPLATE_PATH).AndReturn(True)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
image = self.image_class(self.INSTANCE, self.NAME)
|
||||
@@ -82,8 +84,8 @@ class _ImageTestCase(object):
|
||||
|
||||
def test_cache_base_dir_exists(self):
|
||||
self.mox.StubOutWithMock(os.path, 'exists')
|
||||
os.path.exists(self.PATH).AndReturn(False)
|
||||
os.path.exists(self.TEMPLATE_DIR).AndReturn(True)
|
||||
os.path.exists(self.PATH).AndReturn(False)
|
||||
os.path.exists(self.TEMPLATE_PATH).AndReturn(False)
|
||||
fn = self.mox.CreateMockAnything()
|
||||
fn(target=self.TEMPLATE_PATH)
|
||||
@@ -98,8 +100,8 @@ class _ImageTestCase(object):
|
||||
|
||||
def test_cache_template_exists(self):
|
||||
self.mox.StubOutWithMock(os.path, 'exists')
|
||||
os.path.exists(self.PATH).AndReturn(False)
|
||||
os.path.exists(self.TEMPLATE_DIR).AndReturn(True)
|
||||
os.path.exists(self.PATH).AndReturn(False)
|
||||
os.path.exists(self.TEMPLATE_PATH).AndReturn(True)
|
||||
fn = self.mox.CreateMockAnything()
|
||||
self.mox.ReplayAll()
|
||||
@@ -195,7 +197,6 @@ class Qcow2TestCase(_ImageTestCase, test.TestCase):
|
||||
def test_create_image_with_size(self):
|
||||
fn = self.prepare_mocks()
|
||||
fn(target=self.TEMPLATE_PATH)
|
||||
self.mox.StubOutWithMock(os.path, 'exists')
|
||||
imagebackend.libvirt_utils.create_cow_image(self.TEMPLATE_PATH,
|
||||
self.PATH)
|
||||
imagebackend.disk.extend(self.PATH, self.SIZE)
|
||||
|
||||
@@ -4206,7 +4206,7 @@ class LibvirtDriverTestCase(test.TestCase):
|
||||
|
||||
self.counter = 0
|
||||
|
||||
def fake_get_instance_disk_info(instance):
|
||||
def fake_get_instance_disk_info(instance, xml=None):
|
||||
return '[]'
|
||||
|
||||
def fake_destroy(instance):
|
||||
@@ -4251,7 +4251,7 @@ class LibvirtDriverTestCase(test.TestCase):
|
||||
'disk_size':'83886080'}]
|
||||
disk_info_text = jsonutils.dumps(disk_info)
|
||||
|
||||
def fake_get_instance_disk_info(instance):
|
||||
def fake_get_instance_disk_info(instance, xml=None):
|
||||
return disk_info_text
|
||||
|
||||
def fake_destroy(instance):
|
||||
|
||||
@@ -104,6 +104,13 @@ class _FakeDriverBackendTestCase(object):
|
||||
def fake_make_drive(_self, _path):
|
||||
pass
|
||||
|
||||
def fake_get_instance_disk_info(_self, instance, xml=None):
|
||||
return '[]'
|
||||
|
||||
self.stubs.Set(nova.virt.libvirt.driver.LibvirtDriver,
|
||||
'get_instance_disk_info',
|
||||
fake_get_instance_disk_info)
|
||||
|
||||
self.stubs.Set(nova.virt.libvirt.driver.disk,
|
||||
'extend', fake_extend)
|
||||
|
||||
@@ -227,7 +234,8 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
|
||||
def test_reboot(self):
|
||||
reboot_type = "SOFT"
|
||||
instance_ref, network_info = self._get_running_instance()
|
||||
self.connection.reboot(instance_ref, network_info, reboot_type)
|
||||
self.connection.reboot(self.ctxt, instance_ref, network_info,
|
||||
reboot_type)
|
||||
|
||||
@catch_notimplementederror
|
||||
def test_get_host_ip_addr(self):
|
||||
|
||||
@@ -199,14 +199,16 @@ class VMwareAPIVMTestCase(test.TestCase):
|
||||
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)
|
||||
self.conn.reboot(self.context, self.instance, self.network_info,
|
||||
reboot_type)
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.RUNNING)
|
||||
|
||||
def test_reboot_non_existent(self):
|
||||
self._create_instance_in_the_db()
|
||||
self.assertRaises(exception.InstanceNotFound, self.conn.reboot,
|
||||
self.instance, self.network_info, 'SOFT')
|
||||
self.context, self.instance, self.network_info,
|
||||
'SOFT')
|
||||
|
||||
def test_reboot_not_poweredon(self):
|
||||
self._create_vm()
|
||||
@@ -216,7 +218,8 @@ class VMwareAPIVMTestCase(test.TestCase):
|
||||
info = self.conn.get_info({'name': 1})
|
||||
self._check_vm_info(info, power_state.SUSPENDED)
|
||||
self.assertRaises(exception.InstanceRebootFailure, self.conn.reboot,
|
||||
self.instance, self.network_info, 'SOFT')
|
||||
self.context, self.instance, self.network_info,
|
||||
'SOFT')
|
||||
|
||||
def test_suspend(self):
|
||||
self._create_vm()
|
||||
|
||||
@@ -955,12 +955,12 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
||||
def test_reboot_hard(self):
|
||||
instance = self._create_instance()
|
||||
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
|
||||
conn.reboot(instance, None, "HARD")
|
||||
conn.reboot(self.context, instance, None, "HARD")
|
||||
|
||||
def test_reboot_soft(self):
|
||||
instance = self._create_instance()
|
||||
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
|
||||
conn.reboot(instance, None, "SOFT")
|
||||
conn.reboot(self.context, instance, None, "SOFT")
|
||||
|
||||
def test_reboot_halted(self):
|
||||
session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass',
|
||||
@@ -968,7 +968,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
||||
instance = self._create_instance(spawn=False)
|
||||
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
|
||||
xenapi_fake.create_vm(instance['name'], 'Halted')
|
||||
conn.reboot(instance, None, "SOFT")
|
||||
conn.reboot(self.context, instance, None, "SOFT")
|
||||
vm_ref = vm_utils.lookup(session, instance['name'])
|
||||
vm = xenapi_fake.get_record('VM', vm_ref)
|
||||
self.assertEquals(vm['power_state'], 'Running')
|
||||
@@ -977,8 +977,8 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
||||
instance = self._create_instance(spawn=False)
|
||||
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
|
||||
xenapi_fake.create_vm(instance['name'], 'Unknown')
|
||||
self.assertRaises(xenapi_fake.Failure, conn.reboot, instance,
|
||||
None, "SOFT")
|
||||
self.assertRaises(xenapi_fake.Failure, conn.reboot, self.context,
|
||||
instance, None, "SOFT")
|
||||
|
||||
def _test_maintenance_mode(self, find_host, find_aggregate):
|
||||
real_call_xenapi = self.conn._session.call_xenapi
|
||||
|
||||
Reference in New Issue
Block a user