'Rescue the specified instance.
Attach the image that the instance was created from and boot from it.'

def rescue(self, context, instance, network_info, image_meta):

    vm_ref = vm_util.get_vm_ref(self._session, instance)
    vmdk = vm_util.get_vmdk_info(self._session, vm_ref, uuid=instance.uuid)
    ds_ref = vmdk.device.backing.datastore
    datastore = ds_obj.get_datastore_by_ref(self._session, ds_ref)
    dc_info = self.get_datacenter_ref_and_name(datastore.ref)
    image_info = images.VMwareImage.from_image(context, image_meta.id, image_meta)
    vi = VirtualMachineInstanceConfigInfo(instance, image_info, datastore, dc_info, self._imagecache)
    vm_util.power_off_instance(self._session, instance, vm_ref)
    self._fetch_image_if_missing(context, vi)
    rescue_disk_path = datastore.build_path(instance.uuid, ('%s-rescue.%s' % (image_info.image_id, image_info.file_type)))
    ds_util.disk_copy(self._session, dc_info.ref, vi.cache_image_path, rescue_disk_path)
    self._volumeops.attach_disk_to_vm(vm_ref, instance, vmdk.adapter_type, vmdk.disk_type, rescue_disk_path)
    rescue_device = self._get_rescue_device(instance, vm_ref)
    factory = self._session.vim.client.factory
    boot_spec = vm_util.get_vm_boot_spec(factory, rescue_device)
    vm_util.reconfigure_vm(self._session, vm_ref, boot_spec)
    vm_util.power_on_instance(self._session, instance, vm_ref=vm_ref)
