The hypervisor is returning its own view of the number of vcpus used. This is copied to the compute_node record and is not reset before adding the resource tracker view. Code to reset the memory and disk is included in _update_usage_from_instances() as below. The extensible resource plugins are called here as well. Now the vcpu resource has gone and the accounting is directly in the compute_node object the vcpus_used should be reset to 0 here.
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()
The hypervisor is returning its own view of the number of vcpus used. This is copied to the compute_node record and is not reset before adding the resource tracker view. Code to reset the memory and disk is included in _update_ usage_from_ instances( ) as below. The extensible resource plugins are called here as well. Now the vcpu resource has gone and the accounting is directly in the compute_node object the vcpus_used should be reset to 0 here.
def _update_ usage_from_ instances( self, context, instances):
"""Calculate resource usage based on instance utilization. This is
self.tracked_ instances. clear()
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.
"""
# 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.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
# Reset values for extended resources
self.ext_ resources_ handler. reset_resources (self.compute_ node,
self. driver)