Commit 815e26d6 authored by Gary Wong's avatar Gary Wong

Add an optional (and currently undocumented) "compress" parameter to

DiscoverResources.  If present and true, then the returned rspec will
be zlib compressed.
parent 6f9f9afa
......@@ -50,6 +50,8 @@ use Time::Local;
use Experiment;
use VirtExperiment;
use Firewall;
use Compress::Zlib;
use MIME::Base64;
# Configure variables
my $TB = "@prefix@";
......@@ -238,6 +240,7 @@ sub DiscoverResources($)
my ($argref) = @_;
my $credential = $argref->{'credential'};
my $available = $argref->{'available'};
my $compress = $argref->{'compress'};
my $user_uuid = $ENV{'GENIUSER'};
$credential = GeniCredential->CreateFromSigned($credential);
......@@ -255,6 +258,7 @@ sub DiscoverResources($)
# Boolean as its own object type -- which Perl always interprets as
# true, regardless of the object's value. Undo all of that silliness.
$available = defined( $available ) && $available->value;
$compress = defined( $compress ) && $compress->value;
#
# A sitevar controls whether external users can get any nodes.
......@@ -288,6 +292,12 @@ sub DiscoverResources($)
}
close(AVAIL);
if( $compress ) {
my $coder = Frontier::RPC2->new();
my $base64 = encode_base64( compress( $xml ) );
$xml = $coder->base64( $base64 );
}
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $xml);
}
......
......@@ -23,6 +23,7 @@ import os
import re
import xmlrpclib
from M2Crypto import X509
import zlib
execfile( "test-common.py" )
......@@ -54,9 +55,14 @@ for manager in response["value"]:
params = {}
params["credential"] = mycredential
params["available"] = True
params["compress"] = True
rval,response = do_method(None,
"DiscoverResources", params, manager["url"])
if rval:
print "Could not get a list of resources"
elif debug:
print response[ "value" ]
else:
if isinstance( response[ "value" ], xmlrpclib.Binary ):
response[ "value" ] = zlib.decompress( str( response[ "value" ] ) )
if debug:
print response[ "value" ]
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