From 5433c081ea70ca5d59a99579155db6dd0d07078e Mon Sep 17 00:00:00 2001 From: Aleksandr Didenko Date: Thu, 18 Feb 2016 14:03:54 +0100 Subject: [PATCH] Add PCI-ID to NIC metadata Get PCI-ID infromation for NIC via sysfs and report it to nailgun. Implements: blueprint support-dpdk Change-Id: I7a6187be1e35e428f7d868584d2c1d4a8686b0bd --- agent | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/agent b/agent index d624d0a..306920a 100755 --- a/agent +++ b/agent @@ -302,6 +302,14 @@ class NodeAgent DEFAULT_SRIOV end + def nic_pci_id(int) + vendor = File.read("/sys/class/net/#{int}/device/vendor").chomp.gsub(/^0x/, '') + device = File.read("/sys/class/net/#{int}/device/device").chomp.gsub(/^0x/, '') + "#{vendor}:#{device}" + rescue + "" + end + def _detailed detailed_meta = { :system => _system_info, @@ -393,6 +401,8 @@ class NodeAgent end # Getting SR-IOV info int_meta[:interface_properties][:sriov] = sriov_info(int, int_meta[:bus_info]) + # Get PCI-ID + int_meta[:interface_properties][:pci_id] = nic_pci_id(int) detailed_meta[:interfaces] << int_meta end rescue Exception => e