Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
A script to avoid writting deployment files containing thousands of hosts
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 1 Dec 2005 14:30:02 +0000 (14:30 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 1 Dec 2005 14:30:02 +0000 (14:30 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1846 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/gras/tokenS/make_deployment.pl [new file with mode: 0755]

diff --git a/examples/gras/tokenS/make_deployment.pl b/examples/gras/tokenS/make_deployment.pl
new file mode 100755 (executable)
index 0000000..ca771e9
--- /dev/null
@@ -0,0 +1,50 @@
+#! /usr/bin/perl
+
+use strict;
+
+my $input    = shift @ARGV || die "Usage: $ARGV[0] platform_file.xml nb_host\n";
+my $nb_hosts = shift @ARGV || die "Usage: $ARGV[0] platform_file.xml nb_host\n";
+
+my @host;
+
+open IN,$input || die "Cannot open $input: $!\n";
+
+while (<IN>) {
+  next unless /<cpu name="([^"]*)"/; # "
+  
+  push @host, $1;
+}
+
+# map { print "$_\n" } @host;
+
+print "<?xml version='1.0'?>\n";
+print "<!DOCTYPE platform_description SYSTEM \"surfxml.dtd\">\n";
+print "<platform_description>\n\n";
+
+
+my $it_port=4000;
+my $it_host=0;
+
+for (my $i=0; $i<$nb_hosts -1; $i++) {
+
+  print "  <process host=\"".$host[$it_host]."\" function=\"node\">\n";
+  print "    <argument value=\"". $it_port ."\"/>     <!-- port on which I am listening -->\n";
+  $it_host ++;
+  if ($it_host == scalar @host) {
+    $it_host=0;
+    $it_port++;
+  }
+  print "    <argument value=\"". $host[ $it_host ]."\"/>   <!-- peer (successor) host -->\n";
+  print "    <argument value=\"".($it_port)."\"/>     <!-- port on which peer is listening -->\n";
+  print "  </process>\n\n";
+                
+}
+
+print "  <process host=\"".$host[$it_host]."\" function=\"node\">\n";
+print "    <argument value=\"". $it_port ."\"/>     <!-- port on which I am listening -->\n";
+print "    <argument value=\"". $host[ 0 ]."\"/>   <!-- peer (successor) host -->\n";
+print "    <argument value=\"4000\"/>     <!-- port on which peer is listening -->\n";
+print "    <argument value=\"--create-token\"/>   <!-- I'm first client, ie I have to create the token -->\n";
+print "  </process>\n\n";
+
+print "</platform_description>\n";