Commit ad7dcb64 authored by Robert Ricci's avatar Robert Ricci

Fix so that this script should work correctly if any of the planet-*

nodes have been removed from the topology.
parent d1397979
......@@ -15,7 +15,7 @@ my %opt;
use strict;
my (%elabips, %plabips);
my (%elabips, %plabips, %planetnodes);
open(HOSTS,"/etc/hosts") or die "Unable to open /etc/hosts: $!\n";
......@@ -26,6 +26,10 @@ while (<HOSTS>) {
$elabips{$1} = $IP;
} elsif ($firstname =~ /^(.+)-(plink|plan|pcloud|plabc)$/) {
$plabips{$1} = $IP;
} elsif ($firstname =~ /^(.+)-realinternet$/) {
# Note - we don't really get the planetlab node's IP address in the
# hosts file, so we just use this to find out if the node exists at all
$planetnodes{$1} = 1;
......@@ -47,11 +51,18 @@ foreach my $elabnode (keys %elabips) {
print "$elabips{$elabnode} $plabips{$planetnode} elabc-$elabnode\n";
} else {
# If there is not a corresponding planet-* node in the hosts file, it
# has probably been removed from the experiment, and we should skip ip
my $plabnode = $elabnode;
$plabnode =~ s/^elab/planet/;
if (! exists($planetnodes{$plabnode})){
warn "Skipping $plabnode, which doesn't exist\n";
# Let's hope this is an experiment with a real (not emulated) planetlab
# half. Note - this should be run by something that has sourced
# so that these are set
my $plabhostname = "$elabnode.$ENV{EXPERIMENT}.$ENV{PROJECT}";
$plabhostname =~ s/^elab/planet/;
# so that these enviroment variables are set
my $plabhostname = "$plabnode.$ENV{EXPERIMENT}.$ENV{PROJECT}";
# Find out the IP address for $plabhostname
open(H,"host $plabhostname |") or die "Unable to run host\n";
# Yuck. Why can't 'host' have a flag to spit out just the IP?
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment