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

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

parents 83477fc9 8b18971e
......@@ -6,9 +6,12 @@
#
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);
use vars qw($GENI_DBNAME $GENI_METHODS $EMULAB_PEMFILE
$GENI_RESPONSE_CONVERTER);
BEGIN { $GENI_DBNAME = "geni"; }
# Configure variables
......@@ -18,6 +21,7 @@ $EMULAB_PEMFILE = "$ETCDIR/genisa.pem";
# Testbed libraries.
use lib '@prefix@/lib';
use GeniAM;
use GeniResponse;
if (!defined($GENI_VERSION) || $GENI_VERSION eq "1.0") {
$GENI_METHODS = {
......@@ -31,5 +35,34 @@ if (!defined($GENI_VERSION) || $GENI_VERSION eq "1.0") {
};
}
#----------------------------------------------------------------------
# Morph the ProtoGENI response (a hash with three keys; a
# GeniResponse) into a GENI AM response (a single value or a fault if
# there is an error).
#
# $response is an XML RPC response, which is a three element hash. The
# value element is the GeniResponse hash.
#----------------------------------------------------------------------
sub ConvertResponse($)
{
my ($geni_response) = @_;
my $decoder = Frontier::RPC2->new();
my $response;
if (GeniResponse::IsError($geni_response)) {
# An error result gets mapped to an XML RPC fault
$response =
$decoder->encode_fault(GeniResponse::code($geni_response),
GeniResponse::output($geni_response));
} else {
# A successful result means return the value
$response =
$decoder->encode_response(GeniResponse::value($geni_response));
}
return $response;
}
$GENI_RESPONSE_CONVERTER = \&ConvertResponse;
1;
......@@ -42,7 +42,8 @@ my %GENI_MODULES = ( "cm" => "@prefix@/lib/protogeni-cm.pm",
"ses" => "@prefix@/lib/protogeni-ses.pm" );
# These variables are shared with the loaded module.
use vars qw($EMULAB_PEMFILE $GENI_METHODS $GENI_VERSION);
use vars qw($EMULAB_PEMFILE $GENI_METHODS $GENI_VERSION
$GENI_RESPONSE_CONVERTER);
# Testbed libraries.
use lib '@prefix@/lib';
......@@ -293,8 +294,6 @@ if ($@) {
"Error executing RPC:\n" . $@ . "\n\n" . $request);
}
else {
$response = $decoder->encode_response($result);
if (GeniResponse::IsError($result)) {
$message .= "Error: " . $result->{'code'} . "\n";
}
......@@ -308,6 +307,16 @@ else {
$message .= "Request:\n" . $request . "\n";
AddAuditInfo("message", $message);
#
# Added this for geni-am ...
#
if (defined($GENI_RESPONSE_CONVERTER)) {
$response = &$GENI_RESPONSE_CONVERTER($result);
}
else {
$response = $decoder->encode_response($result);
}
}
if ($debug) {
......
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