def get_vf_num_by_pci_address(pci_addr):
 VIRTFN_RE = re.compile('virtfn(\\d+)')
 virtfns_path = ('/sys/bus/pci/devices/%s/physfn/virtfn*' % pci_addr)
 vf_num = None
 try:
  for vf_path in glob.iglob(virtfns_path):
   if re.search(pci_addr, os.readlink(vf_path)):
    t = VIRTFN_RE.search(vf_path)
    vf_num = t.group(1)
    break
 except Exception:
  pass
 if (vf_num is None):
  raise exception.PciDeviceNotFoundById(id=pci_addr)
 return vf_num

def get_vf_num_by_pci_address ( pci_addr ) : VIRTFN_RE = re . compile ( 'virtfn(\\d+)' ) virtfns_path = ( '/sys/bus/pci/devices/%s/physfn/virtfn*' % pci_addr ) vf_num = None try : for vf_path in glob . iglob ( virtfns_path ) : if re . search ( pci_addr , os . readlink ( vf_path ) ) : t = VIRTFN_RE . search ( vf_path ) vf_num = t . group ( 1 ) break except Exception : pass if ( vf_num is None ) : raise exception . PciDeviceNotFoundById ( id = pci_addr ) return vf_num
get the vf number based on a vfs pci address a vf is associated with an vf number .