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

def _test_migrate_disk_and_power_off(self, flavor_obj, block_device_info=None, params_for_instance=None):

    instance = self._create_instance(params=params_for_instance)
    disk_info = list(fake_disk_info_byname(instance).values())
    disk_info_text = jsonutils.dumps(disk_info)
    def fake_get_instance_disk_info(instance, block_device_info):
        return disk_info
    def fake_destroy(instance):
        pass
    def fake_get_host_ip_addr():
        return '10.0.0.1'
    def fake_execute(*args, **kwargs):
        pass
    def fake_copy_image(src, dest, host=None, receive=False, on_execute=None, on_completion=None, compression=True):
        self.assertIsNotNone(on_execute)
        self.assertIsNotNone(on_completion)
    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(utils, 'execute', fake_execute)
    self.stubs.Set(libvirt_utils, 'copy_image', fake_copy_image)
    out = self.drvr.migrate_disk_and_power_off(context.get_admin_context(), instance, '10.0.0.2', flavor_obj, None, block_device_info=block_device_info)
    self.assertEqual(out, disk_info_text)
    out = self.drvr.migrate_disk_and_power_off(context.get_admin_context(), instance, '10.0.0.1', flavor_obj, None, block_device_info=block_device_info)
    self.assertEqual(out, disk_info_text)
