Skip to content
Snippets Groups Projects
Commit ad7dcb64 authored by Robert Ricci's avatar Robert Ricci
Browse files

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

nodes have been removed from the topology.
parent d1397979
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ my %opt;
getopts('p',\%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";
$lines_output++;
} 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";
next;
}
# Let's hope this is an experiment with a real (not emulated) planetlab
# half. Note - this should be run by something that has sourced
# common-env.sh so that these are set
my $plabhostname = "$elabnode.$ENV{EXPERIMENT}.$ENV{PROJECT}.emulab.net";
$plabhostname =~ s/^elab/planet/;
# common-env.sh so that these enviroment variables are set
my $plabhostname = "$plabnode.$ENV{EXPERIMENT}.$ENV{PROJECT}.emulab.net";
# 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?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment