aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--osdf/optimizers/pciopt/pci_opt_processor.py33
-rw-r--r--osdf/optimizers/pciopt/solver/optimizer.py7
-rw-r--r--osdf/optimizers/pciopt/solver/pci_utils.py1
3 files changed, 26 insertions, 15 deletions
diff --git a/osdf/optimizers/pciopt/pci_opt_processor.py b/osdf/optimizers/pciopt/pci_opt_processor.py
index f774b65..da87b83 100644
--- a/osdf/optimizers/pciopt/pci_opt_processor.py
+++ b/osdf/optimizers/pciopt/pci_opt_processor.py
@@ -17,6 +17,7 @@
#
import traceback
+
from requests import RequestException
from osdf.logging.osdf_logging import metrics_log, MH, error_log
@@ -66,15 +67,16 @@ def process_pci_optimation(request_json, osdf_config, flat_policies):
def get_solutions(cell_info_list, network_cell_info, request_json):
+ status, solutions = build_solution_list(cell_info_list, network_cell_info, request_json)
return {
"transactionId": request_json['requestInfo']['transactionId'],
"requestId": request_json["requestInfo"]["requestId"],
"requestStatus": "completed",
- "statusMessage": "success",
+ "statusMessage": status,
"solutions": [
{
'networkId': request_json['cellInfo']['networkId'],
- 'pciSolutions': build_solution_list(cell_info_list, network_cell_info, request_json)
+ 'pciSolutions': solutions
}
]
}
@@ -82,13 +84,20 @@ def get_solutions(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(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
+ status = "success"
+ req_id = request_json["requestInfo"]["requestId"]
+ try:
+ opt_solution = optimize(network_cell_info, cell_info_list)
+ sol = opt_solution[0]['pci']
+ for k, v in sol.items():
+ old_pci = get_pci_value(network_cell_info, k)
+ if old_pci != v:
+ response = {
+ 'cellId': get_cell_id(network_cell_info, k),
+ 'pci': v
+ }
+ solution_list.append(response)
+ except RuntimeError:
+ error_log.error("Failed finding solution for {} {}".format(req_id, traceback.format_exc()))
+ status = "failed"
+ return status, solution_list
diff --git a/osdf/optimizers/pciopt/solver/optimizer.py b/osdf/optimizers/pciopt/solver/optimizer.py
index 91e693c..5a1a5c2 100644
--- a/osdf/optimizers/pciopt/solver/optimizer.py
+++ b/osdf/optimizers/pciopt/solver/optimizer.py
@@ -64,7 +64,7 @@ def add_to_neighbor_list(network_cell_info, cell, neighbor_list):
for nbr in cell.get('nbr_list', []):
host_id = cell['id']
nbr_id = get_id(network_cell_info, nbr['cellId'])
- if host_id != nbr_id:
+ if nbr_id and host_id != nbr_id:
entry = sorted([host_id, nbr_id])
neighbor_list.add((entry[0], entry[1]))
@@ -74,8 +74,9 @@ def get_second_level_neighbor(network_cell_info):
for cell in network_cell_info['cell_list']:
comb_list = build_second_level_list(network_cell_info, cell)
for comb in comb_list:
- s = sorted(comb)
- second_neighbor_list.add((s[0], s[1]))
+ if comb[0] and comb[1]:
+ s = sorted(comb)
+ second_neighbor_list.add((s[0], s[1]))
return sorted(second_neighbor_list)
diff --git a/osdf/optimizers/pciopt/solver/pci_utils.py b/osdf/optimizers/pciopt/solver/pci_utils.py
index 71b5dd2..df46d1b 100644
--- a/osdf/optimizers/pciopt/solver/pci_utils.py
+++ b/osdf/optimizers/pciopt/solver/pci_utils.py
@@ -30,6 +30,7 @@ def get_cell_id(network_cell_info, id):
return i['cell_id']
return None
+
def get_pci_value(network_cell_info, id):
cell_id = get_cell_id(network_cell_info, id)
for i in network_cell_info['cell_list']: