Commit d28c8475 authored by Srikanth Raju's avatar Srikanth Raju Committed by Leigh B Stoller
Browse files

Set up redirection for meta server

parent 91b013e4
......@@ -164,6 +164,24 @@ if (! -e "/var/run/mkvnode.ready") {
#
my @nodetypes = ( GENVNODETYPE() );
#
# Need the domain, but no conistent way to do it. Ask tmcc for the
# boss node and parse out the domain.
#
my ($DOMAINNAME,$BOSSIP) = tmccbossinfo();
die("Could not get bossname from tmcc!")
if (!defined($DOMAINNAME));
if ($DOMAINNAME =~ /^[-\w]+\.(.*)$/) {
$DOMAINNAME = $1;
}
else {
die("Could not parse domain name!");
}
if ($BOSSIP !~ /^\d+\.\d+\.\d+\.\d+$/) {
die "Bad bossip '$BOSSIP' from bossinfo!";
}
#
# We go through this crap so that we can pull in multiple packages implementing
# the libvnode API so they (hopefully) won't step on our namespace too much.
......@@ -190,7 +208,7 @@ foreach my $type (@nodetypes) {
# need to do this for each type encountered.
TBDebugTimeStampWithDate("starting $type rootPreConfig()");
$libops{$type}{'rootPreConfig'}->();
$libops{$type}{'rootPreConfig'}->($BOSSIP);
TBDebugTimeStampWithDate("finished $type rootPreConfig()");
}
if ($debug) {
......@@ -198,23 +216,6 @@ if ($debug) {
print "libops:\n" . Dumper(%libops);
}
#
# Need the domain, but no conistent way to do it. Ask tmcc for the
# boss node and parse out the domain.
#
my ($DOMAINNAME,$BOSSIP) = tmccbossinfo();
die("Could not get bossname from tmcc!")
if (!defined($DOMAINNAME));
if ($DOMAINNAME =~ /^[-\w]+\.(.*)$/) {
$DOMAINNAME = $1;
}
else {
die("Could not parse domain name!");
}
if ($BOSSIP !~ /^\d+\.\d+\.\d+\.\d+$/) {
die "Bad bossip '$BOSSIP' from bossinfo!";
}
#
# This holds the container state set up by the library. There is state
......
......@@ -111,6 +111,7 @@ my $BRCTL = "brctl";
my $IFCONFIG = "/sbin/ifconfig";
my $ETHTOOL = "/sbin/ethtool";
my $ROUTE = "/sbin/route";
my $IP = "/sbin/ip";
my $SYSCTL = "/sbin/sysctl";
my $VLANCONFIG = "/sbin/vconfig";
my $MODPROBE = "/sbin/modprobe";
......@@ -287,8 +288,9 @@ sub setDebug($)
# Called on each vnode, but should only be executed once per boot.
# We use a file in /var/run (cleared on reboots) to ensure this.
#
sub rootPreConfig()
sub rootPreConfig($)
{
my $bossip = shift;
#
# Haven't been called yet, grab the lock and double check that someone
# didn't do it while we were waiting.
......@@ -466,6 +468,12 @@ sub rootPreConfig()
if ($debug);
createDHCP();
# Set up for metadata server for ec2 support
print "Setting up redirection for meta server...\n";
mysystem("$IP addr add 169.254.169.254/32 scope global dev $cnet_iface");
mysystem("$IPTABLES -t nat -A PREROUTING -d 169.254.169.254/32 -p tcp " .
"-m tcp --dport 80 -j DNAT --to-destination " . $bossip . ":8787");
print "Creating scratch FS ...\n";
if (createExtraFS($EXTRAFS, $VGNAME, "50G")) {
TBScriptUnlock();
......
Supports Markdown
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