From 748240a9eb8ce7a3553685cfe9bccebafc425426 Mon Sep 17 00:00:00 2001 From: "Leigh B. Stoller" Date: Sat, 12 Dec 2009 00:23:43 +0000 Subject: [PATCH] Small set of changes to make the SPP nodes work from the protogeni interface. --- protogeni/lib/GeniCM.pm.in | 19 +++++++--- protogeni/lib/GeniSA.pm.in | 73 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 4 deletions(-) diff --git a/protogeni/lib/GeniCM.pm.in b/protogeni/lib/GeniCM.pm.in index 6296ecffe..d74622e68 100644 --- a/protogeni/lib/GeniCM.pm.in +++ b/protogeni/lib/GeniCM.pm.in @@ -588,6 +588,7 @@ sub GetTicketAuxAux($$$$$$$$) } # Turn off fixnode; we will control this on the commandline. $virtexperiment->allowfixnode(0); + $virtexperiment->multiplex_factor(3); # This is where nodes are parked until a ticket is redeemed. # This experiment no longer has to exist. @@ -722,13 +723,22 @@ sub GetTicketAuxAux($$$$$$$$) if (defined($virtualization_type)) { if ($virtualization_type eq "emulab-vnode") { if (defined($virtualization_subtype)) { + $pctype = "pcvm"; + if ($virtualization_subtype eq "emulab-jail") { $osname = "FBSD-JAIL"; } elsif ($virtualization_subtype eq "emulab-openvz") { $osname = "OPENVZ-STD"; } - $pctype = "pcvm"; + elsif ($virtualization_subtype eq "emulab-spp") { + $osname = "SPPVM-FAKE"; + $pctype = "sppvm"; + # Lets force to shared node. + $ref->{'exclusive'} = $exclusive = 0; + # Kludge for libvtop. + $virtexperiment->multiplex_factor(1); + } } else { goto raw; @@ -894,6 +904,7 @@ sub GetTicketAuxAux($$$$$$$$) my $interfaces = $linkref->{'linkendpoints'} || $linkref->{'interface_ref'}; my $ifacenum = 1; + my $trivial_ok = 0; if (!defined($lanname)) { $response = GeniResponse->Create(GENIRESPONSE_BADARGS, undef, @@ -1000,7 +1011,7 @@ sub GetTicketAuxAux($$$$$$$$) {"vname" => $lanname, "vnode" => $node_nickname, "vport" => $iface_vport, - "trivial_ok" => 1, + "trivial_ok" => $trivial_ok, "ip" => $ip, "delay" => 0.0, "bandwidth" => $bandwidth, # kbps @@ -1047,7 +1058,7 @@ sub GetTicketAuxAux($$$$$$$$) "Could not verify topo"); goto bad; } - system("$MAPPER -n -d -v -m 3 -u -o $tmpfile $pid $eid"); + system("$MAPPER -n -d -v -u -o $tmpfile $pid $eid"); if ($?) { $response = GeniResponse->Create(GENIRESPONSE_ERROR, undef, @@ -1757,7 +1768,7 @@ sub SliverWorkAux($$$$$$$) goto bad; } # Add -u for update mode, but not -f (fixnode). - system("$MAPPER -d -v -u -m 3 $pid $eid"); + system("$MAPPER -d -v -u $pid $eid"); if ($?) { print STDERR "Mapper failed!\n"; # Dump the vtop. diff --git a/protogeni/lib/GeniSA.pm.in b/protogeni/lib/GeniSA.pm.in index 325c2303e..8d92f73fe 100644 --- a/protogeni/lib/GeniSA.pm.in +++ b/protogeni/lib/GeniSA.pm.in @@ -32,6 +32,9 @@ use GeniHRN; use English; use XML::Simple; use Data::Dumper; +use Date::Parse; +use POSIX qw(strftime); +use Time::Local; # Configure variables my $TB = "@prefix@"; @@ -866,6 +869,76 @@ sub Shutdown($) return GeniResponse->Create(GENIRESPONSE_SUCCESS); } +# +# Extend a slice expiration time. +# +sub RenewSlice($) +{ + my ($argref) = @_; + my $credstr = $argref->{'credential'}; + my $expires = $argref->{'valid_until'}; + my $message = "Error renewing slice"; + + if (! (defined($credstr) && defined($expires))) { + return GeniResponse->Create(GENIRESPONSE_BADARGS); + } + my $credential = GeniCredential->CreateFromSigned($credstr); + if (!defined($credential)) { + return GeniResponse->Create(GENIRESPONSE_ERROR, undef, + "Could not create GeniCredential object"); + } + + # + # Make sure the credential was issued to the caller. + # + if ($credential->owner_uuid() ne $ENV{'GENIUUID'}) { + return GeniResponse->Create(GENIRESPONSE_ERROR, undef, + "This is not your credential!"); + } + my $slice = GeniSlice->Lookup($credential->target_uuid()); + if (!defined($slice)) { + return GeniResponse->Create(GENIRESPONSE_ERROR, undef, + "Unknown slice for this credential"); + } + + $credential->HasPrivilege( "pi" ) or + $credential->HasPrivilege( "bind" ) or + return GeniResponse->Create( GENIRESPONSE_FORBIDDEN, undef, + "Insufficient privilege" ); + + # + # Figure out new expiration time; this is the time at which we can + # idleswap the slice out. + # + if (! ($expires =~ /^[-\w:.\/]+/)) { + $message = "Illegal valid_until in rspec"; + goto bad; + } + # Convert to a localtime. + my $when = timegm(strptime($expires)); + if (!defined($when)) { + $message = "Could not parse valid_until"; + goto bad; + } + # + # Do we need a policy limit? + # + my $diff = $when - time(); + + if ($diff < (60 * 5) || $diff > (3600 * 24 * 100)) { + $message = "valid_until out of range"; + goto bad; + } + if ($slice->SetExpiration($when) != 0) { + $message = "Could not set expiration time"; + goto bad; + } + return GeniResponse->Create(GENIRESPONSE_SUCCESS); + + bad: + return GeniResponse->Create(GENIRESPONSE_ERROR, undef, $message); +} + # # Register a sliver. # -- GitLab