3 # This script generates a specific deployment file for the Chord example.
4 # It assumes that the platform will be a cluster.
5 # Usage: python generate.py nb_nodes nb_bits end_date
6 # Example: python generate.py 100000 32 1000
10 if len(sys.argv) != 4:
11 print("Usage: python generate.py nb_nodes nb_bits end_date > deployment_file.xml")
14 nb_nodes = int(sys.argv[1])
15 nb_bits = int(sys.argv[2])
16 end_date = int(sys.argv[3])
18 max_id = 2 ** nb_bits - 1
21 sys.stdout.write("<?xml version='1.0'?>\n"
22 "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n"
23 "<platform version=\"3\">\n"
24 " <process host=\"c-0.me\" function=\"node\"><argument value=\"42\"/><argument value=\"%d\"/></process>\n" % end_date)
26 for i in range(1, nb_nodes):
30 my_id = random.randint(0, max_id)
31 ok = not my_id in all_ids
33 known_id = all_ids[random.randint(0, len(all_ids) - 1)]
35 line = " <process host=\"c-%d.me\" function=\"node\"><argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" /><argument value=\"%d\" /></process>\n" % (i, my_id, known_id, start_date, end_date)
36 sys.stdout.write(line)
39 sys.stdout.write("</platform>")