Commit e38602a1 authored by Leigh Stoller's avatar Leigh Stoller

Remove obsolete stuff

parent 85ea76eb
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -19,8 +19,7 @@ LIB_SCRIPTS = GeniDB.pm GeniUser.pm GeniSAClient.pm \
GeniUtil.pm GeniRegistry.pm
SBIN_SCRIPTS = plabnodewrapper plabslicewrapper
SCRIPTS = test.pl addnode.pl
#OPS_LIBS = GeniCMClient.pm GeniSAClient.pm
SCRIPTS = addnode.pl
# These scripts installed setuid, with sudo.
SETUID_SBIN_SCRIPTS = plabnodewrapper plabslicewrapper
......
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2008 University of Utah and the Flux Group.
# All rights reserved.
#
package GeniCHClient;
#
# The client side of the Emulab to Geni ClearingHouse API. This is where we
# register local users, experiments, etc at the clearinghouse and also how
# we look up things at the clearinghouse.
#
use strict;
use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = "Exporter";
@EXPORT = qw ( );
# Must come after package declaration!
use lib '@prefix@/lib';
use Genixmlrpc;
use GeniResponse;
use English;
use Data::Dumper;
# Configure variables
my $GENICENTRAL = "myboss.myelab.testbed.emulab.net";
my $GENICENTRALURL = "https://$GENICENTRAL/protogeni/xmlrpc/ch";
#
# Context for making calls to the clearinghouse. Opaque to this module.
#
my $MyContext;
#
# Set the context for subsequent calls made to the clearing house.
#
sub SetContext($$)
{
my ($class, $context) = @_;
$MyContext = $context;
return 0;
}
#
# Our credential for talking to the clearinghouse. Should be cached
# but currently asking for a new one each time.
#
my $Credential;
sub SetCredential()
{
return
if (defined($Credential));
GetCredential(undef, undef, undef, \$Credential) == 0
or die("Could not get our CH credential from the clearinghouse.\n");
}
#
# Ask the clearing house for a credential.
#
sub GetCredential($$$$)
{
my ($credential, $uuid, $type, $pref) = @_;
my %args = ();
$args{'credential'} = $credential
if (defined($credential));
$args{'uuid'} = $uuid
if (defined($uuid));
$args{'type'} = $type
if (defined($type));
my $response =
Genixmlrpc::CallMethod($GENICENTRALURL, $MyContext,
"GetCredential", \%args);
return -1
if (!defined($response) || $response->code() != GENIRESPONSE_SUCCESS);
$$pref = $response->value();
return 0;
}
#
# Lookup a record at the clearing house.
#
sub Resolve($$$)
{
my ($uuid, $type, $pref) = @_;
$$pref = undef;
SetCredential();
my $response =
Genixmlrpc::CallMethod($GENICENTRALURL, $MyContext, "Resolve",
{ "credential" => $Credential,
"type" => $type,
"uuid" => $uuid });
return -1
if (!defined($response) || $response->code() != GENIRESPONSE_SUCCESS);
$$pref = $response->value();
return 0;
}
#
# Lookup a user at the clearing house.
#
sub LookupUser($$)
{
my ($uuid, $pref) = @_;
return Resolve($uuid, "User", $pref);
}
#
# Lookup a slice (experiment) at the clearing house.
#
sub LookupSlice($$)
{
my ($uuid, $pref) = @_;
return Resolve($uuid, "Slice", $pref);
}
#
# Register a record at the clearing house.
#
sub Register($$$)
{
my ($type, $cert, $info) = @_;
SetCredential();
my $response =
Genixmlrpc::CallMethod($GENICENTRALURL, $MyContext, "Register",
{ "credential" => $Credential,
"type" => $type,
"cert" => $cert,
"info" => $info });
return -1
if (!defined($response) || $response->code() != GENIRESPONSE_SUCCESS);
return 0;
}
#
# Register a local Emulab user at the Geni ClearingHouse (which in the
# prototype is Utah Emulab).
#
sub RegisterUser($$$$)
{
my ($name, $email, $cert, $keys) = @_;
my $info = { "name" => $name,
"email" => $email };
$info->{"sliverkeys"} = $keys
if (defined($keys));
return Register("User", $cert, $info);
}
#
# Register a slice at the Clearinghouse.
#
sub RegisterSlice($$$)
{
my ($creator_uuid, $cert, $bindings) = @_;
my $info = { "creator_uuid" => $creator_uuid,
"userbindings" => $bindings };
return Register("Slice", $cert, $info);
}
#
# Remove a record at the clearing house.
#
sub Remove($$)
{
my ($type, $uuid) = @_;
SetCredential();
my $response =
Genixmlrpc::CallMethod($GENICENTRALURL, $MyContext, "Remove",
{ "credential" => $Credential,
"type" => $type,
"uuid" => $uuid });
return -1
if (!defined($response) || $response->code() != GENIRESPONSE_SUCCESS);
return 0;
}
#
# Delete a slice registration.
#
sub RemoveSlice($)
{
my ($uuid) = @_;
return Remove("Slice", $uuid);
}
#
# Discover resources for a slice (local experiment). This contacts Geni
# Central to get a list of components. I think the interface is supposed
# to be that we send an rspec and it sends back a list of components. But
# lets not worry about that; just get a list of all components we can ask
# for resources from.
#
sub DiscoverResources($$)
{
my ($slice, $pref) = @_;
my $response =
Genixmlrpc::CallMethod($GENICENTRALURL, $MyContext,
"CH::DiscoverResources",
{ "slice" => $slice->cert() });
return -1
if (!defined($response));
return -1
if ($response->code() != GENIRESPONSE_SUCCESS);
$$pref = $response->value();
return 0;
}
#
# Bind and unbind users to/from slices
#
sub BindUser($$)
{
my ($slice_uuid, $user_uuid) = @_;
my $args = { "slice_uuid" => $slice_uuid,
"user_uuid" => $user_uuid };
my $response =
Genixmlrpc::CallMethod($GENICENTRALURL, $MyContext,
"CH::BindUser", $args);
return -1
if (!defined($response) || $response->code() != GENIRESPONSE_SUCCESS);
return 0;
}
sub UnBindUser($$)
{
my ($slice_uuid, $user_uuid) = @_;
my $args = { "slice_uuid" => $slice_uuid,
"user_uuid" => $user_uuid };
my $response =
Genixmlrpc::CallMethod($GENICENTRALURL, $MyContext,
"CH::UnBindUser", $args);
return -1
if (!defined($response) || $response->code() != GENIRESPONSE_SUCCESS);
return 0;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2008 University of Utah and the Flux Group.
# All rights reserved.
#
package GeniSAClient;
use strict;
use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = "Exporter";
@EXPORT = qw ( );
# Must come after package declaration!
use lib '@prefix@/lib';
use Genixmlrpc;
use GeniResponse;
use English;
use Data::Dumper;
# _Always_ make sure that this 1 is at the end of the file...
1;
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2008 University of Utah and the Flux Group.
# All rights reserved.
#
use strict;
use lib '@prefix@/lib';
use User;
use Experiment;
use Genixmlrpc;
use GeniCHClient;
use GeniCMClient;
use GeniUser;
use GeniCredential;
use GeniSlice;
use English;
use Data::Dumper;
my $this_user = User->LookupByUnixId($UID);
if (! defined($this_user)) {
print STDERR "You ($UID) do not exist!\n";
exit(-1);
}
my $blob;
my $experiment = Experiment->Lookup("testbed", "two");
my @components;
my @resources;
my $ticket;
my $sliver;
#
# The RPC context for this test script is mostly as an SA, with some
# exceptions below.
#
Genixmlrpc->SetContext(Genixmlrpc->Context("@prefix@/etc/genisa.pem"));
#
# Create a Geni user from local user.
#
my $geniuser = GeniUser->CreateFromLocal($this_user);
if (!defined($geniuser)) {
die("Could not create a geni user from local user $this_user\n");
}
# Register at the ClearingHouse.
$geniuser->Register() == 0
or die("Could not register $geniuser at the Geni ClearingHouse.\n");
#
# Another user, for testing binding users to slices.
#
my $geniuser2 = GeniUser->CreateFromLocal(User->Lookup("leebee"));
if (!defined($geniuser2)) {
die("Could not create a geni user from local user leebee\n");
}
# Register at the ClearingHouse.
$geniuser2->Register() == 0
or die("Could not register $geniuser2 at the Geni ClearingHouse.\n");
exit(0);
#
# See if there is a local slice record. If not, create one, then
# register the new slice at the ClearingHouse.
#
my $slice = GeniSlice->Lookup($experiment->uuid());
if (!defined($slice)) {
$slice = GeniSlice->CreateFromLocal($experiment, User->ThisUser());
if (!defined($slice)) {
die("Could not create a local slice record for $experiment\n");
}
}
if ($slice->Register() != 0) {
$slice->Delete();
die("Could not register slice at Geni ClearingHouse.\n");
}
if ($slice->BindUser($geniuser2) != 0) {
die("Could not bind $geniuser2 to slice at Geni ClearingHouse.\n");
}
#
# Generate a credential for resource discovery on components. The credential
# is signed by the local SA, but could just as easily be signed by the slice
# certificate.
#
my $credential = GeniCredential->Create($slice, $geniuser);
if (!defined($credential)) {
die("Could not create a slice credential for $geniuser/$slice!\n");
}
if ($credential->Sign($GeniCredential::LOCALSA_FLAG)) {
die("Could not sign slice credential!\n");
}
#
# Discover resources appropriate for the slice (experiment). This is
# due to change when there is a discovery service at the clearing house.
# For now, we get back a list of components.
#
$slice->DiscoverResources(\@components) == 0 or
die("Could not discover resources for $slice\n");
print Dumper(@components);
#
# Discover resources on each component. This stuff is just a placeholder
# for something else later. For now, we just pass the rspec right back
# to get the ticket.
#
foreach my $component (@components) {
my $rspec;
if ($component->DiscoverResources($slice,
$this_user, $credential, \$rspec) != 0) {
die("Could not discover resources on $component\n");
}
push(@resources, $rspec);
}
my $rspec = $resources[0];
print Dumper($rspec);
#
# Make myself an rspec request from the available resources. We need
# some code to generate this stuff.
#
my @keys = keys(%{$rspec->{'node'}});
my $node1 = $rspec->{'node'}->{$keys[0]};
my $node2 = $rspec->{'node'}->{$keys[1]};
my $nspec = {'node' => {$node1->{'uuid'} => { "uuid" => $node1->{'uuid'},
"node_name" => $keys[0],
},
$node2->{'uuid'} => { "uuid" => $node2->{'uuid'},
"node_name" => $keys[1],
},
},
'link' => {
'link0' => {
"link_name" => 'link0',
"LinkEndPoints" => {
"source_interface" => {
"node_uuid" => $node1->{'uuid'},
"node_name" => $keys[0],
"iface_name" => "eth0",
},
"destination_interface" => {
"node_uuid" => $node2->{'uuid'},
"node_name" => $keys[1],
"iface_name" => "eth0",
}
}
}
}
};
print Dumper($nspec);
#
# Get ticket from component.
#
$ticket = $components[0]->GetTicket($slice, $nspec, $this_user, $credential);
if (!defined($ticket)) {
die("Could not get ticket for $slice\n");
}
print Dumper($ticket);
#
# Create sliver on component using the ticket.
#
$sliver = $components[0]->CreateSliver($slice, $ticket, $this_user);
if (!defined($sliver)) {
die("Could not create sliver for $slice\n");
}
if (defined($sliver)) {
print Dumper($sliver);
# Wait for input before proceeding.
$_ = <STDIN>;
$sliver->Start($this_user);
$_ = <STDIN>;
$sliver->Destroy($this_user);
}
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