'Update usage for a single instance.'

def _update_usage_from_instance(self, context, instance, nodename, is_removed=False):

    uuid = instance['uuid']
    is_new_instance = (uuid not in self.tracked_instances)
    is_removed_instance = ((not is_new_instance) and (is_removed or (instance['vm_state'] in vm_states.ALLOW_RESOURCE_REMOVAL)))
    if is_new_instance:
        self.tracked_instances[uuid] = obj_base.obj_to_primitive(instance)
        sign = 1
    if is_removed_instance:
        self.tracked_instances.pop(uuid)
        sign = (-1)
    cn = self.compute_nodes[nodename]
    self.stats.update_stats_for_instance(instance, is_removed_instance)
    cn.stats = copy.deepcopy(self.stats)
    if (is_new_instance or is_removed_instance):
        if self.pci_tracker:
            self.pci_tracker.update_pci_for_instance(context, instance, sign=sign)
        self.reportclient.update_instance_allocation(cn, instance, sign)
        self._update_usage(self._get_usage_dict(instance), nodename, sign=sign)
    cn.current_workload = self.stats.calculate_workload()
    if self.pci_tracker:
        obj = self.pci_tracker.stats.to_device_pools_obj()
        cn.pci_device_pools = obj
    else:
        cn.pci_device_pools = objects.PciDevicePoolList()
