Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optional support for custom_request_handler_class to AMs #927

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/gcf-am.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ def main(argv=None):
# certs possibly concatenated together
comboCertsFile = geni.CredentialVerifier.getCAsFileFromDir(getAbsPath(opts.rootcadir))

try:
custom_request_handler_class = delegate.custom_request_handler_class
except AttributeError:
# no custom request handler
custom_request_handler_class = None

if opts.api_version == 1:
# rootcadir is dir of multiple certificates
delegate = geni.ReferenceAggregateManager(getAbsPath(opts.rootcadir))
Expand All @@ -200,7 +206,8 @@ def main(argv=None):
base_name=config['global']['base_name'],
authorizer=authorizer,
resource_manager=resource_manager,
delegate=delegate)
delegate=delegate,
custom_request_handler_class = custom_request_handler_class)
elif opts.api_version == 3:
ams = gcf.geni.am.am3.AggregateManagerServer((opts.host, int(opts.port)),
keyfile=keyfile,
Expand All @@ -210,7 +217,8 @@ def main(argv=None):
base_name=config['global']['base_name'],
authorizer=authorizer,
resource_manager=resource_manager,
delegate=delegate, multithread=multithread)
delegate=delegate, multithread=multithread,
custom_request_handler_class = custom_request_handler_class)
else:
msg = "Unknown API version: %d. Valid choices are \"1\", \"2\", or \"3\""
sys.exit(msg % (opts.api_version))
Expand Down
11 changes: 8 additions & 3 deletions src/gcf/geni/am/am2.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,8 @@ def __init__(self, addr, keyfile=None, certfile=None,
trust_roots_dir=None,
ca_certs=None, base_name=None,
authorizer=None, resource_manager=None,
delegate=None):
delegate=None,
custom_request_handler_class = None):
# ca_certs arg here must be a file of concatenated certs
if ca_certs is None:
raise Exception('Missing CA Certs')
Expand All @@ -867,8 +868,12 @@ def __init__(self, addr, keyfile=None, certfile=None,
delegate = ReferenceAggregateManager(trust_roots_dir, base_name,
server_url)
# FIXME: set logRequests=true if --debug
self._server = SecureXMLRPCServer(addr, keyfile=keyfile,
certfile=certfile, ca_certs=ca_certs)
if custom_request_handler_class is not None:
self._server = SecureXMLRPCServer(addr, requestHandler=custom_request_handler_class, keyfile=keyfile,
certfile=certfile, ca_certs=ca_certs)
else:
self._server = SecureXMLRPCServer(addr, keyfile=keyfile,
certfile=certfile, ca_certs=ca_certs)
aggregate_manager = AggregateManager(trust_roots_dir, delegate,
authorizer, resource_manager)
self._server.register_instance(aggregate_manager)
Expand Down
28 changes: 19 additions & 9 deletions src/gcf/geni/am/am3.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from ..util.tz_util import tzd
from ..util.urn_util import publicid_to_urn
from ..util import urn_util as urn
from ..SecureXMLRPCServer import SecureXMLRPCServer
from ..SecureXMLRPCServer import SecureXMLRPCServer, SecureXMLRPCRequestHandler
from ..SecureThreadedXMLRPCServer import SecureThreadedXMLRPCServer

from ...sfa.trust.credential import Credential
Expand Down Expand Up @@ -1378,7 +1378,6 @@ def Shutdown(self, slice_urn, credentials, options):
amc._options)
return amc._result


class AggregateManagerServer(object):
"""An XMLRPC Aggregate Manager Server. Delegates calls to given delegate,
or the default printing AM."""
Expand All @@ -1387,7 +1386,8 @@ def __init__(self, addr, keyfile=None, certfile=None,
trust_roots_dir=None,
ca_certs=None, base_name=None,
authorizer=None, resource_manager=None,
delegate=None, multithread=False):
delegate=None, multithread=False,
custom_request_handler_class = None):
# ca_certs arg here must be a file of concatenated certs
if ca_certs is None:
raise Exception('Missing CA Certs')
Expand All @@ -1403,13 +1403,23 @@ def __init__(self, addr, keyfile=None, certfile=None,
# FIXED: set logRequests=true if --debug
logRequest=logging.getLogger().getEffectiveLevel()==logging.DEBUG
if multithread:
self._server = SecureThreadedXMLRPCServer(addr, keyfile=keyfile,
certfile=certfile, ca_certs=ca_certs,
logRequests=logRequest)
if custom_request_handler_class is not None:
self._server = SecureThreadedXMLRPCServer(addr, requestHandler=custom_request_handler_class, keyfile=keyfile,
certfile=certfile, ca_certs=ca_certs,
logRequests=logRequest)
else:
self._server = SecureThreadedXMLRPCServer(addr, keyfile=keyfile,
certfile=certfile, ca_certs=ca_certs,
logRequests=logRequest)
else:
self._server = SecureXMLRPCServer(addr, keyfile=keyfile,
certfile=certfile, ca_certs=ca_certs,
logRequests=logRequest)
if custom_request_handler_class is not None:
self._server = SecureXMLRPCServer(addr, requestHandler=custom_request_handler_class, keyfile=keyfile,
certfile=certfile, ca_certs=ca_certs,
logRequests=logRequest)
else:
self._server = SecureXMLRPCServer(addr, keyfile=keyfile,
certfile=certfile, ca_certs=ca_certs,
logRequests=logRequest)
aggregate_manager = AggregateManager(trust_roots_dir, delegate,
authorizer, resource_manager)
self._server.register_instance(aggregate_manager)
Expand Down