From 82ed81de5503bac3a2a318d363b08cfe139e7e14 Mon Sep 17 00:00:00 2001
From: Lucas Nussbaum <lucas.nussbaum@loria.fr>
Date: Thu, 5 Jul 2018 13:59:38 +0200
Subject: [PATCH] Add OAR properties for OPA

---
 .../oar-properties/lib/lib-oar-properties.rb      | 13 ++++++++++++-
 generators/wiki/lib/generators/oar_properties.rb  | 15 ++++++++++++---
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/generators/oar-properties/lib/lib-oar-properties.rb b/generators/oar-properties/lib/lib-oar-properties.rb
index 92ca757bae4..2f3a02815b2 100755
--- a/generators/oar-properties/lib/lib-oar-properties.rb
+++ b/generators/oar-properties/lib/lib-oar-properties.rb
@@ -97,7 +97,7 @@ def get_ref_node_properties_internal(cluster_uid, cluster, node_uid, node)
   puts "#{node_uid}: Warning - no rate info for the eth interface" if h['eth_count'] > 0 && h['eth_rate'] == 0
 
   # INFINIBAND
-  ni_mountable = node['network_adapters'].select { |k, na| /^ib[0-9]*(\.[0-9]*)?$/.match(k) && (na['enabled'] == true && (na['mounted'] == true || na['mountable'] == true)) }.values
+  ni_mountable = node['network_adapters'].select { |k, na| /^ib[0-9]*(\.[0-9]*)?$/.match(k) && (na['interface'] == 'InfiniBand' and na['enabled'] == true && (na['mounted'] == true || na['mountable'] == true)) }.values
   ni_fastest   = ni_mountable.max_by { |na| na['rate'] || 0 }
   ib_map = { 0 => 'NO', 10 => 'SDR', 20 => 'DDR', 40 => 'QDR', 56 => 'FDR' }
 
@@ -106,6 +106,17 @@ def get_ref_node_properties_internal(cluster_uid, cluster, node_uid, node)
   h['ib'] = ib_map[h['ib_rate']]
 
   puts "#{node_uid}: Warning - no rate info for the ib interface" if h['ib_count'] > 0 && h['ib_rate'] == 0
+  
+  # OMNIPATH
+  ni_mountable = node['network_adapters'].select { |k, na| /^ib[0-9]*(\.[0-9]*)?$/.match(k) && (na['interface'] == 'Omni-Path' and na['enabled'] == true && (na['mounted'] == true || na['mountable'] == true)) }.values
+  ni_fastest   = ni_mountable.max_by { |na| na['rate'] || 0 }
+
+  h['opa_count'] = ni_mountable.length
+  h['opa_rate']  = ni_mountable.length > 0 ? ni_fastest['rate'] / 1_000_000_000 : 0
+  h['opa'] = h['opa_count'] > 0
+
+  puts "#{node_uid}: Warning - no rate info for the opa interface" if h['opa_count'] > 0 && h['opa_rate'] == 0
+
 
   # MYRINET
   ni_mountable = node['network_adapters'].select { |k, na| /^myri[0-9]*$/.match(k) && (na['enabled'] == true && (na['mounted'] == true || na['mountable'] == true)) }.values
diff --git a/generators/wiki/lib/generators/oar_properties.rb b/generators/wiki/lib/generators/oar_properties.rb
index 9f7dc18d4ee..4a996653997 100644
--- a/generators/wiki/lib/generators/oar_properties.rb
+++ b/generators/wiki/lib/generators/oar_properties.rb
@@ -83,13 +83,22 @@ class OarPropertiesGenerator < WikiGenerator
       "description" => "the maximum rate of connected network interfaces in Gbps"
     },
     "ib" => {
-      "description" => "The technology of the infiniband interface"
+      "description" => "The technology of the Infiniband interface"
     },
     "ib_count" => {
       "description" => "The number of Infiniband interfaces available"
     },
     "ib_rate" => {
-      "description" => "The rate of the connected infiniband interface in Gbps"
+      "description" => "The rate of the connected Infiniband interface in Gbps"
+    },
+    "opa" => {
+      "description" => "Whether an Omni-Path interface is available"
+    },
+    "opa_count" => {
+      "description" => "The number of Omni-Path interfaces available"
+    },
+    "opa_rate" => {
+      "description" => "The rate of the connected Omni-Path interface in Gbps"
     },
     "myri" => {
       "description" => "The type of Myrinet interfaces available"
@@ -134,7 +143,7 @@ class OarPropertiesGenerator < WikiGenerator
   @@categories = {
     "Job-related properties" => ["besteffort", "deploy", "production", "cluster_priority", "max_walltime"],
     "Hierarchy" => ["cluster", "cpu", "core", "host", "network_address", "ip", "switch"],
-    "Hardware" => ["gpu", "gpu_count", "memnode", "memcore", "memcpu", "disktype", "disk_reservation_count", "myri_rate", "myri_count", "myri", "ib_rate", "ib_count", "ib", "eth_rate", "eth_count", "cpufreq", "cputype", "cpucore", "cpuarch", "virtual", "mic"],
+    "Hardware" => ["gpu", "gpu_count", "memnode", "memcore", "memcpu", "disktype", "disk_reservation_count", "myri_rate", "myri_count", "myri", "ib_rate", "ib_count", "ib", "opa", "opa_rate", "opa_count", "eth_rate", "eth_count", "cpufreq", "cputype", "cpucore", "cpuarch", "virtual", "mic"],
     "Miscellaneous" => ["wattmeter", "nodemodel"]
   }
 
-- 
GitLab