Fix the oof-osdf to configdb interface bugs 96/88496/1 1.3.1
authorvrvarma <vv8305@att.com>
Fri, 24 May 2019 20:36:10 +0000 (16:36 -0400)
committervrvarma <vv8305@att.com>
Fri, 24 May 2019 20:36:21 +0000 (16:36 -0400)
Change-Id: I41ce7210f108195a83a35db46094e27a88f239fb
Signed-off-by: vrvarma <vv8305@att.com>
Issue-ID: OPTFRA-508

osdf/optimizers/pciopt/configdb.py
osdf/optimizers/pciopt/solver/optimizer.py
osdf/optimizers/pciopt/solver/pci_utils.py
test/functest/simulators/configdb/response-payloads/getNbrList-cell0.json
test/functest/simulators/configdb/response-payloads/getNbrList-cell1.json
test/functest/simulators/configdb/response-payloads/getNbrList-cell2.json
test/functest/simulators/configdb/response-payloads/getNbrList-cell20.json
test/functest/simulators/configdb/response-payloads/getNbrList-cell21.json
test/functest/simulators/configdb/response-payloads/getNbrList-cell22.json
test/functest/simulators/configdb/response-payloads/getNbrList-cell23.json
test/functest/simulators/configdb/response-payloads/getNbrList-cell24.json

index 0e76884..8f003c2 100644 (file)
@@ -57,9 +57,13 @@ def request(req_object, osdf_config, flat_policies):
         cell_info = {'cell_id': cell_id, 'id': count}
         nbr_list_url = '{}/{}/{}/{}'.format(config['configDbUrl'], config['configDbGetNbrListUrl'], cell_id, ts)
         nbr_list_raw = rc.request(url=nbr_list_url, raw_response=True)
-        cell_info['nbr_list'] = nbr_list_raw.json()
+        cell_info['nbr_list'] = get_neighbor_list(nbr_list_raw.json())
         cell_list.append(cell_info)
         count += 1
 
     cell_list_response['cell_list'] = cell_list
     return cell_resp, cell_list_response
+
+
+def get_neighbor_list(nbr_list_response):
+    return nbr_list_response.get('nbrList', [])
index 9b2e9d9..0a6d5a4 100644 (file)
@@ -103,7 +103,7 @@ def get_neighbor_list(network_cell_info):
 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'])
+        nbr_id = get_id(network_cell_info, nbr['targetCellId'])
         if nbr_id and host_id != nbr_id:
             neighbor_list.add((host_id, nbr_id))
 
@@ -121,7 +121,7 @@ def get_second_level_neighbor(network_cell_info):
 def build_second_level_list(network_cell_info, cell):
     second_nbr_list = []
     for nbr in cell.get('nbr_list', []):
-        second_nbr_list.append(get_id(network_cell_info, nbr['cellId']))
+        second_nbr_list.append(get_id(network_cell_info, nbr['targetCellId']))
     return [list(elem) for elem in list(itertools.combinations(second_nbr_list, 2))]
 
 
index df46d1b..04829cf 100644 (file)
@@ -35,6 +35,6 @@ 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']:
         for j in i['nbr_list']:
-            if cell_id == j['cellId']:
+            if cell_id == j['targetCellId']:
                 return j['pciValue']
     return None
index e0986d8..ff291fb 100644 (file)
@@ -1,10 +1,15 @@
-[
-  {
-    "cellId": "cell1",
-    "pciValue": 1
-  },
-  {
-    "cellId": "cell2",
-    "pciValue": 2
-  }
-]
\ No newline at end of file
+{
+  "cellId": "cell0",
+  "nbrList": [
+    {
+      "targetCellId": "cell1",
+      "pciValue": 1,
+      "ho": true
+    },
+    {
+      "targetCellId": "cell2",
+      "pciValue": 2,
+      "ho": true
+    }
+  ]
+}
\ No newline at end of file
index d6ed353..3c487e8 100644 (file)
@@ -1,10 +1,15 @@
-[
-  {
-    "cellId": "cell0",
-    "pciValue": 0
-  },
-  {
-    "cellId": "cell2",
-    "pciValue": 2
-  }
-]
\ No newline at end of file
+{
+  "cellId": "cell1",
+  "nbrList": [
+    {
+      "targetCellId": "cell0",
+      "pciValue": 0,
+      "ho": true
+    },
+    {
+      "targetCellId": "cell2",
+      "pciValue": 2,
+      "ho": true
+    }
+  ]
+}
\ No newline at end of file
index 1ea80be..20a8c98 100644 (file)
@@ -1,10 +1,15 @@
-[
-  {
-    "cellId": "cell0",
-    "pciValue": 0
-  },
-  {
-    "cellId": "cell1",
-    "pciValue": 1
-  }
-]
\ No newline at end of file
+{
+  "cellId": "cell2",
+  "nbrList": [
+    {
+      "targetCellId": "cell0",
+      "pciValue": 0,
+      "ho": true
+    },
+    {
+      "targetCellId": "cell1",
+      "pciValue": 1,
+      "ho": true
+    }
+  ]
+}
\ No newline at end of file
index 86c7d2c..d4e754f 100644 (file)
@@ -1,14 +1,20 @@
-[
-  {
-    "cellId": "cell21",
-    "pciValue": 0
-  },
-  {
-    "cellId": "cell22",
-    "pciValue": 1
-  },
-  {
-    "cellId": "cell23",
-    "pciValue": 2
-  }
-]
\ No newline at end of file
+{
+  "cellId": "cell20",
+  "nbrList": [
+    {
+      "targetCellId": "cell21",
+      "pciValue": 0,
+      "ho": true
+    },
+    {
+      "targetCellId": "cell22",
+      "pciValue": 1,
+      "ho": true
+    },
+    {
+      "targetCellId": "cell23",
+      "pciValue": 2,
+      "ho": true
+    }
+  ]
+}
\ No newline at end of file
index 490c15f..a1d6f55 100644 (file)
@@ -1,6 +1,10 @@
-[
-  {
-    "cellId": "cell20",
-    "pciValue":0
-  }
-]
\ No newline at end of file
+{
+  "cellId": "cell21",
+  "nbrList": [
+    {
+      "targetCellId": "cell20",
+      "pciValue": 0,
+      "ho": true
+    }
+  ]
+}
\ No newline at end of file
index 426e13b..9c16aec 100644 (file)
@@ -1,6 +1,10 @@
-[
-  {
-    "cellId": "cell20",
-    "pciValue": 0
-  }
-]
\ No newline at end of file
+{
+  "cellId": "cell22",
+  "nbrList": [
+    {
+      "targetCellId": "cell20",
+      "pciValue": 0,
+      "ho": true
+    }
+  ]
+}
\ No newline at end of file
index de582eb..ac3bf6f 100644 (file)
@@ -1,6 +1,10 @@
-[
-  {
-    "cellId": "cell24",
-    "pciValue": 0
-  }
-]
\ No newline at end of file
+{
+  "cellId": "cell23",
+  "nbrList": [
+    {
+      "targetCellId": "cell24",
+      "pciValue": 0,
+      "ho": true
+    }
+  ]
+}
\ No newline at end of file
index 8d8d3fb..f34128e 100644 (file)
@@ -1,6 +1,10 @@
-[
-  {
-    "cellId": "cell23",
-    "pciValue": 2
-  }
-]
\ No newline at end of file
+{
+  "cellId": "cell24",
+  "nbrList": [
+    {
+      "targetCellId": "cell23",
+      "pciValue": 2,
+      "ho": true
+    }
+  ]
+}
\ No newline at end of file