Browse Source

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
tags/9.0
Aleksandr Didenko 3 years ago
parent
commit
5433c081ea
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      agent

+ 10
- 0
agent View File

@@ -302,6 +302,14 @@ class NodeAgent
302 302
     DEFAULT_SRIOV
303 303
   end
304 304
 
305
+  def nic_pci_id(int)
306
+    vendor = File.read("/sys/class/net/#{int}/device/vendor").chomp.gsub(/^0x/, '')
307
+    device = File.read("/sys/class/net/#{int}/device/device").chomp.gsub(/^0x/, '')
308
+    "#{vendor}:#{device}"
309
+  rescue
310
+    ""
311
+  end
312
+
305 313
   def _detailed
306 314
     detailed_meta = {
307 315
       :system => _system_info,
@@ -393,6 +401,8 @@ class NodeAgent
393 401
         end
394 402
         # Getting SR-IOV info
395 403
         int_meta[:interface_properties][:sriov] = sriov_info(int, int_meta[:bus_info])
404
+        # Get PCI-ID
405
+        int_meta[:interface_properties][:pci_id] = nic_pci_id(int)
396 406
         detailed_meta[:interfaces] << int_meta
397 407
       end
398 408
     rescue Exception => e

Loading…
Cancel
Save