Commit 99872056 authored by Jonathon Duerig's avatar Jonathon Duerig

Checkpoint for MA/SA

parent 9ac7fa2f
#!/usr/bin/perl -wT
#
# Copyright (c) 2008-2013 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
# GENI Public License
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and/or hardware specification (the "Work") to
# deal in the Work without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Work, and to permit persons to whom the Work
# is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Work.
#
# THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS
# IN THE WORK.
#
# }}}
#
package GeniMA;
#
# The server side of the CM interface on remote sites. Also communicates
# with the GMC interface at Geni Central as a client.
#
use strict;
use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = "Exporter";
@EXPORT = qw ( );
use GeniSA;
use GeniResponse;
use GeniCredential;
use GeniRegistry;
use emutil;
sub GetVersion()
{
my $blob = {
"VERSION" => "0.1",
"CREDENTIAL_TYPES" => ["SFA"]
};
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
}
sub LookupPublic($)
{
my ($options) = @_;
my $match = $options->{'match'};
my $filter = $options->{'filter'};
my $members = {};
if (exists($match) && defined($match)) {
foreach my $key (@{ $match }) {
my $geniuser = GeniUser->Lookup($key, 0);
if (defined($geniuser)) {
my $blob = {};
GeniStd::addField($blob, "MEMBER_URN", $geniuser->urn(),
$filter);
GeniStd::addField($blob, "MEMBER_UID", $geniuser->uid(),
$filter);
GeniStd::addField($blob, "MEMBER_USERNAME", $geniuser->hrn(),
$filter);
$members->{$geniuser->urn()} = $blob;
}
}
}
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $members);
}
sub LookupPrivate($$)
{
my ($credential_args, $options) = @_;
my $credential = GeniStd::CheckCredentials($credential_args);
return $credential
if (GeniResponse::IsResponse($credential));
$credential->HasPrivilege( "authority" ) or
$credential->HasPrivilege( "resolve" ) or
return GeniResponse->Create( GENIRESPONSE_FORBIDDEN, undef,
"Insufficient privilege" );
my $match = $options->{'match'};
my $filter = $options->{'filter'};
my $members = {};
if (exists($match) && defined($match)) {
foreach my $key (@{ $match }) {
my $geniuser = GeniUser->Lookup($key, 0);
if (defined($geniuser)) {
my $blob = {};
$members->{$geniuser->urn()} = $blob;
}
}
}
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $members);
}
sub LookupIdentifying($$)
{
my ($credential_args, $options) = @_;
my $credential = GeniStd::CheckCredentials($credential_args);
return $credential
if (GeniResponse::IsResponse($credential));
$credential->HasPrivilege( "authority" ) or
$credential->HasPrivilege( "resolve" ) or
return GeniResponse->Create( GENIRESPONSE_FORBIDDEN, undef,
"Insufficient privilege" );
my $match = $options->{'match'};
my $filter = $options->{'filter'};
my $members = {};
if (exists($match) && defined($match)) {
foreach my $key (@{ $match }) {
my $geniuser = GeniUser->Lookup($key, 0);
if (defined($geniuser)) {
my @namelist = split(/ /, $neinuser->name());
my $lastname = pop(@namelist);
my $firstname = join(" ", @namelist);
my $blob = {};
GeniStd::addField($blob, "MEMBER_URN", $geniuser->urn(),
$filter);
GeniStd::addField($blob, "MEMBER_FIRSTNAME", $firstname,
$filter);
GeniStd::addField($blob, "MEMBER_LASTNAME", $lastname,
$filter);
GeniStd::addField($blob, "MEMBER_EMAIL", $geniuser->email(),
$filter);
}
}
}
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $members);
}
sub UpdateMember($$$)
{
my ($member_urn, $credential_args, $options) = @_;
return GeniResponse->Create(GENIRESPONSE_FORBIDDEN, undef,
"Update Member is Unimplemented");
}
sub GetCredentials($$$)
{
my ($member_urn, $credential_args, $options) = @_;
my $credential = GeniSA::GetCredential($member_urn);
return $credential
if (GeniResponse::IsResponse($credential));
my $blob = {
"geni_type" => "sfa",
"geni_type" => "3",
"geni_credential" => $credential->value()
};
return GeniResponse->Create(GENIRESPONSE_SUCCESS, [$blob]);
}
#!/usr/bin/perl -wT
#
# Copyright (c) 2008-2013 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
# GENI Public License
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and/or hardware specification (the "Work") to
# deal in the Work without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Work, and to permit persons to whom the Work
# is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Work.
#
# THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS
# IN THE WORK.
#
# }}}
#
package GeniMA;
#
# The server side of the CM interface on remote sites. Also communicates
# with the GMC interface at Geni Central as a client.
#
use strict;
use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = "Exporter";
@EXPORT = qw ( );
use GeniSA;
use GeniResponse;
use GeniCredential;
use GeniRegistry;
use emutil;
sub GetVersion()
{
my $blob = {
"VERSION" => "0.1",
"SERVICES" => ["SLICE", "PROJECT", "SLICE_MEMBER", "PROJECT_MEMBER"],
"CREDENTIAL_TYPES" => ["SFA"],
"ROLES" => ["AUTHORITY", "ADMIN", "MEMBER"]
};
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
}
sub CreateSlice($$$)
{
my ($slice_urn, $credential_args, $options) = @_;
my $credential = GeniStd::CheckCredentials($credential_args);
return $credential
if (GeniResponse::IsResponse($credential));
my $args = {
"credential" => $credential->Stringify(),
"urn" => $slice_urn
};
my $response = GeniSA::Register($args);
if (! GeniResponse->IsError($response)) {
my $slice = GeniSlices::Lookup($slice_urn);
if (defined($slice)) {
my $blob = {
"SLICE_URN" => $slice_urn,
"SLICE_EXPIRATION" => $slice->expires(),
"SLICE_CREDENTIAL" => $response->value()
};
$response = GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
} else {
$response = GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Internal Error: Looking up slice during creation");
}
}
return $response;
}
sub LookupSlices()
{
my ($credential_args, $options) = @_;
my $credential = GeniStd::CheckCredentials($credential_args);
return $credential
if (GeniResponse::IsResponse($credential));
$credential->HasPrivilege( "authority" ) or
$credential->HasPrivilege( "resolve" ) or
return GeniResponse->Create( GENIRESPONSE_FORBIDDEN, undef,
"Insufficient privilege" );
my $match = $options->{'match'};
my $filter = $options->{'filter'};
my $members = {};
if (exists($match) && defined($match)) {
foreach my $key (@{ $match }) {
my $slice = GeniSlice->Lookup($key, 0);
if (defined($slice)) {
my $blob = {};
GeniStd::addField($blob, "SLICE_URN", $slice->urn(),
$filter);
GeniStd::addField($blob, "SLICE_UID", $slice->uid(),
$filter);
GeniStd::addField($blob, "SLICE_CREATION", $slice->created(),
$filter);
GeniStd::addField($blob, "SLICE_EXPIRATION", $slice->expires(),
$filter);
GeniStd::addField($blob, "EXPIRED", "False",
$filter);
GeniStd::addField($blob, "SLICE_NAME", $slice->hrn(),
$filter);
GeniStd::addField($blob, "SLICE_DESCRIPTION", "A Slice",
$filter);
}
}
}
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $members);
}
sub UpdateSlice()
{
my ($slice_urn, $credential_args, $options) = @_;
return GeniResponse->Create(GENIRESPONSE_FORBIDDEN, undef,
"Update Slice is Unimplemented");
}
sub GetCredentials()
{
my ($slice_urn, $credential_args, $options) = @_;
my $credential = GeniSA::GetCredential($slice_urn);
return $credential
if (GeniResponse::IsResponse($credential));
my $blob = {
"geni_type" => "sfa",
"geni_type" => "3",
"geni_credential" => $credential->value()
};
return GeniResponse->Create(GENIRESPONSE_SUCCESS, [$blob]);
}
sub ModifySliceMembership()
{
}
sub LookupSliceMembers()
{
}
sub LookupSlicesForMember()
{
}
sub RegisterAggregate($$$$)
{
my ($slice_urn, $aggregate_url, $credentials, $options) = @_;
}
sub RemoveAggregate()
{
}
sub GetSliceAggregates()
{
}
sub CreateProject()
{
}
sub LookupProjects()
{
}
sub UpdateProject()
{
}
sub ModifyProjectMembership()
{
}
sub LookupProjectMembers()
{
}
sub LookupProjectsForMember()
{
}
#!/usr/bin/perl -w
#
# Copyright (c) 2008-2013 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
# GENI Public License
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and/or hardware specification (the "Work") to
# deal in the Work without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Work, and to permit persons to whom the Work
# is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Work.
#
# THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS
# IN THE WORK.
#
# }}}
#
use strict;
use English;
use Frontier::Responder;
use Frontier::RPC2;
# Do this early so that we talk to the right DB.
use vars qw($GENI_DBNAME $GENI_METHODS $EMULAB_PEMFILE
$GENI_RESPONSE_CONVERTER $GENI_VERSION);
BEGIN { $GENI_DBNAME = "geni-sa"; }
# Configure variables
my $ETCDIR = "@prefix@/etc";
$EMULAB_PEMFILE = "$ETCDIR/genisa.pem";
# Testbed libraries.
use lib '@prefix@/lib';
use GeniMA;
use GeniResponse;
$GENI_METHODS = {
"get_version" => \&GeniMA::GetVersion,
"lookup_public_member_info" => \&GeniMA::LookupPublic,
"lookup_private_member_info" => \&GeniMA::LookupPrivate,
"lookup_identifying_member_info" => \&GeniMA::LookupIdentifying,
"update_member_info" => \&GeniMA::UpdateMember,
"get_credentials" => \&GeniMA::GetCredentials,
};
1;
#!/usr/bin/perl -w
#
# Copyright (c) 2008-2013 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
# GENI Public License
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and/or hardware specification (the "Work") to
# deal in the Work without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Work, and to permit persons to whom the Work
# is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Work.
#
# THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS
# IN THE WORK.
#
# }}}
#
use strict;
use English;
use Frontier::Responder;
use Frontier::RPC2;
# Do this early so that we talk to the right DB.
use vars qw($GENI_DBNAME $GENI_METHODS $EMULAB_PEMFILE
$GENI_RESPONSE_CONVERTER);
BEGIN { $GENI_DBNAME = "geni-sa"; }
# Configure variables
my $ETCDIR = "@prefix@/etc";
$EMULAB_PEMFILE = "$ETCDIR/genisa.pem";
# Testbed libraries.
use lib '@prefix@/lib';
use GeniSA;
use GeniResponse;
$GENI_METHODS = {
# SLICE_INFO
"get_version" => \&GeniStdSA::GetVersion,
"create_slice" => \&GeniStdSA::CreateSlice,
"lookup_slices" => \&GeniStdSA::LookupSlices,
"update_slice" => \&GeniStdSA::UpdateSlice,
"get_credentials" => \&GeniStdSA::GetCredentials,
# SLICE_MEMBERS
"modify_slice_membership" => \&GeniStdSA::ModifySliceMembership,
"lookup_slice_members" => \&GeniStdSA::LookupSliceMembers,
"lookup_slices_for_member" => \&GeniStdSA::LookupSlicesForMember,
# SLIVER INFO
"register_aggregate" => \&GeniStdSA::RegisterAggregate,
"remove_aggregate" => \&GeniStdSA::RemoveAggregate,
"get_slice_aggregates" => \&GeniStdSA::GetSliceAggregates,
# PROJECT_SERVICE
"create_project" => \&GeniStdSA::CreateProject,
"lookup_projects" => \&GeniStdSA::LookupProjects,
"update_project" => \&GeniStdSA::UpdateProject,
# PROJECT_SERVICE
"modify_project_membership" => \&GeniStdSA::ModifyProjectMembership,
"lookup_project_members" => \&GeniStdSA::LookupProjectMembers,
"lookup_projects_for_member" => \&GeniStdSA::LookupProjectsForMember,
};
1;
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