5 my $input = shift @ARGV || die "Usage: $ARGV[0] platform_file.xml nb_host\n";
6 my $nb_hosts = shift @ARGV || 0;
10 open IN,$input || die "Cannot open $input: $!\n";
13 next unless /<host id="([^"]*)"/; # "
18 die "No host found in $input. Is it really a SimGrid platform file?\nCheck that you didn't pass a deployment file, for example.\n"
19 unless (scalar @host);
22 $nb_hosts = scalar @host;
25 # map { print "$_\n" } @host;
27 print "<?xml version='1.0'?>\n";
28 print "<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n";
29 print "<platform version=\"2\">\n\n";
35 for (my $i=0; $i<$nb_hosts -1; $i++) {
37 print " <process host=\"".$host[$it_host]."\" function=\"node\">\n";
38 print " <argument value=\"". $it_port ."\"/> <!-- port on which I am listening -->\n";
40 if ($it_host == scalar @host) {
44 print " <argument value=\"". $host[ $it_host ]."\"/> <!-- peer (successor) host -->\n";
45 print " <argument value=\"".($it_port)."\"/> <!-- port on which peer is listening -->\n";
46 print " </process>\n\n";
50 print " <process host=\"".$host[$it_host]."\" function=\"node\">\n";
51 print " <argument value=\"". $it_port ."\"/> <!-- port on which I am listening -->\n";
52 print " <argument value=\"". $host[ 0 ]."\"/> <!-- peer (successor) host -->\n";
53 print " <argument value=\"4000\"/> <!-- port on which peer is listening -->\n";
54 print " <argument value=\"--create-token\"/> <!-- I'm first client, ie I have to create the token -->\n";
55 print " </process>\n\n";
57 print "</platform>\n";