summaryrefslogtreecommitdiffstats
path: root/apps/pci/optimizers/pci_opt_processor.py
diff options
context:
space:
mode:
authorkrishnaa96 <krishna.moorthy6@wipro.com>2021-07-20 11:44:26 +0530
committerkrishnaa96 <krishna.moorthy6@wipro.com>2021-07-20 14:38:09 +0530
commitf90e03c6a749ee25df3ac74355981861d59160d0 (patch)
tree400b9f6b2ef6a07b1dbb4ebeeb58e8c026e00a45 /apps/pci/optimizers/pci_opt_processor.py
parent555e5727d1c818108ff255a1b9fe4542b768ad5c (diff)
Add cps client to PCI app
- Add CPS client - Add configuration to switch between CPS and config DB Issue-ID: OPTFRA-978 Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com> Change-Id: Ibce259123864a16e5f9e3b8e53563151d8036a88
Diffstat (limited to 'apps/pci/optimizers/pci_opt_processor.py')
-rw-r--r--apps/pci/optimizers/pci_opt_processor.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/apps/pci/optimizers/pci_opt_processor.py b/apps/pci/optimizers/pci_opt_processor.py
index 01ae0b4..a58d2f4 100644
--- a/apps/pci/optimizers/pci_opt_processor.py
+++ b/apps/pci/optimizers/pci_opt_processor.py
@@ -21,12 +21,15 @@ import traceback
from onaplogging.mdcContext import MDC
from requests import RequestException
-from osdf.logging.osdf_logging import metrics_log, MH, error_log
+from apps.pci.optimizers.config_request import request as config_request
+from apps.pci.optimizers.solver.optimizer import pci_optimize as optimize
+from apps.pci.optimizers.solver.pci_utils import get_cell_id
+from apps.pci.optimizers.solver.pci_utils import get_pci_value
+from osdf.logging.osdf_logging import error_log
+from osdf.logging.osdf_logging import metrics_log
+from osdf.logging.osdf_logging import MH
from osdf.operation.error_handling import build_json_error_body
from osdf.utils.interfaces import get_rest_client
-from .configdb import request as config_request
-from .solver.optimizer import pci_optimize as optimize
-from .solver.pci_utils import get_cell_id, get_pci_value
from osdf.utils.mdc_utils import mdc_from_json
"""
@@ -36,8 +39,8 @@ and Policy.
def process_pci_optimation(request_json, osdf_config, flat_policies):
- """
- Process a PCI request from a Client (build config-db, policy and API call, make the call, return result)
+ """Process a PCI request from a Client (build config-db, policy and API call, make the call, return result)
+
:param req_object: Request parameters from the client
:param osdf_config: Configuration specific to OSDF application (core + deployment)
:param flat_policies: policies related to pci (fetched based on request)
@@ -58,14 +61,14 @@ def process_pci_optimation(request_json, osdf_config, flat_policies):
body = build_json_error_body(err)
metrics_log.info(MH.sending_response(req_id, "ERROR"))
rc.request(json=body, noresponse=True)
- except RequestException as err:
- MDC.put('requestID',req_id)
+ except RequestException:
+ MDC.put('requestID', req_id)
error_log.error("Error sending asynchronous notification for {} {}".format(req_id, traceback.format_exc()))
raise err
-
try:
metrics_log.info(MH.calling_back_with_body(req_id, rc.url, pci_response))
+ error_log.error("pci response: {}".format(str(pci_response)))
rc.request(json=pci_response, noresponse=True)
except RequestException: # can't do much here but log it and move on
error_log.error("Error sending asynchronous notification for {} {}".format(req_id, traceback.format_exc()))
@@ -89,11 +92,11 @@ def get_solutions(cell_info_list, network_cell_info, request_json):
def build_solution_list(cell_info_list, network_cell_info, request_json):
status = "success"
req_id = request_json["requestInfo"]["requestId"]
- pci_solutions =[]
- anr_solutions=[]
+ pci_solutions = []
+ anr_solutions = []
try:
opt_solution = optimize(network_cell_info, cell_info_list, request_json)
- if opt_solution == 'UNSATISFIABLE':
+ if opt_solution == 'UNSATISFIABLE':
status = 'inconsistent input'
return status, pci_solutions, anr_solutions
else: