diff options
author | Dileep Ranganathan <dileep.ranganathan@intel.com> | 2018-04-04 04:53:43 -0700 |
---|---|---|
committer | Dileep Ranganathan <dileep.ranganathan@intel.com> | 2018-04-06 03:15:27 -0700 |
commit | b54b9a32922943c5aa7e1f28bfedcc04ba475e99 (patch) | |
tree | 153b259bf40c175d5b7c1d9bb85a6297448a8863 /conductor | |
parent | 68b2d33d8e202afca035a6bb9b1c63227c44d7e7 (diff) |
Fixed HPA matching when no flavor is found
When no matching flavor is found the candidate list
should be discarded and the solution should be not_found.
Refactored the logic if there is already flavor_mapping.
Change-Id: I24ea91436a5a5c78698801f435a6deb9e9d447e9
Issue-ID: OPTFRA-213
Signed-off-by: Dileep Ranganathan <dileep.ranganathan@intel.com>
Diffstat (limited to 'conductor')
-rw-r--r-- | conductor/conductor/data/service.py | 3 | ||||
-rw-r--r-- | conductor/conductor/solver/optimizer/constraints/hpa.py | 11 | ||||
-rw-r--r-- | conductor/conductor/tests/unit/solver/test_hpa.py | 6 |
3 files changed, 10 insertions, 10 deletions
diff --git a/conductor/conductor/data/service.py b/conductor/conductor/data/service.py index 5912963..f4e3aac 100644 --- a/conductor/conductor/data/service.py +++ b/conductor/conductor/data/service.py @@ -454,10 +454,9 @@ class DataEndpoint(object): # exists. This is an invalid condition. if candidate.get("flavor_map") and candidate["flavor_map"].get( label_name): - error = True LOG.error(_LE("Flavor mapping for label name {} already" "exists").format(label_name)) - return {'response': None, 'error': error} + continue # RPC call to inventory provider for matching hpa capabilities results = self.ip_ext_manager.map_method( diff --git a/conductor/conductor/solver/optimizer/constraints/hpa.py b/conductor/conductor/solver/optimizer/constraints/hpa.py index 9ef37df..98d95d9 100644 --- a/conductor/conductor/solver/optimizer/constraints/hpa.py +++ b/conductor/conductor/solver/optimizer/constraints/hpa.py @@ -59,10 +59,11 @@ class HPA(constraint.Constraint): response = (cei.get_candidates_with_hpa(label_name, _candidate_list, flavorProperties)) - if response: - _candidate_list = response - else: - LOG.error(_LE("Flavor mapping for label name {} already" - "exists").format(label_name)) + _candidate_list = response + if not response: + LOG.error(_LE("No matching candidates for HPA exists").format( + label_name)) + break + # No need to continue. return _candidate_list diff --git a/conductor/conductor/tests/unit/solver/test_hpa.py b/conductor/conductor/tests/unit/solver/test_hpa.py index c9bbbbc..3964c06 100644 --- a/conductor/conductor/tests/unit/solver/test_hpa.py +++ b/conductor/conductor/tests/unit/solver/test_hpa.py @@ -77,9 +77,9 @@ class TestHPA(unittest.TestCase): client_mock.call.return_value = None request_mock.cei = cei.ConstraintEngineInterface(client_mock) - self.assertEqual(self.candidate_list, - self.hpa.solve(mock_decision_path, - self.candidate_list, request_mock)) + self.assertEqual(None, self.hpa.solve(mock_decision_path, + self.candidate_list, + request_mock)) client_mock.call.side_effect = [hpa_candidate_list_1, hpa_candidate_list_2] |