def setUp(self): super(PciDeviceStatsWithTagsTestCase, self).setUp() self.pci_stats = stats.PciDeviceStats() self._create_whitelist()
def _update_from_compute_node(self, compute): """Update information about a host from a ComputeNode object.""" # NOTE(jichenjc): if the compute record is just created but not updated # some field such as free_disk_gb can be None if 'free_disk_gb' not in compute or compute.free_disk_gb is None: LOG.debug( 'Ignoring compute node %s as its usage has not been ' 'updated yet.', compute.uuid) return if (self.updated and compute.updated_at and self.updated > compute.updated_at): return all_ram_mb = compute.memory_mb # Assume virtual size is all consumed by instances if use qcow2 disk. free_gb = compute.free_disk_gb least_gb = compute.disk_available_least if least_gb is not None: if least_gb > free_gb: # can occur when an instance in database is not on host LOG.warning( _LW("Host %(hostname)s has more disk space than " "database expected " "(%(physical)s GB > %(database)s GB)"), { 'physical': least_gb, 'database': free_gb, 'hostname': compute.hypervisor_hostname }) free_gb = min(least_gb, free_gb) free_disk_mb = free_gb * 1024 self.disk_mb_used = compute.local_gb_used * 1024 # NOTE(jogo) free_ram_mb can be negative self.free_ram_mb = compute.free_ram_mb self.total_usable_ram_mb = all_ram_mb self.total_usable_disk_gb = compute.local_gb self.free_disk_mb = free_disk_mb self.vcpus_total = compute.vcpus self.vcpus_used = compute.vcpus_used self.updated = compute.updated_at self.numa_topology = compute.numa_topology self.pci_stats = pci_stats.PciDeviceStats(compute.pci_device_pools) # All virt drivers report host_ip self.host_ip = compute.host_ip self.hypervisor_type = compute.hypervisor_type self.hypervisor_version = compute.hypervisor_version self.hypervisor_hostname = compute.hypervisor_hostname self.cpu_info = compute.cpu_info if compute.supported_hv_specs: self.supported_instances = [ spec.to_list() for spec in compute.supported_hv_specs ] else: self.supported_instances = [] # Don't store stats directly in host_state to make sure these don't # overwrite any values, or get overwritten themselves. Store in self so # filters can schedule with them. self.stats = compute.stats or {} # Track number of instances on host self.num_instances = int(self.stats.get('num_instances', 0)) self.num_io_ops = int(self.stats.get('io_workload', 0)) # update metrics self.metrics = objects.MonitorMetricList.from_json(compute.metrics) # update allocation ratios given by the ComputeNode object self.cpu_allocation_ratio = compute.cpu_allocation_ratio self.ram_allocation_ratio = compute.ram_allocation_ratio self.disk_allocation_ratio = compute.disk_allocation_ratio
def test_pci_stats_not_equivalent(self): pci_stats2 = stats.PciDeviceStats(objects.NUMATopology()) for dev in [self.fake_dev_1, self.fake_dev_2, self.fake_dev_3]: pci_stats2.add_device(dev) self.assertNotEqual(self.pci_stats, pci_stats2)
def test_pci_stats_not_equivalent(self): pci_stats2 = stats.PciDeviceStats() map(pci_stats2.add_device, [self.fake_dev_1, self.fake_dev_2, self.fake_dev_3]) self.assertNotEqual(self.pci_stats, pci_stats2)
def update_from_compute_node(self, compute): """Update information about a host from its compute_node info.""" if (self.updated and compute['updated_at'] and self.updated > compute['updated_at']): return all_ram_mb = compute['memory_mb'] # Assume virtual size is all consumed by instances if use qcow2 disk. free_gb = compute['free_disk_gb'] least_gb = compute.get('disk_available_least') if least_gb is not None: if least_gb > free_gb: # can occur when an instance in database is not on host LOG.warning(_LW("Host %(hostname)s has more disk space than " "database expected " "(%(physical)sgb > %(database)sgb)"), {'physical': least_gb, 'database': free_gb, 'hostname': compute['hypervisor_hostname']}) free_gb = min(least_gb, free_gb) free_disk_mb = free_gb * 1024 self.disk_mb_used = compute['local_gb_used'] * 1024 # NOTE(jogo) free_ram_mb can be negative self.all_freq = compute.get('all_freq') self.curr_freq = compute['curr_freq'] self.max_freq = compute['max_freq'] self.free_ram_mb = compute['free_ram_mb'] self.total_usable_ram_mb = all_ram_mb self.total_usable_disk_gb = compute['local_gb'] self.free_disk_mb = free_disk_mb self.vcpus_total = compute['vcpus'] self.vcpus_used = compute['vcpus_used'] self.updated = compute['updated_at'] self.numa_topology = compute['numa_topology'] if 'pci_stats' in compute: self.pci_stats = pci_stats.PciDeviceStats(compute['pci_stats']) else: self.pci_stats = None # All virt drivers report host_ip self.host_ip = compute['host_ip'] self.hypervisor_type = compute.get('hypervisor_type') self.hypervisor_version = compute.get('hypervisor_version') self.hypervisor_hostname = compute.get('hypervisor_hostname') self.cpu_info = compute.get('cpu_info') if compute.get('supported_instances'): self.supported_instances = jsonutils.loads( compute.get('supported_instances')) # Don't store stats directly in host_state to make sure these don't # overwrite any values, or get overwritten themselves. Store in self so # filters can schedule with them. stats = compute.get('stats', None) or '{}' self.stats = jsonutils.loads(stats) # Track number of instances on host self.num_instances = int(self.stats.get('num_instances', 0)) self.num_io_ops = int(self.stats.get('io_workload', 0)) # update metrics self._update_metrics_from_compute_node(compute)
def update_from_compute_node(self, compute): """Update information about a host from a ComputeNode object.""" if (self.updated and compute.updated_at and self.updated > compute.updated_at): return all_ram_mb = compute.memory_mb # Assume virtual size is all consumed by instances if use qcow2 disk. free_gb = compute.free_disk_gb least_gb = compute.disk_available_least if least_gb is not None: if least_gb > free_gb: # can occur when an instance in database is not on host LOG.warning( _LW("Host %(hostname)s has more disk space than " "database expected " "(%(physical)sgb > %(database)sgb)"), { 'physical': least_gb, 'database': free_gb, 'hostname': compute.hypervisor_hostname }) free_gb = min(least_gb, free_gb) free_disk_mb = free_gb * 1024 self.disk_mb_used = compute.local_gb_used * 1024 # NOTE(jogo) free_ram_mb can be negative self.free_ram_mb = compute.free_ram_mb self.total_usable_ram_mb = all_ram_mb self.total_usable_disk_gb = compute.local_gb self.free_disk_mb = free_disk_mb self.vcpus_total = compute.vcpus self.vcpus_used = compute.vcpus_used self.updated = compute.updated_at self.numa_topology = compute.numa_topology self.instance_numa_topology = None self.pci_stats = pci_stats.PciDeviceStats(compute.pci_device_pools) # All virt drivers report host_ip self.host_ip = compute.host_ip self.hypervisor_type = compute.hypervisor_type self.hypervisor_version = compute.hypervisor_version self.hypervisor_hostname = compute.hypervisor_hostname self.cpu_info = compute.cpu_info if compute.supported_hv_specs: self.supported_instances = [ spec.to_list() for spec in compute.supported_hv_specs ] else: self.supported_instances = [] # Don't store stats directly in host_state to make sure these don't # overwrite any values, or get overwritten themselves. Store in self so # filters can schedule with them. self.stats = compute.stats or {} # Track number of instances on host self.num_instances = int(self.stats.get('num_instances', 0)) self.num_io_ops = int(self.stats.get('io_workload', 0)) # update metrics self._update_metrics_from_compute_node(compute)
def setUp(self): super(PciDeviceVFPFStatsTestCase, self).setUp() white_list = ['{"vendor_id":"8086","product_id":"1528"}', '{"vendor_id":"8086","product_id":"1515"}'] self.flags(passthrough_whitelist=white_list, group='pci') self.pci_stats = stats.PciDeviceStats(objects.NUMATopology())
def setUp(self): super(PciDeviceVFPFStatsTestCase, self).setUp() white_list = ['{"vendor_id":"8086","product_id":"1528"}', '{"vendor_id":"8086","product_id":"1515"}'] self.flags(pci_passthrough_whitelist=white_list) self.pci_stats = stats.PciDeviceStats()
def _create_pci_stats(counts): if counts is None: # the pci_stats column is nullable return None pools = [_create_pci_pool(count) for count in counts] return stats.PciDeviceStats(pools)