def _update_usage_from_instances(self, context, instances):
        """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.
        """
        self.tracked_instances.clear()

        # set some initial values, reserve room for host/hypervisor:
        self.compute_node.local_gb_used = CONF.reserved_host_disk_mb / 1024
        self.compute_node.memory_mb_used = CONF.reserved_host_memory_mb
        self.compute_node.vcpus_used = 0
        self.compute_node.free_ram_mb = (self.compute_node.memory_mb -
                                         self.compute_node.memory_mb_used)
        self.compute_node.free_disk_gb = (self.compute_node.local_gb -
                                          self.compute_node.local_gb_used)
        self.compute_node.current_workload = 0
        self.compute_node.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)
dataset/ETHPy150Open openstack/nova/nova/compute/resource_tracker.py/ResourceTracker._update_usage_from_instances/original