def get_mac_by_pci_address(pci_addr, pf_interface=False):
 dev_path = _get_sysfs_netdev_path(pci_addr, pf_interface)
 if_name = get_ifname_by_pci_address(pci_addr, pf_interface)
 addr_file = os.path.join(dev_path, if_name, 'address')
 try:
  with open(addr_file) as f:
   mac = next(f).strip()
   return mac
 except (IOError, StopIteration) as e:
  LOG.warning(_LW('Could not find the expected sysfs file for determining the MAC address of the PCI device %(addr)s. May not be a NIC. Error: %(e)s'), {'addr': pci_addr, 'e': e})
  raise exception.PciDeviceNotFoundById(id=pci_addr)

def get_mac_by_pci_address ( pci_addr , pf_interface = False ) : dev_path = _get_sysfs_netdev_path ( pci_addr , pf_interface ) if_name = get_ifname_by_pci_address ( pci_addr , pf_interface ) addr_file = os . path . join ( dev_path , if_name , 'address' ) try : with open ( addr_file ) as f : mac = next ( f ) . strip ( ) return mac except ( IOError , StopIteration ) as e : LOG . warning ( _LW ( 'Could not find the expected sysfs file for determining the MAC address of the PCI device %(addr)s. May not be a NIC. Error: %(e)s' ) , { 'addr' : pci_addr , 'e' : e } ) raise exception . PciDeviceNotFoundById ( id = pci_addr )
get the mac address of the nic based on its pci address raises pcidevicenotfoundbyid in case the pci device is not a nic .