'Get xapi OpaqueRef from a db record.
:param check_rescue: if True will return the \'name\'-rescue vm if it
exists, instead of just \'name\''

def _get_vm_opaque_ref(self, instance, check_rescue=False):

    vm_ref = vm_utils.lookup(self._session, instance['name'], check_rescue)
    if (vm_ref is None):
        raise exception.InstanceNotFound(instance_id=instance['name'])
    return vm_ref
