Commit 5f72d9ee authored by Leigh B Stoller's avatar Leigh B Stoller

Add support for a <emulab:skipvlans /> rspec directive.

parent 21eaeb31
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# Copyright (c) 2009-2014, 2016 University of Utah and the Flux Group. # Copyright (c) 2009-2018 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -140,7 +140,8 @@ my $debug = 0; ...@@ -140,7 +140,8 @@ my $debug = 0;
"delay_capacity" => 1, "delay_capacity" => 1,
"dpdb" => 1, "dpdb" => 1,
"nonfsmounts" => 1, "nonfsmounts" => 1,
"nfsmounts" => 1); "nfsmounts" => 1,
"skipvlans" => 1);
# #
# Grab the virtual topo for an experiment. # Grab the virtual topo for an experiment.
......
...@@ -1311,59 +1311,63 @@ sub ActionStart($$;$) ...@@ -1311,59 +1311,63 @@ sub ActionStart($$;$)
# We want to let snmpit run in parallel with os_setup, like the # We want to let snmpit run in parallel with os_setup, like the
# classic path does. # classic path does.
# #
my $snmpit_child = fork(); my $snmpit_child;
if ($snmpit_child) {
# if (!$experiment->skipvlans()) {
# Parent just continues on, but will wait later, we cannot $snmpit_child = fork();
# return to the caller until snmpit is done. if ($snmpit_child) {
# #
print STDERR "Forked off snmpit: process $snmpit_child\n"; # Parent just continues on, but will wait later, we cannot
} # return to the caller until snmpit is done.
else { #
EventFork(); print STDERR "Forked off snmpit: process $snmpit_child\n";
my $msg;
DebugTimeStamp("snmpit started");
if ($flags & $ACTION_FLAGS_SYNCVLANS) {
if (Lan->CompareVlansWithSwitches2($experiment)) {
$msg .= "CompareVlansWithSwitches2 failed!\n";
goto badsnmpit;
}
system("$SNMPIT -X $pid $eid");
if ($?) {
$msg .= "Failed to synchronize vlans";
goto badsnmpit;
}
} }
else { else {
my @diff = (); EventFork();
my @same = (); my $msg;
if (Lan->CompareVlansWithSwitches($experiment, \@diff, \@same)) { DebugTimeStamp("snmpit started");
print STDERR "CompareVlansWithSwitches failed!\n"; if ($flags & $ACTION_FLAGS_SYNCVLANS) {
goto badsnmpit; if (Lan->CompareVlansWithSwitches2($experiment)) {
} $msg .= "CompareVlansWithSwitches2 failed!\n";
if (@diff) { goto badsnmpit;
system("$SNMPIT -f ". join(" ", map("-o $_", @diff))); }
system("$SNMPIT -X $pid $eid");
if ($?) { if ($?) {
$msg .= "Failed to remove obsolete VLANs."; $msg .= "Failed to synchronize vlans";
goto badsnmpit; goto badsnmpit;
} }
} }
system("$SNMPIT -t $pid $eid"); else {
if ($?) { my @diff = ();
$msg .= "Failed to setup vlans"; my @same = ();
goto badsnmpit;
if (Lan->CompareVlansWithSwitches($experiment, \@diff,\@same)) {
print STDERR "CompareVlansWithSwitches failed!\n";
goto badsnmpit;
}
if (@diff) {
system("$SNMPIT -f ". join(" ", map("-o $_", @diff)));
if ($?) {
$msg .= "Failed to remove obsolete VLANs.";
goto badsnmpit;
}
}
system("$SNMPIT -t $pid $eid");
if ($?) {
$msg .= "Failed to setup vlans";
goto badsnmpit;
}
} }
DebugTimeStamp("snmpit finished");
# Avoid END block processing
POSIX::_exit(0);
badsnmpit:
print STDERR "Failed to setup vlans: $msg\n";
# Avoid END block processing
POSIX::_exit(-1);
} }
DebugTimeStamp("snmpit finished");
# Avoid END block processing
POSIX::_exit(0);
badsnmpit:
print STDERR "Failed to setup vlans: $msg\n";
# Avoid END block processing
POSIX::_exit(-1);
} }
my @nodes = keys(%nodes); my @nodes = keys(%nodes);
......
...@@ -876,6 +876,13 @@ sub GetTicketAuxAux($) ...@@ -876,6 +876,13 @@ sub GetTicketAuxAux($)
# #
my $disablerootkeys = GeniXML::DisableRootKey($rspec); my $disablerootkeys = GeniXML::DisableRootKey($rspec);
#
# Allow caller to turn off vlan creation.
#
if (GeniXML::SkipVlans($rspec)) {
$virtexperiment->skipvlans(1);
}
# #
# User can turn off routing. # User can turn off routing.
# #
......
...@@ -791,6 +791,17 @@ sub DisableRootKey($) ...@@ -791,6 +791,17 @@ sub DisableRootKey($)
return 1; return 1;
} }
sub SkipVlans($)
{
my ($rspec) = @_;
my $tmp = GeniXML::FindNodesNS("n:skipvlans", $rspec, $EMULAB_NS)->pop();
return 1
if (defined($tmp));
return 0;
}
sub GetTarball($) sub GetTarball($)
{ {
my ($node) = @_; my ($node) = @_;
......
...@@ -992,6 +992,7 @@ REPLACE INTO table_regex VALUES ('experiments','ipassign_args','text','regex','^ ...@@ -992,6 +992,7 @@ REPLACE INTO table_regex VALUES ('experiments','ipassign_args','text','regex','^
REPLACE INTO table_regex VALUES ('experiments','expt_name','text','redirect','default:fulltext',1,255,NULL); REPLACE INTO table_regex VALUES ('experiments','expt_name','text','redirect','default:fulltext',1,255,NULL);
REPLACE INTO table_regex VALUES ('experiments','dpdb','int','redirect','default:tinyint',0,1,NULL); REPLACE INTO table_regex VALUES ('experiments','dpdb','int','redirect','default:tinyint',0,1,NULL);
REPLACE INTO table_regex VALUES ('experiments','nonfsmounts','int','redirect','default:tinyint',0,1,NULL); REPLACE INTO table_regex VALUES ('experiments','nonfsmounts','int','redirect','default:tinyint',0,1,NULL);
REPLACE INTO table_regex VALUES ('experiments','skipvlans','int','redirect','default:tinyint',0,1,NULL);
REPLACE INTO table_regex VALUES ('experiments','nfsmounts','text','regex','^(emulabdefault|genidefault|all|none)$',0,0,NULL); REPLACE INTO table_regex VALUES ('experiments','nfsmounts','text','regex','^(emulabdefault|genidefault|all|none)$',0,0,NULL);
REPLACE INTO table_regex VALUES ('experiments','packing_strategy','text','regex','^(pack|balance)$',0,0,NULL); REPLACE INTO table_regex VALUES ('experiments','packing_strategy','text','regex','^(pack|balance)$',0,0,NULL);
......
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('experiments','skipvlans','int','redirect',".
"'default:boolean',0,1,NULL)");
return 0;
}
# Local Variables:
# mode:perl
# End:
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