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

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