diff options
author | Dileep Ranganathan <dileep.ranganathan@intel.com> | 2018-09-26 16:54:02 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-09-26 16:54:02 +0000 |
commit | e93d457429f0cb5eb01c5a5ec78c912c1e911a9a (patch) | |
tree | d31b6adf1e3c34e69145d1246b4396aa43cd9d58 /osdf | |
parent | ab35ab7d3c95b8c54ae443085277519388cef384 (diff) | |
parent | e7199cef05b7bad04f3ec2b7815423d5d07aa642 (diff) |
Merge "Disabling policy retrieval for pci opt"
Diffstat (limited to 'osdf')
-rwxr-xr-x | osdf/__init__.py | 1 | ||||
-rw-r--r-- | osdf/optimizers/pciopt/pci_opt_processor.py | 49 |
2 files changed, 31 insertions, 19 deletions
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 |