Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ca771e9d88f3eaae82095b97707525f63634ed40
[simgrid.git] / examples / gras / tokenS / make_deployment.pl
1 #! /usr/bin/perl
2
3 use strict;
4
5 my $input    = shift @ARGV || die "Usage: $ARGV[0] platform_file.xml nb_host\n";
6 my $nb_hosts = shift @ARGV || die "Usage: $ARGV[0] platform_file.xml nb_host\n";
7
8 my @host;
9
10 open IN,$input || die "Cannot open $input: $!\n";
11
12 while (<IN>) {
13   next unless /<cpu name="([^"]*)"/; # "
14   
15   push @host, $1;
16 }
17
18 # map { print "$_\n" } @host;
19
20 print "<?xml version='1.0'?>\n";
21 print "<!DOCTYPE platform_description SYSTEM \"surfxml.dtd\">\n";
22 print "<platform_description>\n\n";
23
24
25 my $it_port=4000;
26 my $it_host=0;
27
28 for (my $i=0; $i<$nb_hosts -1; $i++) {
29
30   print "  <process host=\"".$host[$it_host]."\" function=\"node\">\n";
31   print "    <argument value=\"". $it_port ."\"/>     <!-- port on which I am listening -->\n";
32   $it_host ++;
33   if ($it_host == scalar @host) {
34     $it_host=0;
35     $it_port++;
36   }
37   print "    <argument value=\"". $host[ $it_host ]."\"/>   <!-- peer (successor) host -->\n";
38   print "    <argument value=\"".($it_port)."\"/>     <!-- port on which peer is listening -->\n";
39   print "  </process>\n\n";
40                 
41 }
42
43 print "  <process host=\"".$host[$it_host]."\" function=\"node\">\n";
44 print "    <argument value=\"". $it_port ."\"/>     <!-- port on which I am listening -->\n";
45 print "    <argument value=\"". $host[ 0 ]."\"/>   <!-- peer (successor) host -->\n";
46 print "    <argument value=\"4000\"/>     <!-- port on which peer is listening -->\n";
47 print "    <argument value=\"--create-token\"/>   <!-- I'm first client, ie I have to create the token -->\n";
48 print "  </process>\n\n";
49
50 print "</platform_description>\n";