Author: tmckay
Date: 2012-09-11 13:46:59 +0000 (Tue, 11 Sep 2012)
New Revision: 5463
Modified:
branches/tmckay/sage/python/sage/aviary/aviaryoperations.py
Log:
Allow an operations object to be constructed with no locator and no server lists and
detect host names that are full URLs. This allows Aviary endpoints to be
passed directly for all operations.
Modified: branches/tmckay/sage/python/sage/aviary/aviaryoperations.py
===================================================================
--- branches/tmckay/sage/python/sage/aviary/aviaryoperations.py 2012-09-10 19:41:17 UTC
(rev 5462)
+++ branches/tmckay/sage/python/sage/aviary/aviaryoperations.py 2012-09-11 13:46:59 UTC
(rev 5463)
@@ -254,11 +254,13 @@
if self.locator:
self.job_servers = ServerList(self.locator, "SCHEDULER",
"JOB")
- else:
+ elif job_servers:
self.job_servers = FixedServerList(job_servers,
"9090",
"/services/job/",
"JOB")
+ else:
+ self.job_servers = None
job_wsdl = "file:" +
os.path.join(get_datadir(datadir,"job"),
"aviary-job.wsdl")
@@ -447,11 +449,13 @@
if self.locator:
self.query_servers = ServerList(self.locator,
"CUSTOM",
"QUERY_SERVER")
- else:
+ elif query_servers:
self.query_servers = FixedServerList(query_servers,
"9091",
"/services/query/",
"QUERY_SERVER")
+ else:
+ self.query_servers = None
query_wsdl = "file:" +
os.path.join(get_datadir(datadir,"query"),
"aviary-query.wsdl")
@@ -688,13 +692,9 @@
subId.name = name
subId.qdate = qdate
- if host_is_endpoint:
- servers = None
- else:
- servers = self.query_servers
self._setup_client(query_client,
- servers, # server lookup object
- host, # host we want
+ self.query_servers, # server lookup object
+ host, # host we want
"getSubmissionID")
res = self._call_sync(my_process_results,
@@ -748,17 +748,19 @@
return {"INTEGER": int, "FLOAT": float, "STRING":
str, "BOOLEAN": bool}
def _set_client_info(self, client, refresh=False):
- # If there is no server_list, then client.server_name is expected to
- # be an endpoint
- if client.server_list:
+ # See if the server_name is a full URL. If so, we'll use it.
+ url = parse_URL(client.server_name)
+ if url.scheme and url.host and url.port and url.path:
+ scheme = url.scheme
+ host = client.server_name
+
+ elif client.server_list:
scheme, host = client.server_list.find_server(client.server_name,
refresh)
else:
- # We need the scheme value separated out for the transport
- scheme = parse_URL(client.server_name).scheme
- if scheme is None:
- scheme = "http"
- host = client.server_name
+ log.debug("AviaryOperations: no server list specified and %s "\
+ "is not a URL" % client.server_name)
+ raise Exception("Cannot resolve %s to an Aviary endpoint" %
client.server_name)
# Have to set the URL for the method. This might go away someday...
client.set_options(location=host+client.method_name)
@@ -856,10 +858,7 @@
query_servers="",
key="", cert="", root_cert="",
domain_verify=True):
- # If job_servers and query_servers is not set, we must have a
- # locator. If locator has been set, it must be the right type
- # because it will override the server lists.
- if not (job_servers and query_servers) or locator is not None:
+ if locator is not None:
assert isinstance(locator, AviaryLocator)
super(AviaryOperations, self).__init__(name, locator,
@@ -876,10 +875,7 @@
job_servers="",
key="", cert="", root_cert="",
domain_verify=True):
- # If job_servers is not set, we must have a
- # locator. If locator has been set, it must be the right type
- # because it will override the server list.
- if not job_servers or locator is not None:
+ if locator is not None:
assert isinstance(locator, AviaryLocator)
super(AviaryJobOperations, self).__init__(name, locator,
@@ -894,10 +890,7 @@
query_servers="",
key="", cert="", root_cert="",
domain_verify=True):
- # If query_servers is not set, we must have a
- # locator. If locator has been set, it must be the right type
- # because it will override the server list.
- if not query_servers or locator is not None:
+ if locator is not None:
assert isinstance(locator, AviaryLocator)
super(AviaryQueryOperations, self).__init__(name, locator,
@@ -912,10 +905,6 @@
query_servers="",
key="", cert="", root_cert="",
domain_verify=True):
- if not (job_servers or query_servers or locator_uri):
- raise Exception("locator_uri, job_servers, and query_servers "\
- "may not all be null strings")
-
# If locator uri has not been specified, it's disabled and we will
# use the specified job_servers and query_servers values
if locator_uri: