summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2019-07-29 10:48:35 +0200
committerLukasz Rajewski <lukasz.rajewski@orange.com>2019-07-29 10:51:51 +0200
commitd21350b31eb300b37c89c6dcc04a89229d34af87 (patch)
tree05063da99373f01b75adbbb08da4516ad65a69a7
parenteec1111aacc4d49e52acf7fa7fb7cf7640e42800 (diff)
List of canidate identifiers support
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
-rw-r--r--conductor/conductor/data/plugins/inventory_provider/aai.py15
-rw-r--r--conductor/conductor/tests/unit/data/demands_vfmodule.json2
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py5
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/vfmodule_demand_list.json6
-rw-r--r--conductor/conductor/tests/unit/data/test_service.py2
5 files changed, 21 insertions, 9 deletions
diff --git a/conductor/conductor/data/plugins/inventory_provider/aai.py b/conductor/conductor/data/plugins/inventory_provider/aai.py
index d6fb724..b69655c 100644
--- a/conductor/conductor/data/plugins/inventory_provider/aai.py
+++ b/conductor/conductor/data/plugins/inventory_provider/aai.py
@@ -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:
diff --git a/conductor/conductor/tests/unit/data/demands_vfmodule.json b/conductor/conductor/tests/unit/data/demands_vfmodule.json
index 78cb7d4..b696083 100644
--- a/conductor/conductor/tests/unit/data/demands_vfmodule.json
+++ b/conductor/conductor/tests/unit/data/demands_vfmodule.json
@@ -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": {
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py
index 906897c..d77b644 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py
@@ -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)),
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/vfmodule_demand_list.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/vfmodule_demand_list.json
index c8ddc9e..8069e0f 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/vfmodule_demand_list.json
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/vfmodule_demand_list.json
@@ -15,6 +15,10 @@
"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
diff --git a/conductor/conductor/tests/unit/data/test_service.py b/conductor/conductor/tests/unit/data/test_service.py
index 3f010db..3a5ca72 100644
--- a/conductor/conductor/tests/unit/data/test_service.py
+++ b/conductor/conductor/tests/unit/data/test_service.py
@@ -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',