From 69e38a0445679bac7d6c015958f6f0c9259e12e1 Mon Sep 17 00:00:00 2001
From: Matthieu Imbert <matthieu.imbert@inria.fr>
Date: Thu, 7 May 2020 07:49:50 +0200
Subject: [PATCH] [ipv6] add ipv6 data to sites in reference repository

---
 input/grid5000/ipv6.yaml    |  9 +++++++++
 lib/refrepo/input_loader.rb | 15 ++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/input/grid5000/ipv6.yaml b/input/grid5000/ipv6.yaml
index d5e99e7920..3cca36ab67 100644
--- a/input/grid5000/ipv6.yaml
+++ b/input/grid5000/ipv6.yaml
@@ -10,3 +10,12 @@ ipv6:
     nantes: 6
     rennes: 7
     sophia: 8
+  site_global_kavlans:
+    grenoble: 11
+    lille: 12
+    luxembourg: 20
+    lyon: 13
+    nancy: 14
+    nantes: 21
+    rennes: 16
+    sophia: 18
diff --git a/lib/refrepo/input_loader.rb b/lib/refrepo/input_loader.rb
index a321413bbd..1e605f21c2 100644
--- a/lib/refrepo/input_loader.rb
+++ b/lib/refrepo/input_loader.rb
@@ -54,7 +54,10 @@ def load_yaml_file_hierarchy(directory = File.expand_path("../../input/grid5000/
   # populate each node with its IPv4 addresses
   add_ipv4(global_hash)
 
-  # populate each node with its kavlan IPv4 IPs
+  # add some ipv6 informations in sites
+  add_site_ipv6_infos(global_hash)
+
+  # populate each node with its kavlan IPs
   add_kavlan_ips(global_hash)
   add_kavlan_ipv6s(global_hash)
 
@@ -315,3 +318,13 @@ def add_theorical_flops(h)
     end
   end
 end
+
+def add_site_ipv6_infos(h)
+  h['sites'].each_pair do |site_uid, hs|
+    h['sites'][site_uid]['ipv6'] = {}
+    h['sites'][site_uid]['ipv6']['prefix'] = h['ipv6']['prefix'] + ":%02x" % (h['ipv6']['site_indexes'][site_uid])
+    h['sites'][site_uid]['ipv6']['site_index'] = h['ipv6']['site_indexes'][site_uid]
+    h['sites'][site_uid]['ipv6']['site_global_kavlan'] = h['ipv6']['site_global_kavlans'][site_uid]
+  end
+end
+
-- 
GitLab