Commit 10622aed authored by Tom Mitchell's avatar Tom Mitchell
Browse files

Merge branch 'master' into geni-am-devel

parents e862fc46 c16ced23
......@@ -442,17 +442,17 @@ void print_help() {
<< endl;
cout << " -u - Print a summary of the solution." << endl;
cout << " -c <float> - Use the 'connected' pnode finding algorithm ";
cout << "<float>*100%" << endl;
cout << " of the time." << endl;
cout << "<float>*100%" << endl;
cout << " of the time." << endl;
cout << " -n - Don't anneal - just do the prechecks." << endl;
cout << " -x <file> - Specify a text ptop file" << endl;
cout << " -y <file> - Specify a text top file" << endl;
#ifdef WITH_XML
cout << " -W <file> - Specify the output rspec file" << endl;
cout << " -f <T>[/<T>] - Specify the ptop/vtop file formats " << endl;
cout << " T should be one of (text|xml|rspec-<rspec ver. number>)" << endl;;
cout << " Specifying only one T is equivalent to -f T/T"<<endl;
cout << " -f <T>[/<T>] - Specify the ptop/vtop file formats " << endl;
cout << " T should be one of (text|xml|rspec)" << endl;
cout << " Specifying only one T is equivalent to -f T/T"<<endl;
#endif
cout << " -F - Apply additional checking to fixed nodes" << endl;
cout << " -D - Dump configuration options" << endl;
......@@ -946,6 +946,14 @@ int main(int argc,char **argv) {
break;
#ifdef WITH_XML
case 'W':
if (strcmp(optarg, "") == 0) {
print_help();
}
vtopOutputFilename = optarg;
break;
case 'f':
if (strcmp(optarg, "") == 0) {
print_help();
......@@ -1253,4 +1261,3 @@ int main(int argc,char **argv) {
exit(EXIT_SUCCESS);
}
}
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -409,6 +409,11 @@ sub CheckPassword($$$$$)
my ($prefix, $uid, $password, $name, $email) = @_;
my $checkpass_args = escapeshellarg($password)
. " " . $uid . " " . escapeshellarg($name . ":" . $email);
# Make taint check happy.
if ($checkpass_args =~ /^(.*)$/) {
$checkpass_args = $1;
}
my $pwokay = `$checkpass $checkpass_args`;
if ($?) {
chomp($pwokay);
......
......@@ -177,7 +177,7 @@ my ($dev,$ino,$mode,$nlink,undef,undef,$rdev,$size,
my $if_mod_since = 0;
$if_mod_since = str2time($ENV{HTTP_IF_MODIFIED_SINCE})
if defined $ENV{HTTP_IF_MODIFIED_SINCE};
if ($if_mod_since > 0 && $if_mod_since <= $mtime) {
if ($mtime <= $if_mod_since) {
print "Status: 304 Not Modified\n\n";
} else {
print "Content-Type: $mime_type\n" if defined $mime_type;
......
......@@ -2735,6 +2735,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
dhcpd/dhcpd.conf.template dhcpd/GNUmakefile \
dhcpd/dhcpd.conf.subboss.template \
install/GNUmakefile \
install/libinstall.pm install/update-install install/update-testbed \
install/ops-install install/boss-install install/fs-install \
install/load-descriptors install/dump-descriptors \
install/newnode_sshkeys/GNUmakefile install/smb.conf.head \
......
......@@ -984,6 +984,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
install/load-descriptors install/dump-descriptors \
install/newnode_sshkeys/GNUmakefile install/smb.conf.head \
install/clrhouse-install \
install/libinstall.pm install/update-install install/update-testbed \
mote/GNUmakefile mote/tbuisp mote/tbsgmotepower mote/newmote \
mote/sgtools/GNUmakefile \
robots/GNUmakefile robots/tbsetdest/GNUmakefile \
......
......@@ -99,6 +99,7 @@ my $EXPT_RESOURCESHOSED = 0;
"virt_simnode_attributes",
"virt_user_environment",
"virt_parameters",
"virt_paths",
# vis_nodes is locked during update in prerender, so we
# will get a consistent dataset when we backup.
"vis_nodes",
......
......@@ -52,14 +52,14 @@ TARGETS = emdb.pm emutil.pm emdbi.pm
SETUID_SBIN_SCRIPTS =
endif
$(SUBBOSS_BIN_SCRIPTS):
#
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all: $(TARGETS)
$(SUBBOSS_BIN_SCRIPTS):
include $(TESTBED_SRCDIR)/GNUmakerules
ifeq ($(STANDALONE_CLEARINGHOUSE),0)
......
......@@ -48,6 +48,93 @@ my %LanTables = ("lans" => ["lanid"],
"lan_member_attributes" => ["lanid", "memberid", "attrkey"],
"ifaces" => ["lanid", "ifaceid"]);
#
# Initialize Openflow attributes in lan_attributes table.
#
sub InitOpenflowAttributes($$$)
{
my ($exptidx, $vname, $lanid) = @_;
my $ofenabled = 0;
my $ofcontroller = "";
my $safe_val;
# Add openflow arrtibutes:
my $query_result =
DBQueryWarn("select ofenabled, ofcontroller from virt_lans ".
"where exptidx='$exptidx' and vname='$vname'");
return 0
if (!$query_result);
($ofenabled, $ofcontroller) = $query_result->fetchrow_array()
if ($query_result->numrows);
#
# Firstly check if the attribuets are there, if no values,
# insert them. This is because the vlan may be created
# by Lookup many times. The values can be overwritten by
# the later creation.
#
# Process 'ofenabled':
$query_result =
DBQueryWarn("select attrvalue from lan_attributes ".
"where lanid='$lanid' and attrkey='ofenabled'");
return 0
if (!$query_result);
if (!$query_result->numrows)
{
$safe_val = DBQuoteSpecial($ofenabled);
$query_result =
DBQueryWarn("replace into lan_attributes set ".
" lanid='$lanid', ".
" attrkey='ofenabled', ".
" attrvalue=$safe_val, ".
" attrtype='integer'");
return 0
if (!defined($query_result));
}
# Process 'ofcontroller':
$query_result =
DBQueryWarn("select attrvalue from lan_attributes ".
"where lanid='$lanid' and attrkey='ofcontroller'");
return 0
if (!$query_result);
if (!$query_result->numrows)
{
$safe_val = DBQuoteSpecial($ofcontroller);
$query_result =
DBQueryWarn("replace into lan_attributes set ".
" lanid='$lanid', ".
" attrkey='ofcontroller', ".
" attrvalue=$safe_val, ".
" attrtype='string'");
return 0
if (!defined($query_result));
}
# Process 'oflistener':
$query_result =
DBQueryWarn("select attrvalue from lan_attributes ".
"where lanid='$lanid' and attrkey='oflistener'");
return 0
if (!$query_result);
if (!$query_result->numrows)
{
$safe_val = DBQuoteSpecial("");
$query_result =
DBQueryWarn("replace into lan_attributes set ".
" lanid='$lanid', ".
" attrkey='oflistener', ".
" attrvalue=$safe_val, ".
" attrtype='string'");
return 0
if (!defined($query_result));
}
return 1;
}
#
# Lookup and create a class instance to return.
#
......@@ -107,6 +194,9 @@ sub Lookup($$;$$)
$self->{"ATTRS"} = {};
$self->{"EXPT"} = $experiment;
return undef
if (!Lan->InitOpenflowAttributes($self->{'LAN'}->{'exptidx'}, $self->{'LAN'}->{'vname'}, $lanid));
#
# Grab the attributes for this lan now.
#
......@@ -188,7 +278,7 @@ sub Create($$$;$$$)
# Need the newly minted ID
my $lanid = $query_result->insertid();
my $lan = Lan->Lookup($lanid);
print "Created lan: $lan\n"
if ($debug && $lan);
return $lan;
......
......@@ -72,6 +72,7 @@ my $debug = 0;
"elabinelab_attributes" => [ "role", "attrkey", "ordering" ],
"virt_tiptunnels" => [ "host", "vnode" ],
"virt_parameters" => [ "name", "value" ],
"virt_paths" => [ "pathname", "segmentname"],
);
#
......@@ -1184,5 +1185,10 @@ use vars qw(@ISA);
@ISA = "VirtExperiment::VirtTableRow";
use VirtExperiment;
package VirtExperiment::VirtTableRow::virt_paths;
use vars qw(@ISA);
@ISA = "VirtExperiment::VirtTableRow";
use VirtExperiment;
# _Always_ make sure that this 1 is at the end of the file...
1;
......@@ -108,6 +108,9 @@ if (@ARGV) {
if (defined($options{"d"})) {
$debug++;
}
if (defined($options{"f"})) {
$force = 1;
}
if (defined($options{"a"})) {
$all = 1;
}
......
......@@ -31,6 +31,7 @@ use Lan;
use GeniEmulab;
use GeniResource;
use GeniResponse;
use GeniXML;
use English;
use Socket;
use XML::Simple;
......@@ -103,7 +104,12 @@ sub MapResources($$$$)
$fragments{$cm} = {
'generated_by' => 'libvtop',
'type' => 'request',
'xmlns' => 'http://www.protogeni.net/resources/rspec/0.1',
'xmlns' => 'http://www.protogeni.net/resources/rspec/0.2',
# Assign now wants this stuff. I have no clue what it means!
'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
'xsi:schemaLocation' =>
"http://www.protogeni.net/resources/rspec/0.2 ".
"http://www.protogeni.net/resources/rspec/0.2/request.xsd",
'node' => [] };
}
push(@{ $fragments{$cm}->{'node'} }, $copy);
......@@ -204,7 +210,7 @@ sub MapResources($$$$)
$ptopfh->close();
system("nice $ASSIGN -uod -c .75 ".
"-q $ptop -w $vtop -W $soln > $log 2>&1");
"-f rspec/rspec -W $soln $ptop $vtop > $log 2>&1");
if ($?) {
print STDERR "Could not map to physical resources on $resource\n";
......@@ -284,13 +290,20 @@ sub MapResources($$$$)
if ($verbose) {
print STDERR "Final rspec:\n";
print STDERR Dumper($rspec);
if (1) {
my $rspecdoc = GeniResource::ConvertRspec($rspec);
my $rspecstr = GeniXML::Serialize($rspecdoc);
print STDERR "In XML:\n";
print STDERR "$rspecstr\n";
}
}
return 0;
}
sub GetTickets($$$$)
{
my ($experiment, $impotent, $user, $rspec) = @_;
my ($experiment, $verbose, $user, $rspec) = @_;
my %cm_urns = ();
Register($experiment, $user) == 0
......@@ -335,6 +348,17 @@ sub GetTickets($$$$)
$cm_urns{$cm} = $resource;
}
#
# XXX Convert to a proper XML looking thing. This is just a temporay
# hack for now.
#
my $rspecdoc = GeniResource::ConvertRspec($rspec);
my $rspecstr = GeniXML::Serialize($rspecdoc);
if ($verbose) {
print STDERR "In XML:\n";
print STDERR "$rspecstr\n";
}
#
# Get Tickets in parallel.
#
......@@ -344,7 +368,7 @@ sub GetTickets($$$$)
my ($resource) = @_;
print STDERR "Asking for ticket from $resource\n";
if ($resource->GetTicket($user, $rspec, $impotent)) {
if ($resource->GetTicket($user, $rspecstr, 0)) {
#
# Print this here since we do not save this in the
# DB, and the parent side of the fork will not have
......@@ -428,7 +452,7 @@ sub RedeemTickets($$$)
};
print STDERR "Redeeming all tickets in parallel ...\n";
if (ParRun(undef, \@results, $coderef, @resources)) {
if (ParRun({'maxwaittime' => 300}, \@results, $coderef, @resources)) {
print STDERR "*** RedeemTickets: Internal error getting tickets\n";
#
# Need to be careful here; some of the tickets might have been
......@@ -487,21 +511,29 @@ sub MapNodes($$)
my $manifest = $resource->Manifest();
return -1
if (!defined($manifest));
my $manifest_string = $resource->manifest_string();
print STDERR Dumper($manifest)
print STDERR "$manifest_string\n"
if ($verbose);
foreach my $ref (@{ $manifest->{'node'} }) {
my $sliver_urn = $ref->{'sliver_urn'};
my $vname = $ref->{'virtual_id'};
foreach my $ref (GeniXML::FindNodes("n:node",
$manifest)->get_nodelist()) {
my $sliver_urn = GeniXML::GetText("sliver_urn", $ref);
my $vname = GeniXML::GetVirtualId($ref);
my $sshdport = GeniXML::GetText("sshdport", $ref);
my $manager_urn= GeniXML::GetText("component_manager_urn", $ref);
#
# The manifest can include nodes from other CMs. There will not
# be a sliver urn in that case.
#
my $component_manager_urn = $ref->{'component_manager_urn'};
next
if (!defined($sliver_urn) && !defined($component_manager_urn));
if (!defined($sliver_urn));
# Hmm, still need to check this.
next
if (!defined($manager_urn) ||
$manager_urn ne $resource->manager_urn());
my $node = $experiment->VnameToNode($vname);
if (!defined($node)) {
......@@ -515,9 +547,7 @@ sub MapNodes($$)
$sliver_urn})
== 0 or return -1;
if (exists($ref->{'sshdport'})) {
my $sshdport = $ref->{'sshdport'};
if (defined($sshdport)) {
$node->Update({'sshdport' => $sshdport});
}
#
......@@ -527,29 +557,38 @@ sub MapNodes($$)
"-s $BOSSNODE -k $eventkey,$keyhash -u '$sliver_urn'";
$cmd .= " -j " . $node->node_id()
if ($node->isvirtnode());
$ref->{'startup_command'} = "$cmd boot";
GeniXML::SetText("startup_command", $ref, "$cmd boot");
# Interface map for loop below.
if (exists($ref->{'interface'})) {
foreach my $ifaceref (@{ $ref->{'interface'} }) {
my $virtid = $ifaceref->{'virtual_id'};
my $compid = $ifaceref->{'component_id'};
if (defined(GeniXML::FindFirst("n:interface", $ref))) {
foreach my $ifaceref (GeniXML::FindNodes("n:interface",
$ref)->get_nodelist()) {
my $virtid = GeniXML::GetText("virtual_id", $ifaceref);
my $compid = GeniXML::GetText("component_id", $ifaceref);
$ifacemap{$virtid} = [$node, $compid];
}
}
}
foreach my $ref (@{ $manifest->{'link'} }) {
my $linkname = $ref->{"virtual_id"};
my $interfaces = $ref->{'interface_ref'};
my %managers = map { $_->{'id'} => $_->{'id'} }
@{ $ref->{'component_manager'} };
foreach my $ref (GeniXML::FindNodes("n:link",
$manifest)->get_nodelist()) {
my $linkname = GeniXML::GetVirtualId($ref);
my $link_type = GeniXML::GetText("link_type", $ref);
my $vlantag = GeniXML::GetText("vlantag", $ref);
my @ifacerefs = GeniXML::FindNodes("n:interface_ref",
$ref)->get_nodelist();
my %managers = ();
if (GeniXML::FindNodes("n:component_manager", $ref)) {
%managers = map { GeniXML::GetText("id", $_) => $_ }
GeniXML::FindNodes("n:component_manager",
$ref)->get_nodelist();
}
# Skip tunnels in this loop for now.
next
if (exists($ref->{'link_type'}) &&
$ref->{'link_type'} eq "tunnel");
if (defined($link_type) && $link_type eq "tunnel");
#
# The manifest can include links for other CMs. Skip those
......@@ -558,13 +597,13 @@ sub MapNodes($$)
next
if (!exists($managers{$resource->manager_urn()}));
if (exists($ref->{'vlantag'})) {
my $TAG = $ref->{'vlantag'};
if (defined($vlantag)) {
my $TAG = $vlantag;
if (defined($TAG)) {
if (!($TAG =~ /^[\w]*$/)) {
print STDERR "Bad vlantag '$TAG' for $linkname\n";
print STDERR Dumper($manifest);
print STDERR "$manifest_string\n";
return -1;
}
my $lan = Lan->Lookup($experiment, $linkname, 1);
......@@ -590,11 +629,12 @@ sub MapNodes($$)
}
}
foreach my $ifaceref (@{ $interfaces }) {
my $vname = $ifaceref->{'virtual_node_id'};
my $iface_id = $ifaceref->{'virtual_interface_id'};
my $MAC = $ifaceref->{'MAC'};
my $VMAC = $ifaceref->{'VMAC'};
foreach my $ifaceref (@ifacerefs) {
my $vname = GeniXML::GetText("virtual_node_id", $ifaceref);
my $iface_id = GeniXML::GetText("virtual_interface_id",
$ifaceref);
my $MAC = GeniXML::GetText("MAC", $ifaceref);
my $VMAC = GeniXML::GetText("VMAC", $ifaceref);
my ($node, $compid) = @{ $ifacemap{$iface_id} };
my $iface;
......@@ -607,7 +647,7 @@ sub MapNodes($$)
if (!defined($iface)) {
print STDERR "Could not determine iface for" .
"$vname,$iface_id\n";
print STDERR Dumper($manifest);
print STDERR "$manifest_string\n";
return -1;
}
#
......@@ -619,7 +659,7 @@ sub MapNodes($$)
my $pnode = $node->GetPhysHost();
if (!defined($pnode)) {
print STDERR "Could not physical node for $node\n";
print STDERR Dumper($manifest);
print STDERR "$manifest_string\n";
return -1;
}
$node = $pnode;
......@@ -628,22 +668,22 @@ sub MapNodes($$)
my $interface = Interface->LookupByIface($node,$iface);
if (!defined($interface)) {
print STDERR "Could not map iface for $node,$iface\n";
print STDERR Dumper($manifest);
print STDERR "$manifest_string\n";
return -1;
}
if (!defined($MAC)) {
print STDERR "No mac (or vmac) for $node,$iface\n";
print STDERR Dumper($manifest);
print STDERR "$manifest_string\n";
return -1;
}
if (! ($MAC =~ /^[\w]*$/)) {
print STDERR "Bad mac '$MAC' for $node,$iface\n";
print STDERR Dumper($manifest);
print STDERR "$manifest_string\n";
return -1;
}
if ($interface->Update({"mac" => "$MAC"})) {
print STDERR "Could not update $node,$iface\n";
print Dumper($manifest);
print STDERR "$manifest_string\n";
return -1;
}
if (defined($VMAC)) {
......@@ -659,12 +699,12 @@ sub MapNodes($$)
}
if (! ($VMAC =~ /^[\w]*$/)) {
print STDERR "Bad vmac '$VMAC' for $linkname,$vname\n";
print STDERR Dumper($manifest);
print STDERR "$manifest_string\n";
return -1;
}
if ($vinterface->Update({"mac" => "$VMAC"})) {
print STDERR "Could not update $linkname,$vname\n";
print Dumper($manifest);
print STDERR "$manifest_string\n";
return -1;
}
}
......@@ -746,12 +786,14 @@ sub StartSlivers($$$$)
my $errors = 0;
my $count = 0;
my @tmp = ();
my @failed = ();
foreach my $result (@results) {
my $resource = $resources[$count];
if ($result != 0) {
print STDERR "*** Error starting slivers for $resource\n";
$errors++;
push(@failed, $resource);
}
else {
#
......@@ -767,6 +809,40 @@ sub StartSlivers($$$$)
}
$count++;
}
#
# Set the nodes to TBFAILED to avoid waiting in os_setup.
#
if (@failed) {
foreach my $resource (@failed) {
my $manager_urn = $resource->manager_urn();
my $ticketstr = $resource->Ticket();
my $ticket = GeniXML::Parse($ticketstr);
return -1
if (!defined($ticket));
foreach my $ref (GeniXML::FindNodes("n:node",
$ticket)->get_nodelist()) {
my $vname = GeniXML::GetVirtualId($ref);
my $this_manager_urn = GeniXML::GetManagerId($ref);
next
if (!defined($this_manager_urn) ||
$manager_urn ne $this_manager_urn);
my $node = $experiment->VnameToNode($vname);
next
if (!defined($node));
if ($node->eventstate() ne TBDB_NODESTATE_TBFAILED()) {
$node->SetEventState(TBDB_NODESTATE_TBFAILED());
}
}
}
}
# Everything failed, stop now.
return -1
if (!@tmp);
MapNodes($experiment, $verbose);
return WaitForSlivers($experiment, $user, $verbose, @tmp);
......@@ -797,16 +873,17 @@ sub WaitForSlivers($$$@)
return -1
if (!defined($manifest));
foreach my $ref (@{ $manifest->{'node'} }) {
my $vname = $ref->{'virtual_id'};
my $urn = $ref->{'component_urn'};
foreach my $ref (GeniXML::FindNodes("n:node",
$manifest)->get_nodelist()) {
my $vname = GeniXML::GetVirtualId($ref);
my $urn = GeniXML::GetNodeId($ref);
my $node = $experiment->VnameToNode($vname);
#
# The manifest can include nodes from other CMs. There will not
# be a sliver urn in that case.
#
my $sliver_urn = $ref->{'sliver_urn'};
my $sliver_urn = GeniXML::GetSliverId($ref);
next
if (!defined($sliver_urn));
......@@ -838,7 +915,9 @@ sub WaitForSlivers($$$@)
my $coderef = sub {
my ($resource) = @_;
my $ref;
my $notready = 0;
my $failed = 0;
my $ready = 0;
my $count = 0;