From 8db75899e30f3c766b41ce4d2721d542a1aef7fa Mon Sep 17 00:00:00 2001 From: Leigh B Stoller Date: Thu, 27 Feb 2014 09:07:29 -0700 Subject: [PATCH] Brutal hack for Nick, to pass a nomac_learning directive through to the XEN backend. Not worth describing, its terrible. --- clientside/tmcc/common/libsetup.pm | 67 +++++++++++++++++++++-- clientside/tmcc/common/mkvnode.pl | 6 ++ clientside/tmcc/linux/xen/libvnode_xen.pm | 6 +- protogeni/lib/GeniCM.pm.in | 16 ++++-- 4 files changed, 81 insertions(+), 14 deletions(-) diff --git a/clientside/tmcc/common/libsetup.pm b/clientside/tmcc/common/libsetup.pm index 7f803c2ce..cf6e6563d 100644 --- a/clientside/tmcc/common/libsetup.pm +++ b/clientside/tmcc/common/libsetup.pm @@ -1,7 +1,7 @@ #!/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. diff --git a/clientside/tmcc/common/mkvnode.pl b/clientside/tmcc/common/mkvnode.pl index 774d0bb52..323d91083 100755 --- a/clientside/tmcc/common/mkvnode.pl +++ b/clientside/tmcc/common/mkvnode.pl @@ -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); diff --git a/clientside/tmcc/linux/xen/libvnode_xen.pm b/clientside/tmcc/linux/xen/libvnode_xen.pm index 7cc6a38b6..613fc1504 100644 --- a/clientside/tmcc/linux/xen/libvnode_xen.pm +++ b/clientside/tmcc/linux/xen/libvnode_xen.pm @@ -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; diff --git a/protogeni/lib/GeniCM.pm.in b/protogeni/lib/GeniCM.pm.in index 08a23fdeb..624ff0cdc 100644 --- a/protogeni/lib/GeniCM.pm.in +++ b/protogeni/lib/GeniCM.pm.in @@ -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'} }); + } } # -- GitLab