From e7199cef05b7bad04f3ec2b7815423d5d07aa642 Mon Sep 17 00:00:00 2001 From: "Varma, Vikas" Date: Wed, 19 Sep 2018 18:38:26 -0400 Subject: Disabling policy retrieval for pci opt Fixing the pci optimization response. Disable policy retrieval until the policies are loaded. Fix merge issues with optfapp.py Change-Id: I2acb82aac1cd6d154abf37f58755016bc377e475 Signed-off-by: Varma, Vikas Issue-ID: OPTFRA-342 --- osdf/__init__.py | 1 + osdf/optimizers/pciopt/pci_opt_processor.py | 49 ++++++++++++++++++----------- 2 files changed, 31 insertions(+), 19 deletions(-) (limited to 'osdf') diff --git a/osdf/__init__.py b/osdf/__init__.py index 5d15a85..c33639e 100755 --- a/osdf/__init__.py +++ b/osdf/__init__.py @@ -24,6 +24,7 @@ from jinja2 import Template end_point_auth_mapping = { # map a URL endpoint to auth group "cmscheduler": "CMScheduler", "placement": "Placement", + "pci": "PCIOpt" } userid_suffix, passwd_suffix = "Username", "Password" diff --git a/osdf/optimizers/pciopt/pci_opt_processor.py b/osdf/optimizers/pciopt/pci_opt_processor.py index 030128e..989f578 100644 --- a/osdf/optimizers/pciopt/pci_opt_processor.py +++ b/osdf/optimizers/pciopt/pci_opt_processor.py @@ -20,7 +20,6 @@ import traceback from requests import RequestException from osdf.logging.osdf_logging import metrics_log, MH, error_log -from osdf.models.api.pciOptimizationResponse import PCIOptimizationResponse, Solution, PCISolution 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 @@ -44,26 +43,9 @@ def process_pci_optimation(request_json, osdf_config, flat_policies): try: rc = get_rest_client(request_json, service="pcih") req_id = request_json["requestInfo"]["requestId"] - transaction_id = request_json['requestInfo']['transactionId'] cell_info_list, network_cell_info = config_request(request_json, osdf_config, flat_policies) - pci_response = PCIOptimizationResponse() - pci_response.transactionId = transaction_id - pci_response.requestId = req_id - pci_response.requestStatus = 'success' - pci_response.solutions = Solution() - pci_response.solutions.networkId = request_json['cellInfo']['networkId'] - pci_response.solutions.pciSolutions = [] - - for cell in request_json['cellInfo']['cellIdList']: - pci_solution = optimize(cell['cellId'], network_cell_info, cell_info_list) - error_log.error(pci_solution) - sol = pci_solution[0]['pci'] - for k, v in sol.items(): - response = PCISolution() - response.cellId = get_cell_id(network_cell_info, k) - response.pci = get_pci_value(network_cell_info, v) - pci_response.solutions.pciSolutions.append(response) + pci_response = get_solutions(cell_info_list, network_cell_info, request_json) metrics_log.info(MH.inside_worker_thread(req_id)) except Exception as err: @@ -82,3 +64,32 @@ def process_pci_optimation(request_json, osdf_config, flat_policies): 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())) + + +def get_solutions(cell_info_list, network_cell_info, request_json): + return { + "transactionId": request_json['requestInfo']['transactionId'], + "requestId": request_json["requestInfo"]["requestId"], + "requestStatus": "completed", + "statusMessage": "success", + "solutions": [ + { + 'networkId': request_json['cellInfo']['networkId'], + 'pciSolutions': build_solution_list(cell_info_list, network_cell_info, request_json) + } + ] + } + + +def build_solution_list(cell_info_list, network_cell_info, request_json): + solution_list = [] + for cell in request_json['cellInfo']['cellIdList']: + opt_solution = optimize(cell, network_cell_info, cell_info_list) + sol = opt_solution[0]['pci'] + for k, v in sol.items(): + response = { + 'cellId': get_cell_id(network_cell_info, k), + 'pci': get_pci_value(network_cell_info, v) + } + solution_list.append(response) + return solution_list -- cgit 1.2.3-korg