summaryrefslogtreecommitdiffstats
path: root/scripts/dpdk_nic_bind.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-09-05 23:55:02 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-09-05 23:55:02 +0300
commit873e398fe2a52655b4d683acbcd05ef726cd97fa (patch)
tree563e7b3b0ee9668e6e9a88586b3b8e5e53deb0ea /scripts/dpdk_nic_bind.py
parenta11688641cc2a7f2c0a47ee9fc91af5768dd8b22 (diff)
fix dpdk_nic_bind.py for virtio interfaces @ OpenStack
Diffstat (limited to 'scripts/dpdk_nic_bind.py')
-rwxr-xr-xscripts/dpdk_nic_bind.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/scripts/dpdk_nic_bind.py b/scripts/dpdk_nic_bind.py
index 36f18adb..1242e3e3 100755
--- a/scripts/dpdk_nic_bind.py
+++ b/scripts/dpdk_nic_bind.py
@@ -220,8 +220,15 @@ def get_pci_device_details(dev_id):
sys_path = "/sys/bus/pci/devices/%s/net/" % dev_id
if exists(sys_path):
device["Interface"] = ",".join(os.listdir(sys_path))
+ device['net_path'] = sys_path
else:
device["Interface"] = ""
+ device['net_path'] = None
+ for path, dirs, _ in os.walk('/sys/bus/pci/devices/%s' % dev_id):
+ if 'net' in dirs:
+ device['net_path'] = os.path.join(path, 'net')
+ device["Interface"] = ",".join(os.listdir(device['net_path']))
+ break
# check if a port is used for connections (ssh etc)
device["Active"] = ""
@@ -292,10 +299,11 @@ def get_nic_details():
devices[d]["Module_str"] = ",".join(modules)
# get MAC from Linux if available
- mac_file = '/sys/bus/pci/devices/%s/net/%s/address' % (devices[d]['Slot'], devices[d]['Interface'])
- if os.path.exists(mac_file):
- with open(mac_file) as f:
- devices[d]['MAC'] = f.read().strip()
+ if devices[d]['net_path']:
+ mac_file = '%s/%s/address' % (devices[d]['net_path'], devices[d]['Interface'])
+ if os.path.exists(mac_file):
+ with open(mac_file) as f:
+ devices[d]['MAC'] = f.read().strip()
# get NUMA from Linux if available
numa_node_file = '/sys/bus/pci/devices/%s/numa_node' % devices[d]['Slot']