Commit 8db75899 authored by Leigh B Stoller's avatar Leigh B Stoller

Brutal hack for Nick, to pass a nomac_learning directive through

to the XEN backend. Not worth describing, its terrible.
parent 272550cb
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -42,7 +42,7 @@ use Exporter;
getlinkdelayconfig getloadinfo getbootwhat getnodeattributes
copyfilefromnfs getnodeuuid getarpinfo getstorageconfig
getmanifest fetchmanifestblobs runbootscript runhooks
build_fake_macs
build_fake_macs getenvvars
TBDebugTimeStamp TBDebugTimeStampWithDate
TBDebugTimeStampsOn TBDebugTimeStampsOff
......@@ -1800,13 +1800,38 @@ sub calcroutes ($)
# Gather up all the link info from the topomap
my %lans = ();
my $nnodes = 0;
my %noroute = ();
#
# Prepass the lans section to see which lans are not routed.
#
foreach my $lanref (@{ $topomap->{"lans"} }) {
#
# look for no-route flag. They are in the topomap cause of
# hostnames generation, but we do not want to run them through
# the route calculator. Shared vlans are the only current
# usage case.
#
if (exists($lanref->{"noroute"}) && $lanref->{"noroute"}) {
$noroute{$lanref->{"vname"}} = 1;
}
}
# The nodes section tells us the name of each node, and all its links.
foreach my $noderef (@{ $topomap->{"nodes"} }) {
my $vname = $noderef->{"vname"};
my $links = $noderef->{"links"};
my @links = ();
# Cull out non routable networks.
if (defined($noderef->{"links"})) {
foreach my $link (split(" ", $noderef->{"links"})) {
my ($lan,$ip) = split(":", $link);
push(@links, $link)
if (! exists($noroute{$lan}));
}
}
if (!defined($links)) {
if (!@links) {
# If we have no links, there are no routes to compute.
if ($vname eq $myname) {
@$rptr = ();
......@@ -1816,7 +1841,7 @@ sub calcroutes ($)
}
# Links is a string of "$lan1:$ip1 $lan2:$ip2 ..."
foreach my $link (split(" ", $links)) {
foreach my $link (@links) {
my ($lan,$ip) = split(":", $link);
if (! defined($lans{$lan})) {
......@@ -3237,6 +3262,38 @@ sub getnodeattributes($)
return 0;
}
#
# Return the environment variables in a key/value array.
#
sub getenvvars($)
{
my ($rptr) = @_;
my @tmccresults = ();
my %result = ();
my $issharedhost = SHAREDHOST();
my %tmccopts = ();
if ($issharedhost) {
$tmccopts{"nocache"} = 1;
}
if (tmcc(TMCCCMD_USERENV, undef, \@tmccresults, %tmccopts) < 0) {
warn("*** WARNING: Could not get environment vars from server!\n");
%$rptr = ();
return -1;
}
foreach my $line (@tmccresults) {
if ($line =~ /^(.*)="(.*)"$/ ||
$line =~ /^(.*)=(.+)$/) {
$result{$1} = $2;
}
}
%$rptr = %result;
return 0;
}
#
# Return the hostname or IP to use for a local event server.
# Defaults to "localhost" for most nodes or the physical host IP for Xen VMs.
......
......@@ -299,6 +299,7 @@ my %vnconfig = ( "vnodeid" => $vnodeid,
"ldconfig" => undef,
"tunconfig" => undef,
"attributes"=> undef,
"environment" => undef,
"storageconfig" => undef,
);
sub VNCONFIG($) { return $vnconfig{'config'}->{$_[0]}; }
......@@ -332,6 +333,7 @@ my %tmp;
my @tmp;
my $tmp;
my %attrs;
my %envvars;
fatal("Could not get vnode config for $vnodeid")
if (getgenvnodeconfig(\%tmp));
......@@ -357,6 +359,10 @@ fatal("getstorageconfig($vnodeid): $!")
if (getstorageconfig(\@tmp));
$vnconfig{"storageconfig"} = [ @tmp ];
fatal("getenvvars(): $!")
if (getenvvars(\%envvars));
$vnconfig{"environment"} = \%envvars;
if ($debug) {
print "VN Config:\n";
print Dumper(\%vnconfig);
......
......@@ -1516,9 +1516,9 @@ sub vnodePreConfigExpNetwork($$$$)
};
# Prototyping hack for Nick.
if (exists($interface->{'SETTINGS'}) &&
exists($interface->{'SETTINGS'}->{'nomac_learning'}) &&
$interface->{'SETTINGS'}->{'nomac_learning'}) {
my $envvar = $interface->{"LAN"} . "_nomac_learning";
if (exists($vnconfig->{'environment'}->{$envvar}) &&
$vnconfig->{'environment'}->{$envvar}) {
$link->{'nomac_learning'} = 1;
}
push @links, $link;
......
......@@ -1713,14 +1713,18 @@ sub GetTicketAuxAux($$$$$$$$$$)
}
#
# Look for general link attributes that pass through to the
# backend.
# Look for general link attributes. We cannot use the
# virt_lan_settings here, we do not pass them through for
# regular lans. That needs to be fixed. At the moment,
# I just need this for Nick zero aging stuff, so make it
# an environment variable instead. Yuck.
#
foreach my $attr_ref (GeniXML::GetLinkAttributes($linkref)) {
$virtexperiment->NewTableRow("virt_lan_settings",
{"vname" => $lanname,
"capkey" => $attr_ref->{'key'},
"capval" => $attr_ref->{'value'} });
if ($attr_ref->{'key'} eq "nomac_learning") {
$virtexperiment->NewTableRow("virt_user_environment",
{"name" => $lanname . "_" . "nomac_learning",
"value" => $attr_ref->{'value'} });
}
}
#
......
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