def test_device_not_assignable_regex(self): white_list = ('{"address":{"domain": ".*", "bus": ".*", ' '"slot": "0a", "function": "[2-3]"}, ' '"physical_network":"hr_net"}') parsed = whitelist.Whitelist( [white_list]) self.assertFalse(parsed.device_assignable(dev_dict))
def __init__(self, stats=None, dev_filter=None): super(PciDeviceStats, self).__init__() # NOTE(sbauza): Stats are a PCIDevicePoolList object self.pools = [pci_pool.to_dict() for pci_pool in stats] if stats else [] self.pools.sort(key=lambda item: len(item)) self.dev_filter = dev_filter or whitelist.Whitelist( CONF.pci.passthrough_whitelist)
def __init__(self, context): self.context = context self.client = clients.OpenStackClients(self.context).neutron() self.admin_client = None self.pci_whitelist = pci_whitelist.Whitelist( CONF.pci.passthrough_whitelist) self.last_neutron_extension_sync = None self.extensions = {}
def init(self, context, docker_api): self.docker = docker_api self.neutron_api = neutron.NeutronAPI(context) self.context = context self.pci_whitelist = pci_whitelist.Whitelist( CONF.pci.passthrough_whitelist) self.last_neutron_extension_sync = None self.extensions = {}
def setUp(self): super(PciDeviceStatsWithTagsTestCase, self).setUp() white_list = [ '{"vendor_id":"1137","product_id":"0071",' '"address":"*:0a:00.*","physical_network":"physnet1"}', '{"vendor_id":"1137","product_id":"0072"}' ] self.config(passthrough_whitelist=white_list, group='pci') dev_filter = whitelist.Whitelist(white_list) self.pci_stats = stats.PciDeviceStats(dev_filter=dev_filter)
def __init__(self, context, node_id=None): """Create a pci device tracker. If a node_id is passed in, it will fetch pci devices information from database, otherwise, it will create an empty devices list and the resource tracker will update the node_id information later. """ super(PciDevTracker, self).__init__() self.stale = {} self.node_id = node_id self.dev_filter = whitelist.Whitelist(CONF.pci.passthrough_whitelist) self.stats = stats.PciDeviceStats(dev_filter=self.dev_filter) self._context = context if node_id: self.pci_devs = objects.PciDevice.list_by_compute_node( context, node_id) else: self.pci_devs = [] self._build_device_tree(self.pci_devs) self._initial_instance_usage()
def test_device_assignable(self): white_list = '{"product_id":"0001", "vendor_id":"8086"}' parsed = whitelist.Whitelist([white_list]) self.assertTrue(parsed.device_assignable(dev_dict))
def test_device_not_assignable_glob(self): white_list = '{"address":"*:00:0b.*", "physical_network":"hr_net"}' parsed = whitelist.Whitelist( [white_list]) self.assertFalse(parsed.device_assignable(dev_dict))
def test_whitelist_multiple(self): wl1 = '{"product_id":"0001", "vendor_id":"8086"}' wl2 = '{"product_id":"0002", "vendor_id":"8087"}' parsed = whitelist.Whitelist([wl1, wl2]) self.assertEqual(2, len(parsed.specs))
def test_whitelist_empty(self): parsed = whitelist.Whitelist() self.assertFalse(parsed.device_assignable(dev_dict))
def test_whitelist_list_format(self): white_list = '[{"product_id":"0001", "vendor_id":"8086"},'\ '{"product_id":"0002", "vendor_id":"8086"}]' parsed = whitelist.Whitelist([white_list]) self.assertEqual(2, len(parsed.specs))
def test_whitelist(self): white_list = '{"product_id":"0001", "vendor_id":"8086"}' parsed = whitelist.Whitelist([white_list]) self.assertEqual(1, len(parsed.specs))