Changeset c23025e
- Timestamp:
- Sep 11, 2007 5:51:25 PM (17 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 4addf9d
- Parents:
- 63f7c7e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedkit/splitter.pl
r63f7c7e rc23025e 33 33 34 34 # XXX system with a relative pathname is sort of gross 35 if ( $host ne "localhost") { 36 system ("ssh $user\@$host $cmd"); 37 } 38 else { 39 system ("$cmd"); 40 } 35 # if ( $host ne "localhost") { 36 #system ("ssh $user\@$host $cmd"); 37 #} 38 #else { 39 #system ("$cmd"); 40 #} 41 system ("ssh $user\@$host $cmd"); 41 42 if ($?) { 42 43 warn "$wname failed $?\n" if $wname; … … 66 67 # hash, as is the project name on the remote testbed. Parameters are the 67 68 # testbed and the experiment id. Configuration files are scp-ed over to the 68 # target testbed. Then the current state of the experiment determined using 69 # expinfo. From that state, the experiment is either created, modified or 70 # spapped in. If everything succeeds, true is returned. 69 # target testbed from the global $tmpdir/$tb directory. Then the current state 70 # of the experiment determined using expinfo. From that state, the experiment 71 # is either created, modified or spapped in. If everything succeeds, true is 72 # returned. 71 73 sub start_segment { 72 74 my($tb, $eid) = @_; # testbed and experiment ID 73 my($host) = $host{$tb}; # Host name of remote users75 my($host) = "$host{$tb}$domain{$tb}"; # Host name of remote ops (FQDN) 74 76 my($user) = $user{$tb}; # user to pass to ssh 75 77 my($pid) = $project{$tb}; # remote project to start the … … 81 83 82 84 # Determine the status of the remote experiment 83 if ( $host ne "localhost") { 84 open(STATUS, "ssh $user\@$host /usr/testbed/bin/expinfo $pid $eid|") || 85 die "Can't ssh to $user\@$host:$!\n"; 86 } 87 else { 88 open(STATUS, "/usr/testbed/bin/expinfo $pid $eid|") || 89 die "Can't call expinfo locally"; 90 } 85 #if ( $host ne "localhost") { 86 # open(STATUS, "ssh $user\@$host /usr/testbed/bin/expinfo $pid $eid|") || 87 # die "Can't ssh to $user\@$host:$!\n"; 88 # } 89 # else { 90 # open(STATUS, "/usr/testbed/bin/expinfo $pid $eid|") || 91 # die "Can't call expinfo locally"; 92 # } 93 open(STATUS, "ssh $user\@$host /usr/testbed/bin/expinfo $pid $eid|") || 94 die "Can't ssh to $user\@$host:$!\n"; 91 95 # XXX: this is simple now. Parsing may become more complex 92 96 while (<STATUS>) { … … 98 102 99 103 # Copy the experiment definition data over (unless the host is local) 100 if ( $host ne "localhost") { 101 &scp_file($tclfile, "$user\@$host") || return 0; 102 } 103 104 #if ( $host ne "localhost") { 105 # &scp_file("$tmpdir/$tb/$tclfile", "$user\@$host") || return 0; 106 # } 107 # else { 108 # # XXX this ain't quite right 109 # system("cp $tmpdir/$tb/$tclfile ."); 110 # } 111 112 &scp_file("$tmpdir/$tb/$tclfile", "$user\@$host") || return 0; 104 113 # Remote experiment is active. Modify it. 105 114 if ($state eq "active") { 106 115 # First copy new scripts and hostinfo into the remote /proj 107 &scp_file("./hostnames", "$user\@$host", $to_hostname) || return 0; 116 &scp_file("$tmpdir/$tb/hostnames", "$user\@$host", $to_hostname) || 117 return 0; 108 118 &ship_scripts($host, $user, $proj_dir) || return 0; 109 119 &ssh_cmd($user, $host, "/usr/testbed/bin/modexp -r -s -w $pid " . … … 151 161 my($tb, $eid) = @_; 152 162 my($user) = "$user{$tb}"; 153 my($host) = "$host{$tb} ";163 my($host) = "$host{$tb}$domain{$tb}"; 154 164 my($pid) = $project{$tb}; 155 165 … … 159 169 } 160 170 161 $tcl_splitter = "/usr/testbed/lib/ns2ir/parse.tcl"; # tcl program to split experiments 171 # tcl program to split experiments 172 # $tcl_splitter = "/usr/testbed/lib/ns2ir/parse.tcl"; 173 $tcl_splitter = "/users/faber/testbed/tbsetup/ns2ir/parse.tcl"; 162 174 $tclsh = "/usr/local/bin/otclsh"; # tclsh to call directly 163 175 … … 169 181 170 182 # Argument processing. 171 getopts('d:c:m:e:f:n ', \%opts);183 getopts('d:c:m:e:f:nt:', \%opts); 172 184 173 185 $eid = $opts{'e'}; # Experiment ID … … 175 187 $master = $opts{'m'}; # Master testbed 176 188 $startem = $opts{'n'} ? 0 : 1; # If true, start the sub-experiments 189 $tmpdir = $opts{'t'} || "/tmp"; # where to collect tmp files 177 190 $config = $opts{'c'} || "./testbeds"; 178 191 $local_script_dir = $opts{'d'}; # Local scripts 192 193 $tmpdir .= "/split$$"; 194 195 unless (-d "$tmpdir") { 196 mkdir("$tmpdir") || die "Can't create $tmpdir: $!"; 197 } 198 179 199 180 200 for $s (@scripts) { … … 190 210 next if /^#/; 191 211 chomp; 192 ($tb, $h, $ u, $p, $es, $gs, $mes, $mgs, $t, $i) = split(":", $_);212 ($tb, $h, $d, $u, $p, $es, $gs, $mes, $mgs, $t, $i) = split(":", $_); 193 213 $host{$tb} = $h; 194 214 $user{$tb} = $u; 215 $domain{$tb} = $d; 195 216 $project{$tb} = $p; 196 217 $gwtype{$tb} = $t; … … 200 221 $mgwstart{$tb} = $mgs; 201 222 $gwimage{$tb} = $i; 223 224 # Make sure the domain starts with a period 225 $domain{$tb} = ".$domain{$tb}" unless $domain{$tb} =~ /^\./; 202 226 } 203 227 close(CONF); 204 228 205 229 # Open a pipe to the splitter program and start it parsing the experiments 206 open(PIPE, "$tclsh $tcl_splitter -s - p $pid $gid $eid $tcl|") ||230 open(PIPE, "$tclsh $tcl_splitter -s -m $master -p $pid $gid $eid $tcl|") || 207 231 die "Cannot execute $tclsh $tcl_splitter -s -p $pid $gid $eid $tcl:$!\n"; 208 232 … … 218 242 if ($host{$ctb}) { 219 243 $allocated{$ctb}++; # Keep track of the testbeds allocated 220 $destfile = "./$eid.$ctb.tcl"; 244 245 unless (-d "$tmpdir/$ctb") { 246 mkdir("$tmpdir/$ctb") || die "Can't create $tmpdir/$ctb: $!"; 247 } 248 $destfile = "$tmpdir/$ctb/$eid.$ctb.tcl"; 221 249 222 250 open(FILE, ">$destfile") || die "Cannot open $destfile:$!\n"; … … 228 256 next; 229 257 }; 258 230 259 # End of that experiment 231 260 /^#\s+End\s+Testbed\s+\((\w+)\)/ && do { … … 236 265 next; 237 266 }; 267 268 # Beginning of a gateway set 269 /^#\s+Begin\s+gateways\s+\((\w+)\)/ && do { 270 $gateways = $1; 271 # If we've heard of this tb, create the config lines for it one at a 272 # time. 273 if ($allocated{$gateways}) { 274 # Just in case. This directory should already have been created 275 # above. 276 unless (-d "$tmpdir/$gateways") { 277 mkdir("$tmpdir/$gateways") || 278 die "Can't create $tmpdir/$gateways: $!"; 279 } 280 } 281 else { 282 warn "Gateways given (and ignored) for testbed not in use: " . 283 "$gateways\n"; 284 $gateways = 0; 285 } 286 next; 287 }; 288 /^#\s+End\s+gateways\s+\((\w+)\)/ && do { 289 die "Mismatched gateway markers ($1, $gateways)\n" 290 unless !$gateways || $gateways == $1; 291 $gateways = 0; 292 next; 293 }; 238 294 # Beginning of the hostnames list. Collection is always in the hostnames 239 295 # file. 240 296 /^#\s+Begin\s+hostnames/ && do { 241 $destfile = " ./hostnames";297 $destfile = "$tmpdir/hostnames"; 242 298 open(FILE, ">$destfile") || die "Can't open $destfile:$!\n"; 243 299 next; … … 249 305 next; 250 306 }; 307 308 # Generate gateway configuration info, one file per line 309 $gateways && do { 310 chomp; 311 my($dtb, $myname, $desthost, $type) = split(" ", $_); 312 my($sdomain) = $domain{$gateways}; # domain for the source 313 my($ddomain) = $domain{$dtb}; # domain for the destination 314 315 # If either end of this link is in the master side of the testbed, that 316 # side is the active end. Otherwise the first testbed encountered in 317 # the file will be the active end. The $active_end variable keeps 318 # track of those decisions 319 if ( $dtb eq $master ) { $active = "false"; } 320 elsif ($gateways eq $master ) { $active = "true"; } 321 elsif ( $active_end{"$dtb-$gateways"} ) { $active="false"; } 322 else { $active_end{"$gateways-$dtb"}++; $active = "true"; } 323 324 # Write out the file 325 open(GWCONFIG, ">$tmpdir/$gateways/$myname$sdomain.gw.conf") || 326 die "can't open $tmpdir/%gateways/$myname$sdomain.gw.conf: $!\n"; 327 print GWCONFIG "Active: $active\n"; 328 print GWCONFIG "Type: $type\n"; 329 print GWCONFIG "Peer: $desthost$ddomain\n"; 330 print GWCONFIG "Pubkeys: /placeholder\n"; 331 print GWCONFIG "Privkeys: /placeholder\n"; 332 close(GWCONFIG); 333 334 #done processing gateway entry, ready for next line 335 next; 336 }; 337 251 338 252 339 next unless $destfile; # Unidentified testbed, ignore config … … 352 439 testbed. 353 440 441 =item host 442 443 The host name of the testbed's ops node. The user calling B<splitter.pl> must 444 be able to execute commands on this host via L<ssh(1)>. 445 446 =item domain 447 448 The domain of nodes in this testbed (including the ops host). 449 354 450 =item project 355 451
Note: See TracChangeset
for help on using the changeset viewer.