Merge "fix comments OPTFRA-242, edit release notes"
[optf/osdf.git] / osdfapp.py
index eb14530..698d922 100755 (executable)
@@ -45,6 +45,7 @@ from requests import RequestException
 from schematics.exceptions import DataError
 from osdf.logging.osdf_logging import MH, audit_log, error_log, debug_log
 from osdf.models.api.placementRequest import PlacementAPI
+from osdf.operation.responses import osdf_response_for_request_accept as req_accept
 
 ERROR_TEMPLATE = osdf.ERROR_TEMPLATE
 
@@ -96,6 +97,7 @@ def handle_data_error(e):
 @app.route("/api/oof/v1/healthcheck", methods=["GET"])
 def do_osdf_health_check():
     """Simple health check"""
+    audit_log.info("A health check request is processed!")
     return "OK"
 
 
@@ -110,22 +112,15 @@ def do_placement_opt():
     req_id = request_json['requestInfo']['requestId']
     g.request_id = req_id
     audit_log.info(MH.received_request(request.url, request.remote_addr, json.dumps(request_json)))
-
     PlacementAPI(request_json).validate()
-
-    # Currently policies are being used only during placement, so only fetch them if placement demands is not empty
-    policies, prov_status = {}, None
-
-    if 'placementDemand' in request_json['placementInfo']['demandInfo']:
-        policies, prov_status = get_policies(request_json, "placement")
-
+    policies = get_policies(request_json, "placement")
     audit_log.info(MH.new_worker_thread(req_id, "[for placement]"))
-    t = Thread(target=process_placement_opt, args=(request_json, policies, osdf_config, prov_status))
+    t = Thread(target=process_placement_opt, args=(request_json, policies, osdf_config))
     t.start()
     audit_log.info(MH.accepted_valid_request(req_id, request))
-    return osdf.operation.responses.osdf_response_for_request_accept(
-        req_id=req_id, text="Accepted placement request. Response will be posted to callback URL")
-
+    return req_accept(request_id=req_id,
+                      transaction_id=request_json['requestInfo']['transactionId'],
+                      request_status="accepted", status_message="")
 
 @app.errorhandler(500)
 def internal_failure(error):