Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f815c21803e97199e52e97eb017692c6c74588d6
[simgrid.git] / buildtools / Cmake / generate_g5k_platform.pl
1 #!/usr/bin/perl -w
2 use strict;
3 my $toversion=3;
4
5 if($#ARGV!=1) {
6     die "Usage: ./generate_g5k_platform.pl g5k_username g5k_password\n";
7 }
8
9 print "<?xml version='1.0'?>\n";
10 print "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n";
11 print "<platform version=\"$toversion\">\n";
12 print "\t<AS id=\"AS_grid5000\" routing=\"Floyd\" >\n";
13
14 `rm -rf temp_g5k`;
15 `mkdir -p temp_g5k`;
16 chdir("./temp_g5k");
17 `wget https://api.grid5000.fr/2.0/grid5000/sites --http-user="$ARGV[0]" --http-password="$ARGV[1]" --no-check-certificate --quiet`;
18
19 open SITES_LIGNE, 'sites' or die "Unable to open sites $!\n";
20 my $line = "";
21 my $site = "";
22 my $cluster = "";
23 my $nodes = "";
24 my @AS_route = ();
25
26 print "\t\t<AS id=\"AS_interne\" routing=\"Floyd\">\n";
27 printf "\t\t\t<router id=\"lille\"/>\n";
28 printf "\t\t\t<router id=\"paris\"/>\n";
29 printf "\t\t\t<router id=\"nancy\"/>\n";
30 printf "\t\t\t<router id=\"rennes\"/>\n";
31 printf "\t\t\t<router id=\"lyon\"/>\n";
32 printf "\t\t\t<router id=\"bordeaux\"/>\n";
33 printf "\t\t\t<router id=\"grenoble\"/>\n";
34 printf "\t\t\t<router id=\"marseille\"/>\n";
35 printf "\t\t\t<router id=\"toulouse\"/>\n";
36 printf "\t\t\t<router id=\"sophia\"/>\n";
37 #printf "\t\t\t<router id=\"luxembourg\">\n";
38 print "\n";
39 printf "\t\t\t<link id=\"Lille_Paris\"        bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
40 printf "\t\t\t<link id=\"Paris_Nancy\"        bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
41 printf "\t\t\t<link id=\"Paris_Rennes\"       bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
42 printf "\t\t\t<link id=\"Paris_Lyon\"         bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
43 printf "\t\t\t<link id=\"Bordeaux_Lyon\"      bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
44 printf "\t\t\t<link id=\"Lyon_Grenoble\"      bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
45 printf "\t\t\t<link id=\"Lyon_Marseille\"     bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
46 printf "\t\t\t<link id=\"Marseille_Sophia\"   bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
47 printf "\t\t\t<link id=\"Marseille_Toulouse\" bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
48 #printf "\t\t<link id=\"Luxemburg_Nancy\"    bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
49 print "\n";
50
51 print "\t\t<route src=\"lille\"     dst=\"paris\"     ><link_ctn id=\"Lille_Paris\"/></route>\n";
52 print "\t\t<route src=\"paris\"     dst=\"nancy\"     ><link_ctn id=\"Paris_Nancy\"/></route>\n";
53 print "\t\t<route src=\"paris\"     dst=\"rennes\"    ><link_ctn id=\"Paris_Rennes\"/></route>\n";
54 print "\t\t<route src=\"paris\"     dst=\"lyon\"      ><link_ctn id=\"Paris_Lyon\"/></route>\n";
55 print "\t\t<route src=\"bordeaux\"  dst=\"lyon\"      ><link_ctn id=\"Bordeaux_Lyon\"/></route>\n";
56 print "\t\t<route src=\"lyon\"      dst=\"grenoble\"  ><link_ctn id=\"Lyon_Grenoble\"/></route>\n";
57 print "\t\t<route src=\"lyon\"      dst=\"marseille\" ><link_ctn id=\"Lyon_Marseille\"/></route>\n";
58 print "\t\t<route src=\"marseille\" dst=\"sophia\"    ><link_ctn id=\"Marseille_Sophia\"/></route>\n";
59 print "\t\t<route src=\"marseille\" dst=\"toulouse\"  ><link_ctn id=\"Marseille_Toulouse\"/></route>\n";
60 #print "\t\t<route src=\"Luxemburg\" dst=\"Nancy\"     ><link_ctn id=\"Luxemburg_Nancy\"/></route>\n";
61 print "\t\t</AS>\n";    
62
63 while(defined($line=<SITES_LIGNE>))
64 {
65         if($line =~ /"uid": "(.*)",/){
66                 $site = $1;
67                 print "\t\t<AS id=\"AS_$site\" routing=\"RuleBased\" >\n";
68                 `wget https://api.grid5000.fr/2.0/grid5000/sites/$site/clusters --http-user="$ARGV[0]" --http-password="$ARGV[1]" --no-check-certificate --quiet`;
69                 open CLUSTERS_LIGNE, 'clusters' or die "Unable to open clusters $!\n";
70                 while(defined($line=<CLUSTERS_LIGNE>))
71                 {
72                         if($line =~ /"uid": "(.*)",/){
73                                 $cluster = $1;
74                                 print "\t\t\t<cluster id=\"AS_$cluster\" prefix=\"$cluster-\" suffix=\".$cluster.grid5000.fr\"\n";
75                                 `wget https://api.grid5000.fr/2.0/grid5000/sites/$site/clusters/$cluster/nodes --http-user="$ARGV[0]" --http-password="$ARGV[1]" --no-check-certificate --quiet`;
76                                 open NODES_LIGNE, 'nodes' or die "Unable to open nodes $!\n";
77                                 while(defined($line=<NODES_LIGNE>))
78                                 {
79                                         if($line =~ /"total": (.*),/){
80                                                 print "\t\t\t\tradical=\"1-$1\" power=\"3.542E9\" bw=\"1.25E8\" lat=\"1.0E-4\""."\n";
81                                                 print "\t\t\t\tbb_bw=\"1.25E9\" bb_lat=\"1.0E-4\"></cluster>\n";
82                                         }
83                                 }
84                                 print "\t\t\t<link   id=\"link_$cluster\" bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n\n";
85                                 close NODES_LIGNE;
86                                 `rm nodes`;
87                         }
88                 }
89                 close CLUSTERS_LIGNE;
90                 `rm clusters`;
91                 
92                 print "\t\t\t<AS id=\"gw_AS_$site\" routing=\"Full\">\n";
93                 print "\t\t\t\t<router id=\"gw_$site\"/>\n";
94                 print "\t\t\t</AS>\n";
95                 print "\t\t\t<link   id=\"link_gw_$site\" bandwidth=\"1.25E9\" latency=\"1.0E-4\"/>\n";
96                 print "\n";
97                 
98                 print "\t\t\t<ASroute src=\"^AS_(.*)\$\" dst=\"^AS_(.*)\$\"\n";
99                 print "\t\t\t\tgw_src=\"\$1src-AS_\$1src_router.\$1src.grid5000.fr\"\n";
100                 print "\t\t\t\tgw_dst=\"\$1dst-AS_\$1dst_router.\$1dst.grid5000.fr\"\n";
101                 print "\t\t\t\tsymmetrical=\"YES\">\n";
102                 print "\t\t\t\t\t<link_ctn id=\"link_\$1src\"/>\n";
103                 print "\t\t\t\t\t<link_ctn id=\"link_\$1dst\"/>\n";
104                 print "\t\t\t</ASroute>\n\n"; 
105
106                 print "\t\t\t<ASroute src=\"^AS_(.*)\$\" dst=\"^gw_AS_(.*)\$\"\n";
107                 print "\t\t\t\tgw_src=\"\$1src-AS_\$1src_router.\$1src.grid5000.fr\"\n";
108                 print "\t\t\t\tgw_dst=\"gw_\$1dst\"\n";
109                 print "\t\t\t\tsymmetrical=\"NO\">\n";
110                 print "\t\t\t\t\t<link_ctn id=\"link_\$1src\"/>\n";
111                 print "\t\t\t</ASroute>\n\n"; 
112                 
113                 print "\t\t\t<ASroute src=\"^gw_AS_(.*)\$\" dst=\"^AS_(.*)\$\"\n";
114                 print "\t\t\t\tgw_src=\"gw_\$1src\"\n";
115                 print "\t\t\t\tgw_dst=\"\$1dst-AS_\$1dst_router.\$1dst.grid5000.fr\"\n";
116                 print "\t\t\t\tsymmetrical=\"NO\">\n";
117                 print "\t\t\t\t\t<link_ctn id=\"link_\$1dst\"/>\n";
118                 print "\t\t\t</ASroute>\n\n"; 
119                 
120                 print "\t\t</AS>\n";
121                 
122                 push @AS_route, $site;
123         }
124 }
125
126 while(@AS_route)
127 {
128         $site = pop @AS_route;
129         print "\t\t<ASroute src=\"AS_$site\" dst=\"AS_interne\" gw_src=\"gw_$site\"";
130         if( $site =~ /^orsay$/ )
131         {
132                 print " gw_dst=\"paris\"";
133         }
134         else
135         {
136                 print " gw_dst=\"$site\"";
137         }
138         print " symmetrical=\"YES\">\n";
139         print "\t\t\t<link_ctn id=\"link_gw_$site\"/>\n";
140         print "\t\t</ASroute>\n";
141         
142 #       print "\t\t<ASroute src=\"AS_interne\" dst=\"AS_$site\" gw_dst=\"gw_$site\"";
143 #       if( $site =~ /^orsay$/ )
144 #       {
145 #               print " gw_src=\"paris\"";
146 #       }
147 #       else
148 #       {
149 #               print " gw_src=\"$site\"";
150 #       }
151 #       print " symmetrical=\"NO\">\n";
152 #       print "\t\t\t<link_ctn id=\"link_gw_$site\"/>\n";
153 #       print "\t\t</ASroute>\n";
154 }
155
156 print "\t</AS>\n";
157 print "</platform>\n";
158 `rm sites`;
159 close SITES_LIGNE;