Commit ee23571f authored by Leigh B Stoller's avatar Leigh B Stoller

Add another convenience function: GetSSHKeys().

parent dfd1d0a7
......@@ -222,5 +222,46 @@ sub GetManifests($)
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
}
#
# Get SSH keys for the instance (implied by the credential).
#
sub GetSSHKeys($)
{
my ($argref) = @_;
my $cred = $argref->{'credential'};
if (!defined($cred)) {
return GeniResponse->MalformedArgsResponse("Missing credential");
}
my $authority = GeniAuthority->Lookup($ENV{'MYURN'});
if (!defined($authority)) {
print STDERR "Could not find local authority object\n";
return GeniResponse->Create(GENIRESPONSE_ERROR);
}
my $credential = GeniCredential::CheckCredential($cred, $authority);
return $credential
if (GeniResponse::IsResponse($credential));
my $slice = MapCertToSlice($credential->owner_cert());
return $slice
if (GeniResponse::IsResponse($slice));
#
# Given the slice, we need to find the Portal instance.
#
my $instance = APT_Instance->LookupBySlice($slice->uuid());
return GeniResponse->Create(GENIRESPONSE_SEARCHFAILED, undef,
"No portal instance for slice")
if (!defined($instance));
my $sshkeys;
if ($instance->GetSSHKeys(\$sshkeys) < 0 || !@{$sshkeys}) {
print STDERR "Could not get SSH keys\n";
return GeniResponse->Create(GENIRESPONSE_ERROR);
}
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $sshkeys);
}
# _Always_ make sure that this 1 is at the end of the file...
1;
......@@ -46,6 +46,7 @@ $GENI_METHODS = {
"GetVersion" => \&GeniPortal::GetVersion,
"GetCredential" => \&GeniPortal::GetCredential,
"GetManifests" => \&GeniPortal::GetManifests,
"GetSSHKeys" => \&GeniPortal::GetSSHKeys,
};
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