List of canidate identifiers support 77/92177/1
authorLukasz Rajewski <lukasz.rajewski@orange.com>
Mon, 29 Jul 2019 08:48:35 +0000 (10:48 +0200)
committerLukasz Rajewski <lukasz.rajewski@orange.com>
Mon, 29 Jul 2019 08:51:51 +0000 (10:51 +0200)
List of candidate identifers in required and excluded
candidates list now is supported only as a list

Issue-ID: OPTFRA-486
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Change-Id: I1628a5806ff1faecabc9c94507621e786a622f2c

conductor/conductor/data/plugins/inventory_provider/aai.py
conductor/conductor/tests/unit/data/demands_vfmodule.json
conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py
conductor/conductor/tests/unit/data/plugins/inventory_provider/vfmodule_demand_list.json
conductor/conductor/tests/unit/data/test_service.py

index d6fb724..b69655c 100644 (file)
@@ -1904,11 +1904,16 @@ class AAI(base.InventoryProviderBase):
             for list_candidate in candidates_list:
                 if list_candidate \
                         and list_candidate.get('inventory_type') \
-                        == candidate.get('inventory_type') \
-                        and list_candidate.get('candidate_id') \
-                        == candidate.get('candidate_id'):
-                    has_candidate = True
-                    break
+                        == candidate.get('inventory_type'):
+                    if isinstance(list_candidate.get('candidate_id'), list):
+                        for candidate_id in list_candidate.get('candidate_id'):
+                            if candidate_id == candidate.get('candidate_id'):
+                                has_candidate = True
+                                break
+                    else:
+                        raise Exception("Invalid candidate id list format")
+                    if has_candidate:
+                        break
 
         if not exclude:
             if not has_candidate:
index 78cb7d4..b696083 100644 (file)
@@ -7,7 +7,7 @@
             "vlan_key": "vlan_key",
             "port_key": "vlan_port",
             "excluded_candidates": [{
-                "candidate_id": "e765d576-8755-4145-8536-0bb6d9b1dc9a",
+                "candidate_id": ["e765d576-8755-4145-8536-0bb6d9b1dc9a"],
                 "inventory_type": "vfmodule"
             }],
             "attributes": {
index 906897c..d77b644 100644 (file)
@@ -621,7 +621,10 @@ tenant/3c6c471ada7747fe8ff7f28e100b61e8/vservers/vserver/00bddefc-126e-4e4f-a18d
 
         candidate_list_empty = list()
         candidate_list = list()
-        candidate_list.append(candidate)
+        candidate_info = copy.deepcopy(candidate)
+        candidate_info['candidate_id'] = list()
+        candidate_info['candidate_id'].append(candidate['candidate_id'])
+        candidate_list.append(candidate_info)
 
         self.assertFalse(self.aai_ep.match_candidate_by_list(candidate, candidate_list_empty, True, 'demand',
                                                              triage_translator_data)),
index c8ddc9e..8069e0f 100644 (file)
             "cloud-region-id": "RegionOne",
             "service_instance_id": "3e8d118c-10ca-4b4b-b3db-089b5e9e6a1c"
         },
-        "service_type": "vPGN-XX"
+        "service_type": "vPGN-XX",
+        "excluded_candidates": [{
+            "inventory_type": "vfmodule",
+            "candidate_id": ["e765d576-8755-4145-8536-0bb6d9b1dc9a"]
+        }]
     }]
 }
\ No newline at end of file
index 3f010db..3a5ca72 100644 (file)
@@ -255,7 +255,7 @@ class TestDataEndpoint(unittest.TestCase):
                           'resolved_demands': [{'service_resource_id': 'vFW-SINK-XX', 'vlan_key': 'vlan_key',
                                                 'inventory_provider': 'aai', 'inventory_type': 'vfmodule',
                                                 'excluded_candidates': [
-                                                    {'candidate_id': 'e765d576-8755-4145-8536-0bb6d9b1dc9a',
+                                                    {'candidate_id': ['e765d576-8755-4145-8536-0bb6d9b1dc9a'],
                                                      'inventory_type': 'vfmodule'
                                                      }], 'port_key': 'vlan_port', 'service_type': 'vFW-SINK-XX',
                                                 'attributes': {'global-customer-id': 'Demonstration',