Commit 815f6c6f authored by Leigh B. Stoller's avatar Leigh B. Stoller

Some preliminary manifest handling. Very simple; StartSliver() accepts

an optional manifest argument. Only processing the startup command
right now, don't want to put much effort into this until we work out
how the manifest is going to be used and processed in the V2 API.
parent c404b414
......@@ -514,6 +514,33 @@ sub NewCredential($$)
return $credential;
}
#
# Process the manifest. Just hand off to the slivers.
#
sub ProcessManifest($$)
{
my ($self, $manifest) = @_;
return -1
if (! ref($self));
my @slivers = ();
if ($self->SliverList(\@slivers) != 0) {
print STDERR "Could not get sliver list for $self\n";
return -1;
}
foreach my $sliver (@slivers) {
next
if (ref($sliver) ne "GeniSliver::Node");
if ($sliver->ProcessManifest($manifest) != 0) {
return -1;
}
}
return 0;
}
#
# Start all the slivers in the aggregate. Start is special since it
# sorta means reboot, and the only thing we reboot are nodes. And,
......
......@@ -783,7 +783,7 @@ sub GetTicket($;$)
$node->node_id() : "")};
# Tarball and startup command.
if (exists($ref->{'startup_command'})) {
if (0 && exists($ref->{'startup_command'})) {
my $startupcmd = $ref->{'startup_command'};
if (! TBcheck_dbslot($startupcmd, "virt_nodes", "startupcmd",
......@@ -2122,6 +2122,7 @@ sub StartSliver($)
{
my ($argref) = @_;
my $cred = $argref->{'credential'};
my $manifest = $argref->{'manifest'};
my $impotent = $argref->{'impotent'};
$impotent = 0
......@@ -2159,6 +2160,13 @@ sub StartSliver($)
"No such sliver/aggregate $sliver_uuid");
}
}
if (defined($manifest)) {
$manifest = XMLin($manifest, KeyAttr => [],
ForceArray => ["node", "link", "interface",
"interface_ref", "linkendpoints"]);
}
#
# Lock the slice to avoid concurrent operation.
#
......@@ -2176,6 +2184,21 @@ sub StartSliver($)
return GeniResponse->Create(GENIRESPONSE_FORBIDDEN, undef,
"Slice has been shutdown");
}
if (defined($manifest)) {
print Dumper($manifest);
#
# This is not signed, so have to be very careful about using
# anything inside it.
#
if ($sliver->ProcessManifest($manifest) != 0) {
$slice->UnLock();
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Could not process manifest");
}
}
if (!$impotent && $sliver->Start() != 0) {
$slice->UnLock();
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
......
......@@ -22,7 +22,7 @@ use GeniCertificate;
use GeniAggregate;
use GeniUsage;
# Hate to import all this crap; need a utility library.
use emutil qw(TBGetUniqueIndex);
use emutil;
use Experiment;
use OSinfo;
use Node;
......@@ -503,6 +503,7 @@ use GeniCredential;
use GeniCertificate;
use GeniUtil;
use Experiment;
use emutil;
use XML::Simple;
use libdb qw(TBDB_ALLOCSTATE_RES_INIT_DIRTY TBDB_NODESTATE_SHUTDOWN
TBResolveNextOSID);
......@@ -755,6 +756,68 @@ sub UnProvision($;$)
return 0;
}
#
# Process a manifest.
#
sub ProcessManifest($$)
{
my ($self, $manifest) = @_;
return -1
if (! ref($self));
my $experiment = Experiment->Lookup($self->slice_uuid());
if (!defined($experiment)) {
print STDERR "Could not map $self to its experiment\n";
return -1;
}
my $pid = $experiment->pid();
my $eid = $experiment->eid();
my $uuid = $self->uuid();
return 0
if (!defined($uuid));
my $node = Node->Lookup($uuid);
if (!defined($node)) {
print STDERR "Could not map node $uuid to its object\n";
return -1;
}
my $reservation = $node->Reservation();
if (!defined($reservation)) {
print STDERR "$node was already released from $self\n";
return -1;
}
if ($reservation->SameExperiment($experiment)) {
#
# Find the corresponding node in the manifest.
#
foreach my $ref (@{$manifest->{'node'}}) {
if ($ref->{'sliver_uuid'} eq $uuid) {
# startup command.
if (exists($ref->{'startup_command'})) {
my $startupcmd = $ref->{'startup_command'};
if (! TBcheck_dbslot($startupcmd, "virt_nodes",
"startupcmd",
TBDB_CHECKDBSLOT_WARN|
TBDB_CHECKDBSLOT_ERROR)) {
print STDERR "Invalid startup command '$startupcmd'\n";
return -1;
}
$node->Update({"startupcmd" => $startupcmd});
}
return 0;
}
}
}
else {
print STDERR "$node is reserved to another, not $self\n";
# Signal error so we can look at what happened.
return -1;
}
return 0;
}
#
# Start a sliver, which means what?
#
......
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