From a91382198572cb619eb460f83cc85c9bb7c95b10 Mon Sep 17 00:00:00 2001
From: root <root@clonex.home>
Date: Sun, 11 Feb 2024 14:18:02 +0100
Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20script=20nix=20batsim=20et=20d'u?=
 =?UTF-8?q?n=20script=20python=20pour=20g=C3=A9n=C3=A9rer=20des=20json=20a?=
 =?UTF-8?q?l=C3=A9atoires=20bas=C3=A9=20sur=20de=20vrai=20donn=C3=A9es,=20?=
 =?UTF-8?q?fait=20par=20:=20Karim/Adem?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 batsim.nix        | 14 +++++++++++++
 generationJson.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++
 multicloud.xml    | 38 ++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)
 create mode 100644 batsim.nix
 create mode 100755 generationJson.py
 create mode 100644 multicloud.xml

diff --git a/batsim.nix b/batsim.nix
new file mode 100644
index 0000000..81ef513
--- /dev/null
+++ b/batsim.nix
@@ -0,0 +1,14 @@
+let
+  kapack = import
+    ( fetchTarball "https://github.com/oar-team/nur-kapack/archive/master.tar.gz") {};
+in
+
+kapack.pkgs.mkShell rec {
+  name = "tuto-env-master";
+  buildInputs = [
+    kapack.batsim-master # simulator
+    kapack.batsched-master # scheduler
+    kapack.batexpe-master # experiment management tools
+    kapack.pkgs.curl # used to retrieve batsim workloads/platforms
+  ];
+}
diff --git a/generationJson.py b/generationJson.py
new file mode 100755
index 0000000..ac57279
--- /dev/null
+++ b/generationJson.py
@@ -0,0 +1,52 @@
+import json
+import random
+#Author : Karim /Adem
+
+data = {
+    "nb_res": 3,
+    "jobs": [
+        {"id": 1, "subtime": 0, "walltime": 100, "res": 1, "profile": "France_2018"},
+        {"id": 2, "subtime": 100, "walltime": 200, "res": 1, "profile": "France_2019"},
+        {"id": 3, "subtime": 200, "walltime": 300, "res": 1, "profile": "France_2020"},
+        {"id": 4, "subtime": 300, "walltime": 400, "res": 1, "profile": "France_2021"},
+        {"id": 5, "subtime": 400, "walltime": 500, "res": 2, "profile": "Morocco_2018"},
+        {"id": 6, "subtime": 500, "walltime": 600, "res": 2, "profile": "Morocco_2019"},
+        {"id": 7, "subtime": 600, "walltime": 700, "res": 2, "profile": "Morocco_2020"},
+        {"id": 8, "subtime": 700, "walltime": 800, "res": 2, "profile": "Morocco_2021"},
+        {"id": 9, "subtime": 800, "walltime": 900, "res": 3, "profile": "USA_2018"},
+        {"id": 10, "subtime": 900, "walltime": 1000, "res": 3, "profile": "USA_2019"},
+        {"id": 11, "subtime": 1000, "walltime": 1100, "res": 3, "profile": "USA_2020"},
+        {"id": 12, "subtime": 1100, "walltime": 1200, "res": 3, "profile": "USA_2021"}
+    ],
+    "profiles": {
+
+    }
+}
+
+# On génère des valeurs aléatoires avec une marge de 2 en partant sur de "vrai" données
+def generate_random_carbon(base, margin=2):
+    return f"{random.randint(base - margin, base + margin)}kg"
+
+# Profils avec les émissions de carbone spécifiques et la marge de ±2kg
+specific_carbon_emissions = {
+    "France_2018": 67, "France_2019": 69, "France_2020": 67, "France_2021": 65,
+    "Morocco_2018": 613, "Morocco_2019": 627, "Morocco_2020": 642, "Morocco_2021": 631,
+    "USA_2018": 412, "USA_2019": 393, "USA_2020": 369, "USA_2021": 379
+}
+
+
+for profile, base_emission in specific_carbon_emissions.items():
+    data["profiles"][profile] = {
+        "type": "delay",
+        "delay": 1,
+        "carbon_emission": generate_random_carbon(base_emission)
+    }
+
+# nom du fichier en sortie
+filename = 'jsonInput.json'
+
+# On écrit les données dans le fichier Json
+with open(filename, 'w') as file:
+    json.dump(data, file, indent=4)
+
+print(filename)
diff --git a/multicloud.xml b/multicloud.xml
new file mode 100644
index 0000000..b0c22bd
--- /dev/null
+++ b/multicloud.xml
@@ -0,0 +1,38 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
+<platform version="4.1">
+
+<zone id="AS0" routing="Full">
+    <cluster id="dcA" prefix="a" suffix="" radical="0-511"
+        speed="1Gf" bw="125MBps" lat="50us" bb_bw="2.25GBps"
+        bb_lat="500us" />
+    <cluster id="dcB" prefix="b" suffix="" radical="0-511"
+        speed="1Gf" bw="125MBps" lat="50us" bb_bw="2.25GBps"
+        bb_lat="500us" />
+    <cluster id="dcC" prefix="c" suffix="" radical="0-511"
+        speed="1Gf" bw="125MBps" lat="50us" bb_bw="2.25GBps"
+        bb_lat="500us" />
+
+    <cluster id="mastercluster" prefix="master_host" suffix="" radical="0-0"
+        speed="1Gf" bw="125MBps" lat="50us" bb_bw="2.25GBps"
+        bb_lat="500us">
+        <prop id="role" value="master" />
+    </cluster>
+
+    <link id="backbone" bandwidth="1.25GBps" latency="500us" />
+
+    <zoneRoute src="dcA" dst="mastercluster" gw_src="adcA_router"
+        gw_dst="master_hostmastercluster_router">
+        <link_ctn id="backbone" />
+    </zoneRoute>
+    <zoneRoute src="dcB" dst="mastercluster" gw_src="bdcB_router"
+        gw_dst="master_hostmastercluster_router">
+        <link_ctn id="backbone" />
+    </zoneRoute>
+    <zoneRoute src="dcC" dst="mastercluster" gw_src="cdcC_router"
+        gw_dst="master_hostmastercluster_router">
+        <link_ctn id="backbone" />
+    </zoneRoute>
+
+</zone>
+</platform>
-- 
GitLab