'Test for nova.virt.libvirt.libvirt_driver.LivirtConnection
.migrate_disk_and_power_off.'

def test_migrate_disk_and_power_off_exception(self):

    self.counter = 0
    self.checked_shared_storage = False
    def fake_get_instance_disk_info(instance, block_device_info):
        return []
    def fake_destroy(instance):
        pass
    def fake_get_host_ip_addr():
        return '10.0.0.1'
    def fake_execute(*args, **kwargs):
        self.counter += 1
        if (self.counter == 1):
            assert False, 'intentional    failure'
    def fake_os_path_exists(path):
        return True
    def fake_is_storage_shared(dest, inst_base):
        self.checked_shared_storage = True
        return False
    self.stubs.Set(self.drvr, '_get_instance_disk_info', fake_get_instance_disk_info)
    self.stubs.Set(self.drvr, '_destroy', fake_destroy)
    self.stubs.Set(self.drvr, 'get_host_ip_addr', fake_get_host_ip_addr)
    self.stubs.Set(self.drvr, '_is_storage_shared_with', fake_is_storage_shared)
    self.stubs.Set(utils, 'execute', fake_execute)
    self.stub_out('os.path.exists', fake_os_path_exists)
    ins_ref = self._create_instance()
    flavor = {'root_gb': 10, 'ephemeral_gb': 20}
    flavor_obj = objects.Flavor(**flavor)
    self.assertRaises(AssertionError, self.drvr.migrate_disk_and_power_off, context.get_admin_context(), ins_ref, '10.0.0.2', flavor_obj, None)
