def update_available_resource(self, context): """Override in-memory calculations of compute node resource usage based on data audited from the hypervisor layer. Add in resource claims in progress to account for operations that have declared a need for resources, but not necessarily retrieved them from the hypervisor layer yet. """ LOG.audit(_("Auditing locally available compute resources")) resources = self.driver.get_available_resource(self.nodename) if not resources: # The virt driver does not support this function LOG.audit( _("Virt driver does not support " "'get_available_resource' Compute tracking is disabled.")) self.compute_node = None return self._verify_resources(resources) self._report_hypervisor_resource_view(resources) # Grab all instances assigned to this node: instances = db.instance_get_all_by_host_and_node( context, self.host, self.nodename) # Now calculate usage based on instance utilization: self._update_usage_from_instances(resources, instances) # Grab all in-progress migrations: migrations = db.migration_get_in_progress_by_host(context, self.host) self._update_usage_from_migrations(resources, migrations) self._report_final_resource_view(resources) self._sync_compute_node(context, resources)
def update_available_resource(self, context): """Override in-memory calculations of compute node resource usage based on data audited from the hypervisor layer. Add in resource claims in progress to account for operations that have declared a need for resources, but not necessarily retrieved them from the hypervisor layer yet. """ LOG.audit(_("Auditing locally available compute resources")) resources = self.driver.get_available_resource(self.nodename) if not resources: # The virt driver does not support this function LOG.audit(_("Virt driver does not support " "'get_available_resource' Compute tracking is disabled.")) self.compute_node = None return self._verify_resources(resources) self._report_hypervisor_resource_view(resources) # Grab all instances assigned to this node: instances = db.instance_get_all_by_host_and_node(context, self.host, self.nodename) # Now calculate usage based on instance utilization: self._update_usage_from_instances(resources, instances) # Grab all in-progress migrations: migrations = db.migration_get_in_progress_by_host(context, self.host) self._update_usage_from_migrations(resources, migrations) self._report_final_resource_view(resources) self._sync_compute_node(context, resources)
def test_in_progress_host2(self): migrations = db.migration_get_in_progress_by_host(self.ctxt, 'host2') # 2 as dest, 2 as source self.assertEqual(4, len(migrations)) self._assert_in_progress(migrations)
def test_instance_join(self): migrations = db.migration_get_in_progress_by_host(self.ctxt, 'host2') for migration in migrations: instance = migration['instance'] self.assertEqual(migration['instance_uuid'], instance['uuid'])
def test_in_progress_host1(self): migrations = db.migration_get_in_progress_by_host(self.ctxt, 'host1') # 2 as source + 1 as dest self.assertEqual(3, len(migrations)) self._assert_in_progress(migrations)