Commit 13881629 authored by Srikanth Chikkulapelly's avatar Srikanth Chikkulapelly
Browse files

Merge branch 'master' of srikanth@git-public.flux.utah.edu:/flux/git/emulab-devel

parents 37811d10 fe081316
......@@ -61,7 +61,7 @@ my %aggregates = ();
BEGIN { use GeniUtil; GeniUtil::AddCache(\%aggregates); }
#
# Lookup by idx, or uuid.
# Lookup by URN, idx, or uuid.
#
sub Lookup($$)
{
......@@ -70,11 +70,26 @@ sub Lookup($$)
my $idx;
if (GeniHRN::IsValid($token)) {
return undef if !GeniHRN::Authoritative($token, "@OURDOMAIN@");
my ($authority, $type, $id) = GeniHRN::Parse($token);
return undef if $type ne "sliver";
$idx = $id;
if( GeniHRN::Authoritative($token, "@OURDOMAIN@") ) {
# Very simple: we put the index of our own aggregates right
# in the name.
$idx = $id;
} else {
# Look up the aggregate's certificate.
$token = GeniHRN::Normalise( $token );
$query_result = DBQueryWarn(
"SELECT geni_aggregates.idx FROM geni_aggregates, " .
"geni_certificates WHERE geni_aggregates.uuid = " .
"geni_certificates.uuid AND " .
"geni_certificates.urn='$token';" );
return undef if (! $query_result || !$query_result->numrows);
($idx) = $query_result->fetchrow_array();
}
}
elsif ($token =~ /^\d+$/) {
$idx = $token;
......
......@@ -34,7 +34,7 @@ use Data::Dumper;
use overload ('""' => 'Stringify');
#
# Lookup by idx or uuid.
# Lookup by URN, idx or uuid.
#
sub Lookup($$)
{
......@@ -286,7 +286,7 @@ sub Lookup($$)
my $idx;
if( GeniHRN::IsValid( $token ) ) {
return undef if !GeniHRN::Authoritative($token, "@OURDOMAIN@");
$token = GeniHRN::Normalise( $token );
my ($authority, $type, $id) = GeniHRN::Parse($token);
return undef if $type ne "sliver";
......@@ -362,6 +362,28 @@ sub LookupByAuthority($$$)
return GeniRegistry::ClientSliver->Lookup($idx);
}
# Returns an array of client slivers belonging which belong to a
# particular slice.
sub LookupBySlice($$)
{
my ($class, $slice) = @_;
my $slice_idx = $slice->idx();
my $query_result;
my @result = ();
$query_result =
DBQueryWarn("select idx from client_slivers ".
"where slice_idx='$slice_idx'");
if ($query_result) {
while (my ($idx) = $query_result->fetchrow_array()) {
my $sliver = GeniRegistry::ClientSliver->Lookup($idx);
if (defined($sliver)) {
push(@result, $sliver);
}
}
}
return @result;
}
#
# Class function to create new Geni slice and return the object.
#
......
......@@ -327,14 +327,20 @@ sub Resolve($)
if ($slice->Lock() != 0) {
return GeniResponse->BusyResponse("slice");
}
my @slivers = GeniRegistry::ClientSliver->LookupBySlice($slice);
my @managers = ();
foreach my $sliver (@slivers) {
push(@managers, $sliver->manager_urn());
}
# Return a blob.
my $blob = { "hrn" => $slice->hrn(),
"uuid" => $slice->uuid(),
"creator_uuid" => $slice->creator_uuid(),
"gid" => $slice->cert(),
"urn" => GeniHRN::Generate( $OURDOMAIN,
"slice",
$slice->slicename() )
"urn" => GeniHRN::Generate($OURDOMAIN,
"slice",
$slice->slicename() ),
"component_managers" => \@managers
};
$slice->UnLock();
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
......
......@@ -57,7 +57,7 @@ my %slivers = ();
BEGIN { use GeniUtil; GeniUtil::AddCache(\%slivers); }
#
# Lookup by idx, or uuid.
# Lookup by URN, idx, or uuid.
#
sub Lookup($$)
{
......@@ -66,11 +66,26 @@ sub Lookup($$)
my $idx;
if (GeniHRN::IsValid($token)) {
return undef if !GeniHRN::Authoritative($token, "@OURDOMAIN@");
my ($authority, $type, $id) = GeniHRN::Parse($token);
return undef if $type ne "sliver";
$idx = $id;
if( GeniHRN::Authoritative($token, "@OURDOMAIN@") ) {
# Very simple: we put the index of our own slivers right
# in the name.
$idx = $id;
} else {
# Look up the slivers's certificate.
$token = GeniHRN::Normalise( $token );
$query_result = DBQueryWarn(
"SELECT geni_slivers.idx FROM geni_slivers, " .
"geni_certificates WHERE geni_slivers.uuid = " .
"geni_certificates.uuid AND " .
"geni_certificates.urn='$token';" );
return undef if (! $query_result || !$query_result->numrows);
($idx) = $query_result->fetchrow_array();
}
}
elsif ($token =~ /^\d+$/) {
$idx = $token;
......
......@@ -76,6 +76,7 @@ sub Lookup($$)
my $query_result;
if (GeniHRN::IsValid($token)) {
# We don't attempt to handle tickets for foreign authorities.
return undef if !GeniHRN::Authoritative($token, "@OURDOMAIN@");
my ($authority, $type, $id) = GeniHRN::Parse($token);
......
......@@ -57,7 +57,7 @@ sub mysystem($)
}
#
# Lookup by idx, or uuid.
# Lookup by URN, idx, or uuid.
#
sub Lookup($$;$)
{
......@@ -69,30 +69,40 @@ sub Lookup($$;$)
if (!defined($includelocal));
if( GeniHRN::IsValid( $token ) ) {
return undef if !GeniHRN::Authoritative( $token, $OURDOMAIN );
$token = GeniHRN::Normalise( $token );
my ($authority, $type, $id) = GeniHRN::Parse( $token );
return undef if $type ne "user";
$query_result =
DBQueryWarn("select idx from geni_users ".
"where hrn='${PGENIDOMAIN}.$id' and status='active'");
return undef
if (!$query_result);
if (!$query_result->numrows) {
return undef
if (!$includelocal);
if( GeniHRN::Authoritative( $token, "@OURDOMAIN@" ) ) {
# A local name, so look only for local users...
$query_result =
DBQueryWarn("select idx from geni_users ".
"where hrn='${PGENIDOMAIN}.$id' " .
"and status='active'");
#
# Check Emulab users table.
#
my $user = User->Lookup($id);
return undef
if (!defined($user));
return GeniUser->CreateFromLocal($user);
if (!$query_result);
if (!$query_result->numrows) {
return undef
if (!$includelocal);
#
# Check Emulab users table.
#
my $user = User->Lookup($id);
return undef
if (!defined($user));
return GeniUser->CreateFromLocal($user);
}
} else {
# A foreign name: check against names in certificates.
$query_result = DBQueryWarn(
"SELECT geni_users.idx FROM geni_users, geni_certificates " .
"WHERE geni_users.uuid = geni_certificates.uuid AND " .
"geni_certificates.urn = '$token';" );
return undef unless $query_result and $query_result->numrows;
}
($idx) = $query_result->fetchrow_array();
}
......
<rspec xmlns="http://www.protogeni.net/resources/rspec/0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.protogeni.net/resources/rspec/0.1
http://www.protogeni.net/resources/rspec/0.1/request.xsd" type="request">
<node virtual_id="my-node" virtualization_type="emulab-vnode"
exclusive="1">
<node_type type_name="pc850" type_slots="1"/>
<interface virtual_id="control"/>
</node>
</rspec>
\ No newline at end of file
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