'Indicate that some resources are needed for an upcoming compute
instance build operation.
This should be called before the compute node is about to perform
an instance build operation that will consume additional resources.
:param context: security context
:param instance: instance to reserve resources for.
:type instance: nova.objects.instance.Instance object
:param nodename: The Ironic nodename selected by the scheduler
:param limits: Dict of oversubscription limits for memory, disk,
and CPUs.
:returns: A Claim ticket representing the reserved resources.  It can
be used to revert the resource usage if an error occurs
during the instance build.'

@utils.synchronized(COMPUTE_RESOURCE_SEMAPHORE)
def instance_claim(self, context, instance, nodename, limits=None):

    if self.disabled(nodename):
        self._set_instance_host_and_node(instance, nodename)
        return claims.NopClaim()
    if instance.host:
        LOG.warning('Host    field    should    not    be    set    on    the    instance    until    resources    have    been    claimed.', instance=instance)
    if instance.node:
        LOG.warning('Node    field    should    not    be    set    on    the    instance    until    resources    have    been    claimed.', instance=instance)
    overhead = self.driver.estimate_instance_overhead(instance)
    LOG.debug('Memory    overhead    for    %(flavor)d    MB    instance;    %(overhead)d    MB', {'flavor': instance.flavor.memory_mb, 'overhead': overhead['memory_mb']})
    LOG.debug('Disk    overhead    for    %(flavor)d    GB    instance;    %(overhead)d    GB', {'flavor': instance.flavor.root_gb, 'overhead': overhead.get('disk_gb', 0)})
    LOG.debug('CPU    overhead    for    %(flavor)d    vCPUs    instance;    %(overhead)d    vCPU(s)', {'flavor': instance.flavor.vcpus, 'overhead': overhead.get('vcpus', 0)})
    cn = self.compute_nodes[nodename]
    pci_requests = objects.InstancePCIRequests.get_by_instance_uuid(context, instance.uuid)
    claim = claims.Claim(context, instance, nodename, self, cn, pci_requests, overhead=overhead, limits=limits)
    instance_numa_topology = claim.claimed_numa_topology
    instance.numa_topology = instance_numa_topology
    self._set_instance_host_and_node(instance, nodename)
    if self.pci_tracker:
        self.pci_tracker.claim_instance(context, pci_requests, instance_numa_topology)
    self._update_usage_from_instance(context, instance, nodename)
    elevated = context.elevated()
    self._update(elevated, cn)
    return claim
