summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conductor/conductor/data/plugins/vim_controller/multicloud.py7
-rw-r--r--conductor/conductor/data/service.py2
-rw-r--r--conductor/conductor/tests/unit/data/candidate_list.json2
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/test_multicloud.py2
-rw-r--r--conductor/conductor/tests/unit/data/test_service.py21
5 files changed, 19 insertions, 15 deletions
diff --git a/conductor/conductor/data/plugins/vim_controller/multicloud.py b/conductor/conductor/data/plugins/vim_controller/multicloud.py
index cdc6cde..8eec9fa 100644
--- a/conductor/conductor/data/plugins/vim_controller/multicloud.py
+++ b/conductor/conductor/data/plugins/vim_controller/multicloud.py
@@ -129,15 +129,14 @@ class MULTICLOUD(base.VimControllerBase):
if body:
vims = body.get("VIMs")
- if vims:
- return vims
- else:
+ if vims is None:
LOG.error(_LE(
"Unable to get VIMs with cpu-{}, memory-{}, disk-{}")
.format(data['vCPU'],
data['Memory'],
data['Storage']))
- return None
+
+ return vims
else:
LOG.error(_LE("Unable to get VIMs from Multicloud with "
"requirement {}").format(data))
diff --git a/conductor/conductor/data/service.py b/conductor/conductor/data/service.py
index f4e3aac..e9d597b 100644
--- a/conductor/conductor/data/service.py
+++ b/conductor/conductor/data/service.py
@@ -518,7 +518,7 @@ class DataEndpoint(object):
vim_request
)
- if vims_result and len(vims_result) > 0:
+ if vims_result and len(vims_result) > 0 and vims_result[0] is not None:
vims_set = set(vims_result[0])
for candidate in candidate_list:
# perform this check only for cloud candidates
diff --git a/conductor/conductor/tests/unit/data/candidate_list.json b/conductor/conductor/tests/unit/data/candidate_list.json
index 789ab64..8a28622 100644
--- a/conductor/conductor/tests/unit/data/candidate_list.json
+++ b/conductor/conductor/tests/unit/data/candidate_list.json
@@ -39,7 +39,7 @@
"cloud_owner": "att-aic",
"cloud_region_version": "1.1",
"physical_location_id": "NYCNY55",
- "vim-id": "att-aic_DLLSTX55"
+ "vim-id": "att-aic_NYCNY55"
}
]
} \ No newline at end of file
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_multicloud.py b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_multicloud.py
index aacaab4..1f4013e 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_multicloud.py
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_multicloud.py
@@ -85,7 +85,7 @@ class TestMultiCloud(unittest.TestCase):
response.text = {"VIMs": []}
response.json.return_value = response.text
rest_mock.return_value = response
- self.assertEqual(None, self.mc_ep.check_vim_capacity(vim_request))
+ self.assertEqual([], self.mc_ep.check_vim_capacity(vim_request))
response.text = {"VIMs": None}
response.json.return_value = response.text
rest_mock.return_value = response
diff --git a/conductor/conductor/tests/unit/data/test_service.py b/conductor/conductor/tests/unit/data/test_service.py
index 4b841de..01c2ab3 100644
--- a/conductor/conductor/tests/unit/data/test_service.py
+++ b/conductor/conductor/tests/unit/data/test_service.py
@@ -295,22 +295,27 @@ class TestDataEndpoint(unittest.TestCase):
hpa_json["conductor_solver"]["constraints"][2].items()[0]
vim_request = constraint_info['properties']['request']
ctxt = {}
- args = {"candidate_list": candidate_list,
+ candidate_list_copy = list(copy.deepcopy(candidate_list))
+ args = {"candidate_list": [candidate_list_copy[1]],
"request": vim_request}
- vim_mock.return_value = ['att-aic_DLLSTX55']
- self.assertEqual({'response': candidate_list, 'error': False},
+ vim_mock.return_value = [['att-aic_NYCNY55']]
+ self.assertEqual({'response': [candidate_list[1]], 'error': False},
self.data_ep.get_candidates_with_vim_capacity(ctxt,
args))
- vim_mock.return_value = ['att-aic_NYCNY33']
- self.assertEqual({'response': [candidate_list[0]], 'error': False},
+ vim_mock.return_value = []
+ self.assertEqual({'response': [candidate_list[1]], 'error': True},
self.data_ep.get_candidates_with_vim_capacity(ctxt,
args))
- vim_mock.return_value = []
- self.assertEqual({'response': candidate_list, 'error': True},
+ vim_mock.return_value = [None]
+ self.assertEqual({'response': [candidate_list[1]], 'error': True},
self.data_ep.get_candidates_with_vim_capacity(ctxt,
args))
vim_mock.return_value = None
- self.assertEqual({'response': candidate_list, 'error': True},
+ self.assertEqual({'response': [candidate_list[1]], 'error': True},
+ self.data_ep.get_candidates_with_vim_capacity(ctxt,
+ args))
+ vim_mock.return_value = [[]]
+ self.assertEqual({'response': [], 'error': False},
self.data_ep.get_candidates_with_vim_capacity(ctxt,
args))