From 543c3d10f9bf197183df4826a8774f1876f33d8e Mon Sep 17 00:00:00 2001
From: Samir Noir <samir.noir@inria.fr>
Date: Thu, 7 Oct 2021 16:51:06 +0200
Subject: [PATCH] [lib] handle new memory_devices in nodes' description

---
 lib/refrepo/gen/reference-api.rb                 | 8 ++++++++
 lib/refrepo/valid/input/schemas/schema-node.yaml | 5 +++++
 2 files changed, 13 insertions(+)

diff --git a/lib/refrepo/gen/reference-api.rb b/lib/refrepo/gen/reference-api.rb
index a3e2f491f79..49b7e479d17 100644
--- a/lib/refrepo/gen/reference-api.rb
+++ b/lib/refrepo/gen/reference-api.rb
@@ -136,6 +136,14 @@ def generate_reference_api
         node["network_adapters"].each { |key, hash| node["network_adapters"][key]["device"] = key; } # Add "device: ethX" within the hash
         node["network_adapters"] = node["network_adapters"].sort_by_array(["eth0", "eth1", "eth2", "eth3", "eth4", "eth5", "eth6", "ib0.8100", "ib0", "ib1", "ib2", "ib3", "ibs1","bmc", "eno1", "eno2", "eno1np0", "eno2np1", "ens4f0", "ens4f1", "ens5f0", "ens5f1"]).values
 
+        node["memory_devices"].each { |key, hash| node["memory_devices"][key]["device"] = key; } # Add "device: dimm_a1" within the hash
+        node["memory_devices"] = node["memory_devices"].sort_by { |d, _|
+          [d.gsub(/dimm_(\d+)/, '\1').to_i,
+           d.gsub(/^dimm_([A-z]+)(\d+)$/, '\1'),
+           d.gsub(/^dimm_([A-z]+)(\d+)$/, '\2').to_i]
+        }.to_h
+        node["memory_devices"] = node["memory_devices"].values
+
         write_json(cluster_path.join("nodes","#{node_uid}.json"), node)
       end
     end
diff --git a/lib/refrepo/valid/input/schemas/schema-node.yaml b/lib/refrepo/valid/input/schemas/schema-node.yaml
index 58ac14a7815..fd1a50cc709 100644
--- a/lib/refrepo/valid/input/schemas/schema-node.yaml
+++ b/lib/refrepo/valid/input/schemas/schema-node.yaml
@@ -33,6 +33,11 @@ kavlan6:
 main_memory:
   ram_size: integer
   pmem_size: optional_integer
+memory_devices:
+  <multi>:
+    size: integer
+    technology: string
+    firmware: optional_string
 mic: optional_hash
 network_adapters:
   <multi>:
-- 
GitLab