def test_spec_list(self): self.assertTrue(utils.pci_device_prop_match( self.fake_pci_1, [{'vendor_id': 'v1', 'device_id': 'd1', 'capabilities_network': ['cap1', 'cap2', 'cap3']}])) self.assertTrue(utils.pci_device_prop_match( self.fake_pci_1, [{'vendor_id': 'v1', 'device_id': 'd1', 'capabilities_network': ['cap3', 'cap1']}]))
def test_spec_list(self): self.assertTrue(utils.pci_device_prop_match( self.fake_pci_1, [{'vendor_id': 'v1', 'device_id': 'd1', 'capabilities_network': ['cap1', 'cap2', 'cap3']}])) self.assertTrue(utils.pci_device_prop_match( self.fake_pci_1, [{'vendor_id': 'v1', 'device_id': 'd1', 'capabilities_network': ['cap3', 'cap1']}]))
def test_spec_extra_key(self): self.assertFalse( utils.pci_device_prop_match(self.fake_pci_1, [{ 'vendor_id': 'v1', 'device_id': 'd1', 'wrong_key': 'k1' }]))
def test_spec_list_no_matching(self): self.assertFalse( utils.pci_device_prop_match( self.fake_pci_1, [{ 'vendor_id': 'v1', 'device_id': 'd1', 'capabilities_network': ['cap1', 'cap33'] }]))
def _filter_pools_for_numa_cells(pools, numa_cells): # Some systems don't report numa node info for pci devices, in # that case None is reported in pci_device.numa_node, by adding None # to numa_cells we allow assigning those devices to instances with # numa topology numa_cells = [None] + [cell.id for cell in numa_cells] # filter out pools which numa_node is not included in numa_cells return [pool for pool in pools if any(utils.pci_device_prop_match( pool, [{'numa_node': cell}]) for cell in numa_cells)]
def test_spec_dismatch(self): self.assertFalse( utils.pci_device_prop_match(self.fake_pci_1, [{ 'vendor_id': 'v4', 'device_id': 'd4' }, { 'vendor_id': 'v3', 'device_id': 'd3' }]))
def test_multiple_spec_match(self): self.assertTrue( utils.pci_device_prop_match(self.fake_pci_1, [{ 'vendor_id': 'v1', 'device_id': 'd1' }, { 'vendor_id': 'v3', 'device_id': 'd3' }]))
def test_spec_list_wrong_type(self): self.assertFalse(utils.pci_device_prop_match( self.fake_pci_1, [{'vendor_id': 'v1', 'device_id': ['d1']}]))
def _filter_pools_for_spec(pools, request_specs): return [pool for pool in pools if utils.pci_device_prop_match(pool, request_specs)]
def test_spec_list_wrong_type(self): self.assertFalse(utils.pci_device_prop_match( self.fake_pci_1, [{'vendor_id': 'v1', 'device_id': ['d1']}]))
def test_spec_list_no_matching(self): self.assertFalse(utils.pci_device_prop_match( self.fake_pci_1, [{'vendor_id': 'v1', 'device_id': 'd1', 'capabilities_network': ['cap1', 'cap33']}]))
def test_spec_extra_key(self): self.assertFalse(utils.pci_device_prop_match( self.fake_pci_1, [{'vendor_id': 'v1', 'device_id': 'd1', 'wrong_key': 'k1'}]))
def test_spec_dismatch(self): self.assertFalse(utils.pci_device_prop_match( self.fake_pci_1, [{'vendor_id': 'v4', 'device_id': 'd4'}, {'vendor_id': 'v3', 'device_id': 'd3'}]))
def test_multiple_spec_match(self): self.assertTrue(utils.pci_device_prop_match( self.fake_pci_1, [{'vendor_id': 'v1', 'device_id': 'd1'}, {'vendor_id': 'v3', 'device_id': 'd3'}]))