summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfig/osdf_config.yaml4
-rwxr-xr-xosdf/__init__.py1
-rw-r--r--osdf/optimizers/pciopt/pci_opt_processor.py49
-rwxr-xr-xosdfapp.py6
-rw-r--r--test/pci-optimization-tests/request.json4
5 files changed, 40 insertions, 24 deletions
diff --git a/config/osdf_config.yaml b/config/osdf_config.yaml
index 636b6ad..c484fb4 100755
--- a/config/osdf_config.yaml
+++ b/config/osdf_config.yaml
@@ -81,3 +81,7 @@ configDbGetNbrListUrl: 'SDNCConfigDBAPI/getNbrList'
# Credentials for PCIHandler
pciHMSUsername: "" # pcihandler username for call back.
pciHMSPassword: "" # pcihandler password for call back.
+
+# Credentials for the OOF PCI Opt service
+osdfPCIOptUsername: pci_test
+osdfPCIOptPassword: pci_testpwd
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
diff --git a/osdfapp.py b/osdfapp.py
index def15d7..c28e14c 100755
--- a/osdfapp.py
+++ b/osdfapp.py
@@ -155,15 +155,17 @@ def do_pci_optimization():
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")
+ #disable policy retrieval
+ # 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 = Thread(target=process_pci_optimation, args=(request_json, osdf_config, None))
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"""
diff --git a/test/pci-optimization-tests/request.json b/test/pci-optimization-tests/request.json
index 79c98c3..7ec9ab5 100644
--- a/test/pci-optimization-tests/request.json
+++ b/test/pci-optimization-tests/request.json
@@ -14,9 +14,7 @@
"cellInfo": {
"networkId": "1000",
"cellIdList": [
- {
- "cellId": "cell0"
- }
+ "cell0"
]
}
} \ No newline at end of file