Skip to content
Snippets Groups Projects
Commit ce9e3c6d authored by Prathamesh Joshi's avatar Prathamesh Joshi Committed by Prathamesh Joshi
Browse files

Modified index method to get a rule from proxy methods

parent d544a89b
No related branches found
No related tags found
1 merge request!598Encode job and analysis tag in the URLs created by gstlal servers
......@@ -224,6 +224,18 @@ def service_domain(gracedb_search, gracedb_pipeline):
return "%s_%s.%s" % (gracedb_pipeline.lower(), gracedb_search.lower(), servicediscovery.DEFAULT_SERVICE_DOMAIN)
def get_rule_from_proxy_route(route):
# Method to trace back the rules defined
# by a PROXY method from the GET methods
# of the original application
if route.method != 'PROXY':
raise ValueError("The route provided is not a PROXY route")
# Make sure we only consider GET methods
# Make sure we don't create links back here
original_rules = [r.rule for r in route.config()['mountpoint.target'].routes if r.method == "GET" and r.rule not in ("/", "/index.html")]
return [route.config()['mountpoint.prefix'][:-1] + r for r in original_rules] # [:-1] removes a / at the end
#
# =============================================================================
#
......@@ -687,14 +699,8 @@ for output_file_number, (svd_bank_url_dict, output_url, ranking_stat_output_url,
netloc = bottle.request.urlparts[1]
server_address = "http://%s" % netloc
yield "<html><body>\n<h3>%s %s %s %s</h3>\n<p>\n" % (job_tag, os.environ.get("GSTLAL_LL_JOB"), netloc, " ".join(sorted(instruments)))
for route in sorted(bottle.default_app().routes, key = lambda route: route.rule):
# don't create links back to this page
if route.rule in ("/", "/index.html"):
continue
# only create links for GET methods
if route.method != "GET":
continue
yield "<a href=\"%s%s\">%s</a><br>\n" % (server_address, route.rule, route.rule)
for rule in sorted(get_rule_from_proxy_route(modified_app.routes[0])):
yield "<a href=\"%s%s\">%s</a><br>\n" % (server_address, rule, rule)
yield "</p>\n</body></html>"
# FIXME: get service-discovery working, then don't do this
if "GSTLAL_LL_JOB" in os.environ:
......
......@@ -263,12 +263,21 @@ if __name__ == '__main__':
ZLC = ZeroLagCounts(options)
#
# Stuff to handle bottle route to retrieve xml doc with new counts
# Create a new, empty, Bottle application and make it the current
# default. The Bottle routes defined in various parts of the code
# will get added to this app.
# Simultaneously, create a new Bottle application and mount the
# default app's modified routes to this app. This app will be
# explicitly passed to the http server(s) to serve it up.
#
bottle.default_app.push()
default_app = bottle.default_app.push()
modified_app = bottle.Bottle()
modified_app.mount(f"/{options.tag}/", default_app)
bottle.route('/zerolag_rankingstatpdf.xml')(ZLC.web_get_zerolag_rankingstatpdf)
httpservers = httpinterface.HTTPServers(
bottle_app = modified_app,
service_name = "%s.gstlal_ll_inspiral_trigger_counter" % (base64.urlsafe_b64encode(uuid.uuid4().bytes)),
service_domain = service_domain(options.gracedb_search, options.gracedb_pipeline),
service_properties = {
......@@ -278,7 +287,7 @@ if __name__ == '__main__':
service_discovery = False,#FIXME
verbose = options.verbose
)
open("gstlal_ll_inspiral_trigger_counter_registry.txt", "w").write("http://%s:%s/\n" % (socket.gethostname(), httpservers[0][0].port))
open("gstlal_ll_inspiral_trigger_counter_registry.txt", "w").write("http://%s:%s/%s/\n" % (socket.gethostname(), httpservers[0][0].port, options.tag))
# set up logging
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment