aboutsummaryrefslogtreecommitdiffstats
path: root/osdfapp.py
diff options
context:
space:
mode:
Diffstat (limited to 'osdfapp.py')
-rwxr-xr-xosdfapp.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/osdfapp.py b/osdfapp.py
index 6ae84cc..5f13108 100755
--- a/osdfapp.py
+++ b/osdfapp.py
@@ -45,8 +45,10 @@ 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.models.api.pciOptimizationRequest import PCIOptimizationAPI
from osdf.operation.responses import osdf_response_for_request_accept as req_accept
from osdf.optimizers.routeopt.simple_route_opt import RouteOpt
+from osdf.optimizers.pciopt.pci_opt_processor import process_pci_optimation
ERROR_TEMPLATE = osdf.ERROR_TEMPLATE
@@ -158,6 +160,23 @@ def do_route_calc():
else:
return RouteOpt.getRoute(request_json)
+@app.route("/api/oof/v1/pci", methods=["POST"])
+@auth_basic.login_required
+def do_pci_optimization():
+ request_json = request.get_json()
+ 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)))
+ PCIOptimizationAPI(request_json).validate()
+ policies = get_policies(request_json, "pciopt")
+ audit_log.info(MH.new_worker_thread(req_id, "[for pciopt]"))
+ t = Thread(target=process_pci_optimation, args=(request_json, policies, osdf_config))
+ t.start()
+ audit_log.info(MH.accepted_valid_request(req_id, request))
+ 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):
"""Returned when unexpected coding errors occur during initial synchronous processing"""