-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgenerate.py
executable file
·99 lines (80 loc) · 4.7 KB
/
generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/python
# This script generates a specific deployment file for the injection simulator.
# It assumes that the platform will be a cluster.
# Usage: python generate.py scheduling policies nb_nodes
# Example: python generate.py centralized 100000 32 1000
import sys, random
## centralized scheduling
largv=len(sys.argv)
nb_nodes = int(sys.argv[2])
if (sys.argv[1] == 'centralized'):
sys.stderr.write("generate deployment file for entropy");
sys.stdout.write("<?xml version='1.0'?>\n"
"<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n"
"<platform version=\"4\">\n"
" <process host=\"node%d\" function=\"injector.Injector\"> </process>\n"
" <process host=\"node%d\" function=\"simulation.CentralizedResolver\"> </process>\n"
"</platform>" % (nb_nodes +1, nb_nodes));
elif (sys.argv[1] == 'example'):
sys.stderr.write("generate deployment file for the simple example");
sys.stdout.write("<?xml version='1.0'?>\n"
"<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n"
"<platform version=\"4\">\n"
" <process host=\"node%d\" function=\"injector.Injector\"> </process>\n"
" <process host=\"node%d\" function=\"simulation.ExampleResolver\"> </process>\n"
"</platform>" % (nb_nodes +1, nb_nodes));
elif (sys.argv[1] == 'without'):
sys.stderr.write("generate deployment file for entropy");
sys.stdout.write("<?xml version='1.0'?>\n"
"<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n"
"<platform version=\"4\">\n"
" <process host=\"node%d\" function=\"injector.Injector\"> </process>\n"
"</platform>" % (nb_nodes +1));
elif (sys.argv[1] == 'hierarchical'):
nb_servicenodes = int(sys.argv[3])
sys.stderr.write("generate deployment file for snooze");
sys.stdout.write("<?xml version='1.0'?>\n"
"<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n"
"<platform version=\"4\">\n"
" <process host=\"node%d\" function=\"injector.Injector\"> </process>\n"
" <process host=\"node%d\" function=\"simulation.HierarchicalResolver\"> </process>\n"
% (nb_nodes + nb_servicenodes, nb_nodes + nb_servicenodes))
# for i in range(0, nb_nodes):
# line = " <process host=\"node%d\" function=\"scheduling.hierarchical.snooze.LocalController\">\
#<argument value=\"node%d\" /><argument value=\"localController-%d\" />\
#</process>\n" % (i, i, i)
# sys.stdout.write(line)
for i in range(nb_nodes, nb_nodes+nb_servicenodes):
line = " <process host=\"node%d\" function=\"scheduling.hierarchical.snooze.GroupManager\">\
<argument value=\"node%d\" /><argument value=\"groupManager-%d\" />\
</process>\n" % (i, i, i)
sys.stdout.write(line)
sys.stdout.write("</platform>")
elif (sys.argv[1] == 'distributed'):
nb_nodes = int(sys.argv[2])
nb_cpu = int(sys.argv[3])
total_cpu_cap = int(sys.argv[4])
ram = int(sys.argv[5])
port_orig = int(sys.argv[6])
port = port_orig
sys.stdout.write("<?xml version='1.0'?>\n"
"<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n"
"<platform version=\"4\">\n"
" <process host=\"node%d\" function=\"injector.Injector\"> </process>\n" % (nb_nodes))
for i in range(0, nb_nodes - 1):
line = " <process host=\"node%d\" function=\"simulation.DistributedResolver\">\n \
<argument value=\"node%d\" /><argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" />\n \
<argument value=\"node%d\" /><argument value=\"%d\" />\n \
</process>\n" % (i, i, nb_cpu, total_cpu_cap, ram, port, i+1, port+1)
port+=1
sys.stdout.write(line)
# link the last agent to the first
line = " <process host=\"node%d\" function=\"simulation.DistributedResolver\">\n \
<argument value=\"node%d\" /><argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" />\n \
<argument value=\"node%d\" /><argument value=\"%d\" />\n \
</process>\n" % (nb_nodes-1, nb_nodes-1, nb_cpu, total_cpu_cap, ram, port, 0, port_orig)
sys.stdout.write(line)
sys.stdout.write("</platform>")
else:
print("Usage: python generate.py scheduling_policy nb_nodes or python generate.py distributed nb_nodes nb_cpu total_cpu_cap ram port > dvms_deploy.xml")
sys.exit(1)