def test_actor_ethX_and_not_ethX(current_actor_context): pci1 = PCIAddress(domain="0000", bus="3e", function="00", device="PCI bridge") pci2 = PCIAddress(domain="0000", bus="3d", function="00", device="Serial controller") interface = [ Interface(name="virbr0", mac="52:54:00:0b:4a:6d", vendor="redhat", driver="pcieport", pci_info=pci1, devpath="/devices/platform/usb/cdc-wdm0"), Interface(name="eth0", mac="52:54:00:0b:4a:6a", vendor="redhat", driver="serial", pci_info=pci2, devpath="/devices/hidraw/hidraw0") ] current_actor_context.feed(PersistentNetNamesFacts(interfaces=interface)) current_actor_context.run() assert current_actor_context.consume(Report) assert 'inhibitor' in current_actor_context.consume( Report)[0].report['flags']
def interfaces(): """ Generator which produces an Interface objects containing assorted interface properties relevant for network naming """ for dev in physical_interfaces(): attrs = {} try: attrs['name'] = dev.sys_name attrs['devpath'] = dev.device_path attrs['driver'] = dev['ID_NET_DRIVER'] attrs['vendor'] = dev['ID_VENDOR_ID'] attrs['pci_info'] = PCIAddress(**pci_info(dev['ID_PATH'])) attrs['mac'] = dev.attributes.get('address') if isinstance(attrs['mac'], bytes): attrs['mac'] = attrs['mac'].decode() except Exception as e: # pylint: disable=broad-except # FIXME(msekleta): We should probably handle errors more granularly # Maybe we should inhibit upgrade process at this point api.current_logger().warning( 'Failed to gather information about network interface: ' + str(e)) continue yield Interface(**attrs)
def interface_mocked(i=0): return Interface(name='n{}'.format(i), devpath='dp{}'.format(i), driver='d{}'.format(i), vendor='v{}'.format(i), pci_info=PCIAddress(domain='pd{}'.format(i), bus='pb{}'.format(i), function='pf{}'.format(i), device='pd{}'.format(i)), mac='m{}'.format(i))
def test_actor_single_int_not_ethX(current_actor_context): pci = PCIAddress(domain="0000", bus="3e", function="00", device="PCI bridge") interface = [ Interface(name="tap0", mac="52:54:00:0b:4a:60", vendor="redhat", driver="pcieport", pci_info=pci, devpath="/devices/platform/usb/cdc-wdm0") ] current_actor_context.feed(PersistentNetNamesFacts(interfaces=interface)) current_actor_context.run() assert not current_actor_context.consume(Report)
def test_all_interfaces_biosdevname(monkeypatch): pci_info = PCIAddress(domain="domain", function="function", bus="bus", device="device") interfaces = [ Interface( name="eth0", mac="mac", vendor="dell", pci_info=pci_info, devpath="path", driver="drv" ) ] assert not library.all_interfaces_biosdevname(interfaces) interfaces = [ Interface( name="em0", mac="mac", vendor="dell", pci_info=pci_info, devpath="path", driver="drv" ) ] assert library.all_interfaces_biosdevname(interfaces) interfaces = [ Interface( name="p0p22", mac="mac", vendor="dell", pci_info=pci_info, devpath="path", driver="drv" ) ] assert library.all_interfaces_biosdevname(interfaces) interfaces = [ Interface( name="p1p2", mac="mac", vendor="dell", pci_info=pci_info, devpath="path", driver="drv" ), Interface( name="em2", mac="mac", vendor="dell", pci_info=pci_info, devpath="path", driver="drv" ), ] assert library.all_interfaces_biosdevname(interfaces) interfaces = [ Interface( name="p1p2", mac="mac", vendor="dell", pci_info=pci_info, devpath="path", driver="drv" ), Interface( name="em2", mac="mac", vendor="dell", pci_info=pci_info, devpath="path", driver="drv" ), Interface( name="eth0", mac="mac", vendor="dell", pci_info=pci_info, devpath="path", driver="drv" ), ] assert not library.all_interfaces_biosdevname(interfaces)