def linux(self): nic_dict = {} i = 1 # Get info about all devices devices = ethtool.get_interfaces_info(ethtool.get_devices()) # Retrieve and print info for dev in devices: name = dev.device mac = dev.mac_address ip = dev.ipv4_address netmask = dev.ipv4_netmask num = str(i) if name != 'lo' and ip is not None: temp = { num: { 'name': name, 'mac': mac, 'ip': ip, 'netmask': netmask } } nic_dict = dict(nic_dict, **temp) i += 1 nic_dict = dict(nic=nic_dict) return nic_dict
def testGetIfaceByIP(self): for dev in ethtool.get_interfaces_info(ethtool.get_active_devices()): ipaddrs = map( lambda etherinfo_ipv6addr: etherinfo_ipv6addr.address, dev.get_ipv6_addresses()) ipaddrs.append(dev.ipv4_address) for ip in ipaddrs: self.assertEqual(dev.device, netinfo.getIfaceByIP(ip))
def refresh(self): import ethtool self._info = ethtool.get_interfaces_info(self.name)[0] try: self._network = IPNetwork( "%s/%s" % (self._info.ipv4_address, self._info.ipv4_netmask)) except (UnboundLocalError, AddrFormatError): pass
def test_get_interface_info_invalid(self): eis = ethtool.get_interfaces_info(INVALID_DEVICE_NAME) self.assertEquals(len(eis), 1) ei = eis[0] self.assertEquals(ei.device, INVALID_DEVICE_NAME) self.assertEquals(ei.ipv4_address, None) self.assertEquals(ei.ipv4_broadcast, None) self.assertEquals(ei.ipv4_netmask, 0) self.assertEquals(ei.mac_address, None)
def getIpInfo(dev): devInfo = ethtool.get_interfaces_info(dev.encode('utf8'))[0] addr = devInfo.ipv4_address netmask = devInfo.ipv4_netmask ipv6addrs = devInfo.get_ipv6_addresses() return (addr if addr else '', prefix2netmask(netmask) if netmask else '', [addr6.address + '/' + str(addr6.netmask) for addr6 in ipv6addrs])
def save_config(conn, iface, gateway=None): nic_info = ethtool.get_interfaces_info(iface)[0] ipv4 = '' if nic_info.ipv4_address: ipv4 = "%s/%s" % (nic_info.ipv4_address, nic_info.ipv4_netmask) n = IPv4Network(ipv4) net_params = {'ipaddr': str(n.ip), 'netmask': str(n.netmask)} if gateway: net_params['gateway'] = gateway iface_xml = InterfaceModel()._create_iface_xml(iface, net_params) iface = conn.interfaceDefineXML(iface_xml)
def getIfaceByIP(ip): for info in ethtool.get_interfaces_info(ethtool.get_active_devices()): for ipv4addr in info.get_ipv4_addresses(): if ip == ipv4addr.address or ip == IPv4toMapped(ipv4addr.address): return info.device for ipv6addr in info.get_ipv6_addresses(): if ip == ipv6addr.address: return info.device return ''
def list_eth_ips(): devcfgs = ethtool.get_interfaces_info(ethtool.get_devices()) addrs = set() for d in devcfgs: if d.ipv4_address: addrs.add(d.ipv4_address) addrs.add("0.0.0.0") for ip6 in d.get_ipv6_addresses(): addrs.add(ip6.address) addrs.add("::0") # only list ::0 if ipv6 present return sorted(addrs)
def test_get_interface_info_invalid(self): eis = ethtool.get_interfaces_info(INVALID_DEVICE_NAME) self.assertEqual(len(eis), 1) ei = eis[0] self.assertEqual(ei.device, INVALID_DEVICE_NAME) self.assertRaisesIOError(getattr, (ei, 'ipv4_address'), '[Errno 19] No such device') self.assertRaisesIOError(getattr, (ei, 'ipv4_netmask'), '[Errno 19] No such device') self.assertRaisesIOError(getattr, (ei, 'ipv4_broadcast'), '[Errno 19] No such device') self.assertRaisesIOError(getattr, (ei, 'mac_address'), '[Errno 19] No such device')
def testGetDeviceByIP(self): for dev in ethtool.get_interfaces_info(ethtool.get_active_devices()): # Link-local IPv6 addresses are generated from the MAC address, # which is shared between a nic and its bridge. Since We don't # support having the same IP address on two different NICs, and # link-local IPv6 addresses aren't interesting for 'getDeviceByIP' # then ignore them in the test ipaddrs = [ipv6.address for ipv6 in dev.get_ipv6_addresses() if ipv6.scope != 'link'] if dev.ipv4_address is not None: ipaddrs.append(dev.ipv4_address) for ip in ipaddrs: self.assertEqual(dev.device, netinfo.getDeviceByIP(ip))
def MakeReport(self): ncfg_n = libxml2.newNode("NetworkConfig") (defgw4, defgw6) = self.net_GetDefaultGW() # Make an interface tag for each device found if hasattr(ethtool, 'get_interfaces_info'): # Using the newer python-ethtool API (version >= 0.4) for dev in ethtool.get_interfaces_info(ethtool.get_devices()): if cmp(dev.device, 'lo') == 0: continue intf_n = libxml2.newNode('interface') intf_n.newProp('device', dev.device) intf_n.newProp('hwaddr', dev.mac_address) ncfg_n.addChild(intf_n) # Protcol configurations if dev.ipv4_address: ipv4_n = libxml2.newNode('IPv4') ipv4_n.newProp('ipaddr', dev.ipv4_address) ipv4_n.newProp('netmask', str(dev.ipv4_netmask)) ipv4_n.newProp('broadcast', dev.ipv4_broadcast) ipv4_n.newProp('defaultgw', (defgw4 == dev.device) and '1' or '0') intf_n.addChild(ipv4_n) for ip6 in dev.get_ipv6_addresses(): ipv6_n = libxml2.newNode('IPv6') ipv6_n.newProp('ipaddr', ip6.address) ipv6_n.newProp('netmask', str(ip6.netmask)) ipv6_n.newProp('scope', ip6.scope) intf_n.addChild(ipv6_n) else: # Fall back to older python-ethtool API (version < 0.4) ifdevs = ethtool.get_active_devices() ifdevs.remove('lo') ifdevs.sort() for dev in ifdevs: intf_n = libxml2.newNode('interface') intf_n.newProp('device', dev.device) intf_n.newProp('hwaddr', dev.mac_address) ncfg_n.addChild(intf_n) ipv4_n = libxml2.newNode('IPv4') ipv4_n.newProp('ipaddr', ethtool.get_ipaddr(dev)) ipv4_n.newProp('netmask', str(ethtool.get_netmask(dev))) ipv4_n.newProp('defaultgw', (defgw4 == dev) and '1' or '0') intf_n.addChild(ipv4_n) return ncfg_n
def MakeReport(self): ncfg_n = libxml2.newNode("NetworkConfig") (defgw4, defgw6) = self.net_GetDefaultGW() # Make an interface tag for each device found if hasattr(ethtool, 'get_interfaces_info'): # Using the newer python-ethtool API (version >= 0.4) for dev in ethtool.get_interfaces_info(ethtool.get_devices()): if cmp(dev.device,'lo') == 0: continue intf_n = libxml2.newNode('interface') intf_n.newProp('device', dev.device) intf_n.newProp('hwaddr', dev.mac_address) ncfg_n.addChild(intf_n) # Protcol configurations if dev.ipv4_address: ipv4_n = libxml2.newNode('IPv4') ipv4_n.newProp('ipaddr', dev.ipv4_address) ipv4_n.newProp('netmask', str(dev.ipv4_netmask)) ipv4_n.newProp('broadcast', dev.ipv4_broadcast) ipv4_n.newProp('defaultgw', (defgw4 == dev.device) and '1' or '0') intf_n.addChild(ipv4_n) for ip6 in dev.get_ipv6_addresses(): ipv6_n = libxml2.newNode('IPv6') ipv6_n.newProp('ipaddr', ip6.address) ipv6_n.newProp('netmask', str(ip6.netmask)) ipv6_n.newProp('scope', ip6.scope) intf_n.addChild(ipv6_n) else: # Fall back to older python-ethtool API (version < 0.4) ifdevs = ethtool.get_active_devices() ifdevs.remove('lo') ifdevs.sort() for dev in ifdevs: intf_n = libxml2.newNode('interface') intf_n.newProp('device', dev.device) intf_n.newProp('hwaddr', dev.mac_address) ncfg_n.addChild(intf_n) ipv4_n = libxml2.newNode('IPv4') ipv4_n.newProp('ipaddr', ethtool.get_ipaddr(dev)) ipv4_n.newProp('netmask', str(ethtool.get_netmask(dev))) ipv4_n.newProp('defaultgw', (defgw4 == dev) and '1' or '0') intf_n.addChild(ipv4_n) return ncfg_n
def getAllNetworkInterfaces(self): interfaces = list() try: for dev in ethtool.get_active_devices(): flags = ethtool.get_flags(dev) if not(flags & ethtool.IFF_LOOPBACK): devinfo = ethtool.get_interfaces_info(dev)[0] interfaces.append({ 'name' : dev, 'inet' : [ ethtool.get_ipaddr(dev) ], 'inet6' : map(lambda ip: ip.address, devinfo.get_ipv6_addresses()), 'hw' : ethtool.get_hwaddr(dev) }) except: logging.exception("Error retrieving network interfaces.") return interfaces
def list_eth_ips(): if not ethtool: return [] devcfgs = ethtool.get_interfaces_info(ethtool.get_devices()) addrs = set() for d in devcfgs: if d.ipv4_address: addrs.add(d.ipv4_address) addrs.add("0.0.0.0") for ip6 in d.get_ipv6_addresses(): addrs.add(ip6.address) addrs.add("::0") # only list ::0 if ipv6 present return sorted(addrs)
def getDeviceByIP(ip): """ Get network device by IP address :param ip: String representing IPv4 or IPv6, but not link-local IPv6 """ for info in ethtool.get_interfaces_info(ethtool.get_active_devices()): for ipv4addr in info.get_ipv4_addresses(): if ip in (ipv4addr.address, IPv4toMapped(ipv4addr.address)): return info.device for ipv6addr in info.get_ipv6_addresses(): if ip == ipv6addr.address: return info.device return ''
def testGetDeviceByIP(self): for dev in ethtool.get_interfaces_info(ethtool.get_active_devices()): # Link-local IPv6 addresses are generated from the MAC address, # which is shared between a nic and its bridge. Since We don't # support having the same IP address on two different NICs, and # link-local IPv6 addresses aren't interesting for 'getDeviceByIP' # then ignore them in the test ipaddrs = [ ipv6.address for ipv6 in dev.get_ipv6_addresses() if ipv6.scope != 'link' ] if dev.ipv4_address is not None: ipaddrs.append(dev.ipv4_address) for ip in ipaddrs: self.assertEqual(dev.device, netinfo.getDeviceByIP(ip))
def _get_ipv6_addr_list(self): """ When DNS record is not configured properly for the system, then try to get list of all IPv6 addresses from all devices. Return ::1 only in situation when there no device with valid global IPv6 address. :return: list of IPv6 addresses """ addr_list = [] interface_info = ethtool.get_interfaces_info(ethtool.get_devices()) for info in interface_info: for addr in info.get_ipv6_addresses(): if addr.scope == 'universe': addr_list.append(addr.address) if len(addr_list) == 0: addr_list = ['::1'] return addr_list
def _get_ipv4_addr_list(self): """ When DNS record is not configured properly for the system, then try to get list of all IPv4 addresses from all devices. Return 127.0.0.1 only in situation when there is only loopback device. :return: list of IPv4 addresses """ addr_list = [] interface_info = ethtool.get_interfaces_info(ethtool.get_devices()) for info in interface_info: for addr in info.get_ipv4_addresses(): if addr.address != '127.0.0.1': addr_list.append(addr.address) if len(addr_list) == 0: addr_list = ['127.0.0.1'] return addr_list
def getIfaceByIP(ip): for info in ethtool.get_interfaces_info(ethtool.get_active_devices()): if hasattr(info, 'get_ipv4_addresses'): for ipv4addr in info.get_ipv4_addresses(): if ip == ipv4addr.address or \ ip == IPv4toMapped(ipv4addr.address): return info.device else: if ip == info.ipv4_address or \ ip == IPv4toMapped(info.ipv4_address): return info.device for ipv6addr in info.get_ipv6_addresses(): if ip == ipv6addr.address: return info.device return ''
def getNetworkInterfaces(self): netinfdict = {} metakeys = [ 'mac_address', 'ipv4_address', 'ipv4_netmask', 'ipv4_broadcast' ] ipv6_metakeys = ['address', 'netmask'] try: for info in ethtool.get_interfaces_info(ethtool.get_devices()): for addr in info.get_ipv6_addresses(): for mkey in ipv6_metakeys: # ethtool returns a different scope for "public" IPv6 addresses # on different versions of RHEL. EL5 is "global", while EL6 is # "universe". Make them consistent. scope = addr.scope if scope == 'universe': scope = 'global' key = '.'.join([ 'net.interface', info.device, 'ipv6_%s' % (mkey), scope ]) attr = getattr(addr, mkey) if attr: netinfdict[key] = attr else: netinfdict[key] = "Unknown" # XXX: The kernel supports multiple IPv4 addresses on a single # interface when using iproute2. However, the ethtool.etherinfo.ipv4_* # members will only return the last retrieved IPv4 configuration. As # of 25 Jan 2012 work on a patch was in progress. See BZ 759150. for mkey in metakeys: key = '.'.join(['net.interface', info.device, mkey]) attr = getattr(info, mkey) if attr: netinfdict[key] = attr else: netinfdict[key] = "Unknown" except: print _( "Error reading network interface information:"), sys.exc_type self.allhw.update(netinfdict) return netinfdict
def show_config(device): ipaddr = ethtool.get_ipaddr(device) netmask = ethtool.get_netmask(device) flags = ethtool.get_flags(device) print '%-9.9s' % device, if not (flags & ethtool.IFF_LOOPBACK): print "HWaddr %s" % ethtool.get_hwaddr(device), print ''' inet addr:%s''' % ipaddr, if not (flags & (ethtool.IFF_LOOPBACK | ethtool.IFF_POINTOPOINT)): print "Bcast:%s" % ethtool.get_broadcast(device), print ' Mask:%s' % netmask for info in ethtool.get_interfaces_info(device): for addr in info.get_ipv6_addresses(): print (" inet6 addr: %s/%s Scope: %s" % (addr.address, addr.netmask, addr.scope)) print ' %s' % flags2str(flags) print
def list_eth_ips(ifnames=None): ''' List the IPv4 and IPv6 non-loopback, non link-local addresses (in the RFC3330 sense, not addresses attached to lo) of a list of ethernet interfaces from the SIOCGIFADDR struct. If ifname is omitted, list all IPs of all ifaces excepted for lo. ''' if ifnames is None: ifnames = [name for name in ethtool.get_devices() if name != 'lo'] devcfgs = ethtool.get_interfaces_info(ifnames) addrs = [] for d in devcfgs: if d.ipv4_address: addrs.append(d.ipv4_address) # For IPv6 addresses, we might have more of them on the same device, # and only grab global (universe) addresses. for ip6 in [a for a in d.get_ipv6_addresses() if a.scope == 'universe']: addrs.append(ip6.address) return sorted(set(addrs))
def getNetworkInterfaces(self): netinfdict = {} metakeys = ['mac_address', 'ipv4_address', 'ipv4_netmask', 'ipv4_broadcast'] ipv6_metakeys = ['address', 'netmask'] try: for info in ethtool.get_interfaces_info(ethtool.get_devices()): for addr in info.get_ipv6_addresses(): for mkey in ipv6_metakeys: # ethtool returns a different scope for "public" IPv6 addresses # on different versions of RHEL. EL5 is "global", while EL6 is # "universe". Make them consistent. scope = addr.scope if scope == 'universe': scope = 'global' key = '.'.join(['net.interface', info.device, 'ipv6_%s' % (mkey), scope]) attr = getattr(addr, mkey) if attr: netinfdict[key] = attr else: netinfdict[key] = "Unknown" # XXX: The kernel supports multiple IPv4 addresses on a single # interface when using iproute2. However, the ethtool.etherinfo.ipv4_* # members will only return the last retrieved IPv4 configuration. As # of 25 Jan 2012 work on a patch was in progress. See BZ 759150. for mkey in metakeys: key = '.'.join(['net.interface', info.device, mkey]) attr = getattr(info, mkey) if attr: netinfdict[key] = attr else: netinfdict[key] = "Unknown" except: print _("Error reading network interface information:"), sys.exc_type self.allhw.update(netinfdict) return netinfdict
__author__ = 'yippee' import ethtool interfaces = [] for dev in ethtool.get_devices(): flags = ethtool.get_flags(dev) if flags & ethtool.IFF_UP and \ not (flags & ethtool.IFF_LOOPBACK): # print dev, flags dev_info = ethtool.get_interfaces_info(dev)[0] # print dev_info.get_ipv4_addresses() interfaces.append( {'name': dev, 'inet': ethtool.get_ipv4_addresses(dev_info), 'inet6': ethtool.get_ipv6_addresses(dev_info), 'hw': ethtool.get_hwaddr(dev)}) import pprint pprint(interfaces)
def get_network_interfaces(self): netinfdict = {} old_ipv4_metakeys = ['ipv4_address', 'ipv4_netmask', 'ipv4_broadcast'] ipv4_metakeys = ['address', 'netmask', 'broadcast'] ipv6_metakeys = ['address', 'netmask'] try: interfaces_info = ethtool.get_interfaces_info(ethtool.get_devices()) for info in interfaces_info: master = None mac_address = info.mac_address device = info.device # Omit mac addresses for sit and lo device types. See BZ838123 # mac address are per interface, not per address if self._should_get_mac_address(device): key = '.'.join(['net.interface', device, 'mac_address']) netinfdict[key] = mac_address # all of our supported versions of python-ethtool support # get_ipv6_addresses for addr in info.get_ipv6_addresses(): # ethtool returns a different scope for "public" IPv6 addresses # on different versions of RHEL. EL5 is "global", while EL6 is # "universe". Make them consistent. scope = addr.scope if scope == 'universe': scope = 'global' # FIXME: this doesn't support multiple addresses per interface # (it finds them, but collides on the key name and loses all # but the last write). See bz #874735 for mkey in ipv6_metakeys: key = '.'.join(['net.interface', info.device, 'ipv6_%s' % (mkey), scope]) # we could specify a default here... that could hide # api breakage though and unit testing hw detect is... meh attr = getattr(addr, mkey) or 'Unknown' netinfdict[key] = attr # However, old version of python-ethtool do not support # get_ipv4_address # # python-ethtool's api changed between rhel6.3 and rhel6.4 # (0.6-1.el6 to 0.6-2.el6) # (without revving the upstream version... bad python-ethtool!) # note that 0.6-5.el5 (from rhel5.9) has the old api # # previously, we got the 'ipv4_address' from the etherinfo object # directly. In the new api, that isn't exposed, so we get the list # of addresses on the interface, and populate the info from there. # # That api change as to address bz #759150. The bug there was that # python-ethtool only showed one ip address per interface. To # accomdate the finer grained info, the api changed... # # FIXME: see FIXME for get_ipv6_address, we don't record multiple # addresses per interface if hasattr(info, 'get_ipv4_addresses'): for addr in info.get_ipv4_addresses(): for mkey in ipv4_metakeys: # append 'ipv4_' to match the older interface and keeps facts # consistent key = '.'.join(['net.interface', info.device, 'ipv4_%s' % (mkey)]) attr = getattr(addr, mkey) or 'Unknown' netinfdict[key] = attr # check to see if we are actually an ipv4 interface elif hasattr(info, 'ipv4_address'): for mkey in old_ipv4_metakeys: key = '.'.join(['net.interface', device, mkey]) attr = getattr(info, mkey) or 'Unknown' netinfdict[key] = attr # otherwise we are ipv6 and we handled that already # bonded slave devices can have their hwaddr changed # # "master" here refers to the slave's master device. # If we find a master link, we are a slave, and we need # to check the /proc/net/bonding info to see what the # "permanent" hw address are for this slave try: master = os.readlink('/sys/class/net/%s/master' % info.device) #FIXME except Exception: master = None if master: master_interface = os.path.basename(master) permanent_mac_addr = self._get_slave_hwaddr(master_interface, info.device) key = '.'.join(['net.interface', info.device, "permanent_mac_address"]) netinfdict[key] = permanent_mac_addr except Exception: print _("Error reading network interface information:"), sys.exc_type self.allhw.update(netinfdict) return netinfdict
def read_network_interfaces(): intDict = {} intDict['class'] = "NETINTERFACES" if not ethtool_present and not netifaces_present: # ethtool is not available on non-linux platforms (as kfreebsd), skip it sys.stderr.write( "Warning: information about network interfaces could not be retrieved on this platform.\n" ) return intDict if ethtool_present: interfaces = list( set(ethtool.get_devices() + ethtool.get_active_devices())) else: interfaces = netifaces.interfaces() for interface in interfaces: try: if ethtool_present: hwaddr = ethtool.get_hwaddr(interface) else: hwaddr = netifaces.ifaddresses(interface)[ netifaces.AF_LINK][0]['addr'] except: hwaddr = "" # slave devices can have their hwaddr changed try: master = os.readlink('/sys/class/net/%s/master' % interface) except: master = None if master: master_interface = os.path.basename(master) hwaddr = get_slave_hwaddr(master_interface, interface) try: if ethtool_present: module = ethtool.get_module(interface) else: driver_file = open( '/sys/class/net/%s/device/uevent' % interface, 'r') module = driver_file.readline().split('=')[1].strip() driver_file.close() except: if interface == 'lo': module = "loopback" else: module = "Unknown" try: if ethtool_present: ipaddr = ethtool.get_ipaddr(interface) else: ipaddr = netifaces.ifaddresses(interface)[ netifaces.AF_INET][0]['addr'] except: ipaddr = "" try: if ethtool_present: netmask = ethtool.get_netmask(interface) else: netmask = netifaces.ifaddresses(interface)[ netifaces.AF_INET][0]['netmask'] except: netmask = "" try: if ethtool_present: broadcast = ethtool.get_broadcast(interface) else: broadcast = netifaces.ifaddresses(interface)[ netifaces.AF_INET][0]['broadcast'] except: broadcast = "" ip6_list = [] if ethtool_present: dev_info = ethtool.get_interfaces_info(interface) for info in dev_info: # one interface may have more IPv6 addresses for ip6 in info.get_ipv6_addresses(): scope = ip6.scope if scope == 'global': scope = 'universe' ip6_list.append({ 'scope': scope, 'addr': ip6.address, 'netmask': ip6.netmask }) else: try: for dev_info in netifaces.ifaddresses(interface)[ netifaces.AF_INET6]: ip6_addr = dev_info['addr'].split('%')[0] scope_info = ipaddress.IPv6Address(ip6_addr) if scope_info.is_global: scope = 'universe' elif scope_info.is_link_local: scope = 'link' elif scope_info.is_loopback: scope = 'host' elif scope_info.is_site_local: scope = 'site' # count number of '1' bits in netmask returned by netifaces ip6_netmask = dev_info['netmask'] netmask_bits = 0 for two_octets in ip6_netmask.split(':'): if not two_octets: break elif two_octets.lower() == 'ffff': netmask_bits += 16 else: # remove '0b' from begin and find last '1' in the string netmask_bits += 1 + bin( int(two_octets.split('/')[0], 16))[2:].rindex('1') ip6_list.append({ 'scope': scope, 'addr': ip6_addr, 'netmask': netmask_bits }) except KeyError: pass # no ipv6 for this interface intDict[interface] = { 'hwaddr': hwaddr, 'ipaddr': ipaddr, 'netmask': netmask, 'broadcast': broadcast, 'module': module, 'ipv6': ip6_list } return intDict
def get_network_interfaces(self): netinfdict = {} old_ipv4_metakeys = ['ipv4_address', 'ipv4_netmask', 'ipv4_broadcast'] ipv4_metakeys = ['address', 'netmask', 'broadcast'] ipv6_metakeys = ['address', 'netmask'] try: interfaces_info = ethtool.get_interfaces_info( ethtool.get_devices()) for info in interfaces_info: mac_address = info.mac_address device = info.device # Omit mac addresses for sit and lo device types. See BZ838123 # mac address are per interface, not per address if self._should_get_mac_address(device): key = '.'.join(['net.interface', device, 'mac_address']) netinfdict[key] = mac_address # all of our supported versions of python-ethtool support # get_ipv6_addresses for addr in info.get_ipv6_addresses(): # ethtool returns a different scope for "public" IPv6 addresses # on different versions of RHEL. EL5 is "global", while EL6 is # "universe". Make them consistent. scope = addr.scope if scope == 'universe': scope = 'global' for mkey in ipv6_metakeys: key = '.'.join([ 'net.interface', info.device, 'ipv6_%s' % (mkey), scope ]) list_key = "%s_list" % key # we could specify a default here... that could hide # api breakage though and unit testing hw detect is... meh attr = getattr(addr, mkey) or 'Unknown' netinfdict[key] = attr if not netinfdict.get(list_key, None): netinfdict[list_key] = str(attr) else: netinfdict[list_key] += ', %s' % str(attr) # However, old version of python-ethtool do not support # get_ipv4_address # # python-ethtool's api changed between rhel6.3 and rhel6.4 # (0.6-1.el6 to 0.6-2.el6) # (without revving the upstream version... bad python-ethtool!) # note that 0.6-5.el5 (from rhel5.9) has the old api # # previously, we got the 'ipv4_address' from the etherinfo object # directly. In the new api, that isn't exposed, so we get the list # of addresses on the interface, and populate the info from there. # # That api change as to address bz #759150. The bug there was that # python-ethtool only showed one ip address per interface. To # accomdate the finer grained info, the api changed... if hasattr(info, 'get_ipv4_addresses'): for addr in info.get_ipv4_addresses(): for mkey in ipv4_metakeys: # append 'ipv4_' to match the older interface and keeps facts # consistent key = '.'.join([ 'net.interface', info.device, 'ipv4_%s' % (mkey) ]) list_key = "%s_list" % key attr = getattr(addr, mkey) or 'Unknown' netinfdict[key] = attr if not netinfdict.get(list_key, None): netinfdict[list_key] = str(attr) else: netinfdict[list_key] += ', %s' % str(attr) # check to see if we are actually an ipv4 interface elif hasattr(info, 'ipv4_address'): for mkey in old_ipv4_metakeys: key = '.'.join(['net.interface', device, mkey]) attr = getattr(info, mkey) or 'Unknown' netinfdict[key] = attr # otherwise we are ipv6 and we handled that already # bonded slave devices can have their hwaddr changed # # "master" here refers to the slave's master device. # If we find a master link, we are a slave, and we need # to check the /proc/net/bonding info to see what the # "permanent" hw address are for this slave try: master = os.readlink('/sys/class/net/%s/master' % info.device) # FIXME except Exception: master = None if master: master_interface = os.path.basename(master) permanent_mac_addr = self._get_slave_hwaddr( master_interface, info.device) key = '.'.join([ 'net.interface', info.device, "permanent_mac_address" ]) netinfdict[key] = permanent_mac_addr except Exception as e: log.exception(e) log.warning("Error reading network interface information: %s", e) return netinfdict
def get_network_interfaces(self): netinfdict = {} old_ipv4_metakeys = ["ipv4_address", "ipv4_netmask", "ipv4_broadcast"] ipv4_metakeys = ["address", "netmask", "broadcast"] ipv6_metakeys = ["address", "netmask"] try: interfaces_info = ethtool.get_interfaces_info( ethtool.get_devices()) for info in interfaces_info: mac_address = info.mac_address device = info.device # Omit mac addresses for sit and lo device types. See BZ838123 # mac address are per interface, not per address if self._should_get_mac_address(device): key = ".".join(["net.interface", device, "mac_address"]) netinfdict[key] = mac_address # collect the IPv6 information by device, and by scope ipv6_values = defaultdict(lambda: defaultdict(list)) # all of our supported versions of python-ethtool support # get_ipv6_addresses for addr in info.get_ipv6_addresses(): # ethtool returns a different scope for "public" IPv6 addresses # on different versions of RHEL. EL5 is "global", while EL6 is # "universe". Make them consistent. scope = addr.scope if scope == "universe": scope = "global" for mkey in ipv6_metakeys: # we could specify a default here... that could hide # api breakage though and unit testing hw detect is... meh attr = getattr(addr, mkey) or "Unknown" ipv6_values[mkey][scope].append(str(attr)) for meta_key, mapping_values in ipv6_values.items(): for scope, values in mapping_values.items(): key = "net.interface.{device}.ipv6_{key}.{scope}".format( device=info.device, key=meta_key, scope=scope) list_key = key + "_list" netinfdict[key] = values[0] netinfdict[list_key] = ", ".join(values) # However, old version of python-ethtool do not support # get_ipv4_address # # python-ethtool's api changed between rhel6.3 and rhel6.4 # (0.6-1.el6 to 0.6-2.el6) # (without revving the upstream version... bad python-ethtool!) # note that 0.6-5.el5 (from rhel5.9) has the old api # # previously, we got the 'ipv4_address' from the etherinfo object # directly. In the new api, that isn't exposed, so we get the list # of addresses on the interface, and populate the info from there. # # That api change as to address bz #759150. The bug there was that # python-ethtool only showed one ip address per interface. To # accomdate the finer grained info, the api changed... if hasattr(info, "get_ipv4_addresses"): # collect the IPv4 information by device ipv4_values = defaultdict(list) for addr in info.get_ipv4_addresses(): for mkey in ipv4_metakeys: attr = getattr(addr, mkey) or "Unknown" ipv4_values[mkey].append(str(attr)) for meta_key, values in ipv4_values.items(): # append 'ipv4_' to match the older interface and keeps facts # consistent key = "net.interface.{device}.ipv4_{key}".format( device=info.device, key=meta_key) list_key = key + "_list" netinfdict[key] = values[0] netinfdict[list_key] = ", ".join(values) # check to see if we are actually an ipv4 interface elif hasattr(info, "ipv4_address"): for mkey in old_ipv4_metakeys: key = ".".join(["net.interface", device, mkey]) attr = getattr(info, mkey) or "Unknown" netinfdict[key] = attr # otherwise we are ipv6 and we handled that already # Bonded devices can have their hardware address changed. # # Here the 'bond_interface' refers to the name of device bonding other # network interfaces under single virtual one. # # If we find the bond link (if the file exists), we are a bonded device # and we need to check the /proc/net/bonding information to see what the # 'permanent' hardware address for this bonded device is. bond_interface: Optional[str] try: bond_link: str = os.readlink("/sys/class/net/%s/master" % info.device) bond_interface = os.path.basename(bond_link) # FIXME except Exception: bond_interface = None if bond_interface: address: str = self._get_permanent_hardware_address( bond_interface, info.device) key: str = ".".join([ "net.interface", info.device, "permanent_mac_address" ]) netinfdict[key] = address except Exception as e: log.exception(e) log.warning("Error reading network interface information: %s", e) return netinfdict
def getipv6addrs(dev): """Return a list of IPv6 addresses in the format of 'address/prefixlen'.""" dev_info_list = ethtool.get_interfaces_info(dev.encode('utf8')) ipv6addrs = dev_info_list[0].get_ipv6_addresses() return [addr.address + '/' + str(addr.netmask) for addr in ipv6addrs]
def getnetmask(dev): dev_info_list = ethtool.get_interfaces_info(dev.encode('utf8')) netmask = dev_info_list[0].ipv4_netmask if netmask == 0: return '' return prefix2netmask(netmask)
def _getaddr(dev): dev_info_list = ethtool.get_interfaces_info(dev.encode("utf8")) addr = dev_info_list[0].ipv4_address if addr is None: addr = "" return addr
def read_network_interfaces(): intDict = {} intDict['class'] = "NETINTERFACES" if not ethtool_present: # ethtool is not available on non-linux platforms (as kfreebsd), skip it return intDict interfaces = list(set(ethtool.get_devices() + ethtool.get_active_devices())) for interface in interfaces: try: hwaddr = ethtool.get_hwaddr(interface) except: hwaddr = "" # slave devices can have their hwaddr changed try: master = os.readlink('/sys/class/net/%s/master' % interface) except: master = None if master: master_interface = os.path.basename(master) hwaddr = get_slave_hwaddr(master_interface, interface) try: module = ethtool.get_module(interface) except: if interface == 'lo': module = "loopback" else: module = "Unknown" try: ipaddr = ethtool.get_ipaddr(interface) except: ipaddr = "" try: netmask = ethtool.get_netmask(interface) except: netmask = "" try: broadcast = ethtool.get_broadcast(interface) except: broadcast = "" ip6_list = [] dev_info = ethtool.get_interfaces_info(interface) for info in dev_info: # one interface may have more IPv6 addresses for ip6 in info.get_ipv6_addresses(): scope = ip6.scope if scope == 'global': scope = 'universe' ip6_list.append({ 'scope': scope, 'addr': ip6.address, 'netmask': ip6.netmask }) intDict[interface] = {'hwaddr':hwaddr, 'ipaddr':ipaddr, 'netmask':netmask, 'broadcast':broadcast, 'module': module, 'ipv6': ip6_list} return intDict
def read_network_interfaces(): intDict = {} intDict['class'] = "NETINTERFACES" if not ethtool_present: # ethtool is not available on non-linux platforms (as kfreebsd), skip it return intDict interfaces = list(set(ethtool.get_devices() + ethtool.get_active_devices())) for interface in interfaces: try: hwaddr = ethtool.get_hwaddr(interface) except: hwaddr = "" # slave devices can have their hwaddr changed try: master = os.readlink('/sys/class/net/%s/master' % interface) except: master = None if master: master_interface = os.path.basename(master) hwaddr = get_slave_hwaddr(master_interface, interface) try: module = ethtool.get_module(interface) except: if interface == 'lo': module = "loopback" else: module = "Unknown" try: ipaddr = ethtool.get_ipaddr(interface) except: ipaddr = "" try: netmask = ethtool.get_netmask(interface) except: netmask = "" try: broadcast = ethtool.get_broadcast(interface) except: broadcast = "" ip6_list = [] dev_info = ethtool.get_interfaces_info(interface) for info in dev_info: # one interface may have more IPv6 addresses for ip6 in info.get_ipv6_addresses(): scope = ip6.scope if scope == 'global': scope = 'universe' ip6_list.append({ 'scope': scope, 'addr': ip6.address, 'netmask': ip6.netmask }) intDict[interface] = { 'hwaddr': hwaddr, 'ipaddr': ipaddr, 'netmask': netmask, 'broadcast': broadcast, 'module': module, 'ipv6': ip6_list } return intDict
def get_dev_macaddr(dev): info = ethtool.get_interfaces_info(dev)[0] return info.mac_address
def get_dev_netaddr(dev): info = ethtool.get_interfaces_info(dev)[0] return (info.ipv4_address and "%s/%s" % (info.ipv4_address, info.ipv4_netmask) or '')
def read_network_interfaces(): intDict = {} intDict['class'] = "NETINTERFACES" if not ethtool_present and not netifaces_present: # ethtool is not available on non-linux platforms (as kfreebsd), skip it sys.stderr.write("Warning: information about network interfaces could not be retrieved on this platform.\n") return intDict if ethtool_present: interfaces = list(set(ethtool.get_devices() + ethtool.get_active_devices())) else: interfaces = netifaces.interfaces() for interface in interfaces: try: if ethtool_present: hwaddr = ethtool.get_hwaddr(interface) else: hwaddr = netifaces.ifaddresses(interface)[netifaces.AF_LINK][0]['addr'] except: hwaddr = "" # slave devices can have their hwaddr changed try: master = os.readlink('/sys/class/net/%s/master' % interface) except: master = None if master: master_interface = os.path.basename(master) hwaddr = get_slave_hwaddr(master_interface, interface) try: if ethtool_present: module = ethtool.get_module(interface) else: driver_file = open('/sys/class/net/%s/device/uevent' % interface, 'r') module = driver_file.readline().split('=')[1].strip() driver_file.close() except: if interface == 'lo': module = "loopback" else: module = "Unknown" try: if ethtool_present: ipaddr = ethtool.get_ipaddr(interface) else: ipaddr = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['addr'] except: ipaddr = "" try: if ethtool_present: netmask = ethtool.get_netmask(interface) else: netmask = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['netmask'] except: netmask = "" try: if ethtool_present: broadcast = ethtool.get_broadcast(interface) else: broadcast = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['broadcast'] except: broadcast = "" ip6_list = [] if ethtool_present: dev_info = ethtool.get_interfaces_info(interface) for info in dev_info: # one interface may have more IPv6 addresses for ip6 in info.get_ipv6_addresses(): scope = ip6.scope if scope == 'global': scope = 'universe' ip6_list.append({ 'scope': scope, 'addr': ip6.address, 'netmask': ip6.netmask }) else: try: for dev_info in netifaces.ifaddresses(interface)[netifaces.AF_INET6]: ip6_addr = dev_info['addr'].split('%')[0] scope_info = ipaddress.IPv6Address(ip6_addr) if scope_info.is_global: scope = 'universe' elif scope_info.is_link_local: scope = 'link' elif scope_info.is_loopback: scope = 'host' elif scope_info.is_site_local: scope = 'site' # count number of '1' bits in netmask returned by netifaces ip6_netmask = dev_info['netmask'] netmask_bits = 0 for two_octets in ip6_netmask.split(':'): if not two_octets: break elif two_octets.lower() == 'ffff': netmask_bits += 16 else: # remove '0b' from begin and find last '1' in the string netmask_bits += 1 + bin(int(two_octets.split('/')[0], 16))[2:].rindex('1') ip6_list.append({ 'scope': scope, 'addr': ip6_addr, 'netmask': netmask_bits }) except KeyError: pass # no ipv6 for this interface intDict[interface] = {'hwaddr': hwaddr, 'ipaddr': ipaddr, 'netmask': netmask, 'broadcast': broadcast, 'module': module, 'ipv6': ip6_list} return intDict
def genxml(self, duration, accum, samples, xslt = None): seconds = duration.seconds hours = seconds / 3600 if hours: seconds -= (hours * 3600) minutes = seconds / 60 if minutes: seconds -= (minutes * 60) (sys, node, release, ver, machine) = os.uname() # Start new XML report self.xmlreport = xmlout.XMLOut('rteval', self.version) self.xmlreport.NewReport() self.xmlreport.openblock('run_info', {'days': duration.days, 'hours': hours, 'minutes': minutes, 'seconds': seconds}) self.xmlreport.taggedvalue('date', self.start.strftime('%Y-%m-%d')) self.xmlreport.taggedvalue('time', self.start.strftime('%H:%M:%S')) if self.annotate: self.xmlreport.taggedvalue('annotate', self.annotate) self.xmlreport.closeblock() self.xmlreport.openblock('uname') self.xmlreport.taggedvalue('node', node) isrt = 1 if ver.find(' RT ') == -1: isrt = 0 self.xmlreport.taggedvalue('kernel', release, {'is_RT':isrt}) self.xmlreport.taggedvalue('arch', machine) self.xmlreport.taggedvalue('baseos', self.baseos) self.xmlreport.closeblock() self.xmlreport.openblock("clocksource") self.xmlreport.taggedvalue('current', self.current_clocksource) self.xmlreport.taggedvalue('available', self.available_clocksource) self.xmlreport.closeblock() self.xmlreport.openblock('hardware') self.xmlreport.AppendXMLnodes(self.cputopology) self.xmlreport.taggedvalue('numa_nodes', self.numanodes) self.xmlreport.taggedvalue('memory_size', "%.3f" % self.memsize[0], {"unit": self.memsize[1]}) self.xmlreport.closeblock() self.xmlreport.openblock('services', {'init': self.init}) for s in self.services: self.xmlreport.taggedvalue("service", self.services[s], {"name": s}) self.xmlreport.closeblock() keys = self.kthreads.keys() if len(keys): keys.sort() self.xmlreport.openblock('kthreads') for pid in keys: self.xmlreport.taggedvalue('thread', self.kthreads[pid]['name'], { 'policy' : self.kthreads[pid]['policy'], 'priority' : self.kthreads[pid]['priority'], }) self.xmlreport.closeblock() modlist = util.get_modules() if len(modlist): self.xmlreport.openblock('kernelmodules') for mod in modlist: self.xmlreport.openblock('module') self.xmlreport.taggedvalue('info', mod['modname'], {'size': mod['modsize'], 'state': mod['modstate'], 'numusers': mod['numusers']}) if mod['usedby'] != '-': self.xmlreport.openblock('usedby') for ub in mod['usedby'].split(','): if len(ub): self.xmlreport.taggedvalue('module', ub, None) self.xmlreport.closeblock() self.xmlreport.closeblock() self.xmlreport.closeblock() # # Retrieve configured IP addresses # self.xmlreport.openblock('network_config') # Get the interface name for the IPv4 default gw route = open('/proc/net/route') defgw4 = None if route: rl = route.readline() while rl != '' : rl = route.readline() splt = rl.split("\t") # Only catch default route if len(splt) > 2 and splt[2] != '00000000' and splt[1] == '00000000': defgw4 = splt[0] break route.close() # Make an interface tag for each device found if hasattr(ethtool, 'get_interfaces_info'): # Using the newer python-ethtool API (version >= 0.4) for dev in ethtool.get_interfaces_info(ethtool.get_devices()): if cmp(dev.device,'lo') == 0: continue self.xmlreport.openblock('interface', {'device': dev.device, 'hwaddr': dev.mac_address} ) # Protcol configurations if dev.ipv4_address: self.xmlreport.openblock('IPv4', {'ipaddr': dev.ipv4_address, 'netmask': dev.ipv4_netmask, 'broadcast': dev.ipv4_broadcast, 'defaultgw': (defgw4 == dev.device) and '1' or '0'} ) self.xmlreport.closeblock() for ip6 in dev.get_ipv6_addresses(): self.xmlreport.openblock('IPv6', {'ipaddr': ip6.address, 'netmask': ip6.netmask, 'scope': ip6.scope} ) self.xmlreport.closeblock() self.xmlreport.closeblock() else: # Fall back to older python-ethtool API (version < 0.4) ifdevs = ethtool.get_active_devices() ifdevs.remove('lo') ifdevs.sort() for dev in ifdevs: self.xmlreport.openblock('interface', {'device': dev, 'hwaddr': ethtool.get_hwaddr(dev)} ) self.xmlreport.openblock('IPv4', {'ipaddr': ethtool.get_ipaddr(dev), 'netmask': ethtool.get_netmask(dev), 'defaultgw': (defgw4 == dev) and '1' or '0'} ) self.xmlreport.closeblock() self.xmlreport.closeblock() self.xmlreport.closeblock() self.xmlreport.openblock('loads', {'load_average':str(accum / samples)}) for load in self.loads: load.genxml(self.xmlreport) self.xmlreport.closeblock() self.cyclictest.genxml(self.xmlreport) # now generate the dmidecode data for this host d = dmi.DMIinfo(self.config.GetSection('rteval')) d.genxml(self.xmlreport) # Close the report - prepare for return the result self.xmlreport.close() # Write XML (or write XSLT parsed XML if xslt != None) if self.xml != None: self.xmlreport.Write(self.xml, xslt) else: # If no file is set, use stdout self.xmlreport.Write("-", xslt) # libxml2 defines a filename as "-" to be stdout
def genxml(self, duration, accum, samples, xslt=None): seconds = duration.seconds hours = seconds / 3600 if hours: seconds -= (hours * 3600) minutes = seconds / 60 if minutes: seconds -= (minutes * 60) (sys, node, release, ver, machine) = os.uname() # Start new XML report self.xmlreport = xmlout.XMLOut('rteval', self.version) self.xmlreport.NewReport() self.xmlreport.openblock( 'run_info', { 'days': duration.days, 'hours': hours, 'minutes': minutes, 'seconds': seconds }) self.xmlreport.taggedvalue('date', self.start.strftime('%Y-%m-%d')) self.xmlreport.taggedvalue('time', self.start.strftime('%H:%M:%S')) if self.annotate: self.xmlreport.taggedvalue('annotate', self.annotate) self.xmlreport.closeblock() self.xmlreport.openblock('uname') self.xmlreport.taggedvalue('node', node) isrt = 1 if ver.find(' RT ') == -1: isrt = 0 self.xmlreport.taggedvalue('kernel', release, {'is_RT': isrt}) self.xmlreport.taggedvalue('arch', machine) self.xmlreport.taggedvalue('baseos', self.baseos) self.xmlreport.closeblock() self.xmlreport.openblock("clocksource") self.xmlreport.taggedvalue('current', self.current_clocksource) self.xmlreport.taggedvalue('available', self.available_clocksource) self.xmlreport.closeblock() self.xmlreport.openblock('hardware') self.xmlreport.AppendXMLnodes(self.cputopology) self.xmlreport.taggedvalue('numa_nodes', self.numanodes) self.xmlreport.taggedvalue('memory_size', "%.3f" % self.memsize[0], {"unit": self.memsize[1]}) self.xmlreport.closeblock() self.xmlreport.openblock('services', {'init': self.init}) for s in self.services: self.xmlreport.taggedvalue("service", self.services[s], {"name": s}) self.xmlreport.closeblock() keys = self.kthreads.keys() if len(keys): keys.sort() self.xmlreport.openblock('kthreads') for pid in keys: self.xmlreport.taggedvalue( 'thread', self.kthreads[pid]['name'], { 'policy': self.kthreads[pid]['policy'], 'priority': self.kthreads[pid]['priority'], }) self.xmlreport.closeblock() modlist = util.get_modules() if len(modlist): self.xmlreport.openblock('kernelmodules') for mod in modlist: self.xmlreport.openblock('module') self.xmlreport.taggedvalue( 'info', mod['modname'], { 'size': mod['modsize'], 'state': mod['modstate'], 'numusers': mod['numusers'] }) if mod['usedby'] != '-': self.xmlreport.openblock('usedby') for ub in mod['usedby'].split(','): if len(ub): self.xmlreport.taggedvalue('module', ub, None) self.xmlreport.closeblock() self.xmlreport.closeblock() self.xmlreport.closeblock() # # Retrieve configured IP addresses # self.xmlreport.openblock('network_config') # Get the interface name for the IPv4 default gw route = open('/proc/net/route') defgw4 = None if route: rl = route.readline() while rl != '': rl = route.readline() splt = rl.split("\t") # Only catch default route if len(splt) > 2 and splt[2] != '00000000' and splt[ 1] == '00000000': defgw4 = splt[0] break route.close() # Make an interface tag for each device found if hasattr(ethtool, 'get_interfaces_info'): # Using the newer python-ethtool API (version >= 0.4) for dev in ethtool.get_interfaces_info(ethtool.get_devices()): if cmp(dev.device, 'lo') == 0: continue self.xmlreport.openblock('interface', { 'device': dev.device, 'hwaddr': dev.mac_address }) # Protcol configurations if dev.ipv4_address: self.xmlreport.openblock( 'IPv4', { 'ipaddr': dev.ipv4_address, 'netmask': dev.ipv4_netmask, 'broadcast': dev.ipv4_broadcast, 'defaultgw': (defgw4 == dev.device) and '1' or '0' }) self.xmlreport.closeblock() for ip6 in dev.get_ipv6_addresses(): self.xmlreport.openblock( 'IPv6', { 'ipaddr': ip6.address, 'netmask': ip6.netmask, 'scope': ip6.scope }) self.xmlreport.closeblock() self.xmlreport.closeblock() else: # Fall back to older python-ethtool API (version < 0.4) ifdevs = ethtool.get_active_devices() ifdevs.remove('lo') ifdevs.sort() for dev in ifdevs: self.xmlreport.openblock('interface', { 'device': dev, 'hwaddr': ethtool.get_hwaddr(dev) }) self.xmlreport.openblock( 'IPv4', { 'ipaddr': ethtool.get_ipaddr(dev), 'netmask': ethtool.get_netmask(dev), 'defaultgw': (defgw4 == dev) and '1' or '0' }) self.xmlreport.closeblock() self.xmlreport.closeblock() self.xmlreport.closeblock() self.xmlreport.openblock('loads', {'load_average': str(accum / samples)}) for load in self.loads: load.genxml(self.xmlreport) self.xmlreport.closeblock() self.cyclictest.genxml(self.xmlreport) # now generate the dmidecode data for this host d = dmi.DMIinfo(self.config.GetSection('rteval')) d.genxml(self.xmlreport) # Close the report - prepare for return the result self.xmlreport.close() # Write XML (or write XSLT parsed XML if xslt != None) if self.xml != None: self.xmlreport.Write(self.xml, xslt) else: # If no file is set, use stdout self.xmlreport.Write( "-", xslt) # libxml2 defines a filename as "-" to be stdout
def getaddr(dev): dev_info_list = ethtool.get_interfaces_info(dev.encode('utf8')) addr = dev_info_list[0].ipv4_address if addr is None: addr = '' return addr
import ethtool # Get info about all devices devices = ethtool.get_interfaces_info(ethtool.get_devices()) # Retrieve and print info for dev in devices: print "** Device: %s" % dev.device print "MAC addr: %s" % dev.mac_address print "IPv4: %s/%s Brd: %s" % (dev.ipv4_address, dev.ipv4_netmask, dev.ipv4_broadcast) for ip6 in dev.get_ipv6_addresses(): print "IPv6: [%s] %s/%i" % (ip6.scope, ip6.address, ip6.netmask) print
def test_etherinfo_objects(self): devnames = ethtool.get_devices() eis = ethtool.get_interfaces_info(devnames) for ei in eis: self._verify_etherinfo_object(ei)
def test_get_interface_info_all(self): eis = ethtool.get_interfaces_info(ethtool.get_devices()) for ei in eis: self._verify_etherinfo_object(ei)