'Calculate resource usage based on instance utilization.  This is
different than the hypervisor\'s view as it will account for all
instances assigned to the local compute host, even if they are not
currently powered on.'

def _update_usage_from_instances(self, context, instances, nodename):

    self.tracked_instances.clear()
    cn = self.compute_nodes[nodename]
    cn.local_gb_used = (CONF.reserved_host_disk_mb / 1024)
    cn.memory_mb_used = CONF.reserved_host_memory_mb
    cn.vcpus_used = CONF.reserved_host_cpus
    cn.free_ram_mb = (cn.memory_mb - cn.memory_mb_used)
    cn.free_disk_gb = (cn.local_gb - cn.local_gb_used)
    cn.current_workload = 0
    cn.running_vms = 0
    for instance in instances:
        if (instance.vm_state not in vm_states.ALLOW_RESOURCE_REMOVAL):
            self._update_usage_from_instance(context, instance, nodename)
    self._remove_deleted_instances_allocations(context, cn)
