Commit 3b084bff authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Write a little data file into /var/emulab/boot that gives the

interface to IP address assignment, and is trivially parsable.
This is less onerous then telling people to parse the output of
ifconfig with perl.
parent d1bf7d11
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group. # Copyright (c) 2004, 2005 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
use English; use English;
...@@ -72,7 +72,8 @@ if (@ARGV) { ...@@ -72,7 +72,8 @@ if (@ARGV) {
# Local goo # Local goo
# After libsetup include; ifconfig is run outside vnode setup. # After libsetup include; ifconfig is run outside vnode setup.
my $TMIFC = CONFDIR() . "/rc.ifc"; my $TMIFC = CONFDIR() . "/rc.ifc";
my $TMIFMAP = CONFDIR() . "/ifmap";
# Execute the action. # Execute the action.
SWITCH: for ($action) { SWITCH: for ($action) {
...@@ -106,6 +107,7 @@ sub doboot() ...@@ -106,6 +107,7 @@ sub doboot()
my $upcmds = ""; my $upcmds = "";
my $downcmds = ""; my $downcmds = "";
my @ifacelist = (); my @ifacelist = ();
my @ifacemap = ();
print STDOUT "Checking Testbed interface configuration ... \n"; print STDOUT "Checking Testbed interface configuration ... \n";
...@@ -165,6 +167,10 @@ sub doboot() ...@@ -165,6 +167,10 @@ sub doboot()
$upcmds .= TMROUTECONFIG . " $alias up\n "; $upcmds .= TMROUTECONFIG . " $alias up\n ";
$downcmds .= TMROUTECONFIG . " $alias down\n "; $downcmds .= TMROUTECONFIG . " $alias down\n ";
} }
# Trivially parsable map for users, which associate an IP
# with a local interface.
push(@ifacemap, "$iface $inet $mac");
} }
else { else {
my $inet = $ifconfig->{IPADDR}; my $inet = $ifconfig->{IPADDR};
...@@ -210,6 +216,17 @@ sub doboot() ...@@ -210,6 +216,17 @@ sub doboot()
if (defined($downline)); if (defined($downline));
} }
} }
#
# The map file.
#
unlink $TMIFMAP;
if (open(IFMAP, ">$TMIFMAP")) {
foreach my $iface (@ifacemap) {
print IFMAP "$iface\n";
}
close(IFMAP);
}
# #
# Local file into which we write ifconfig commands (as a shell script). # Local file into which we write ifconfig commands (as a shell script).
...@@ -270,4 +287,5 @@ sub doreconfig() ...@@ -270,4 +287,5 @@ sub doreconfig()
sub docleanup() sub docleanup()
{ {
unlink $TMIFC; unlink $TMIFC;
unlink $TMIFMAP;
} }
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