diff options
author | Ruoyu Ying <ruoyu.ying@intel.com> | 2019-01-11 20:33:18 +0800 |
---|---|---|
committer | Ruoyu Ying <ruoyu.ying@intel.com> | 2019-01-11 20:36:09 +0800 |
commit | 1e635c3ce0efe9592be2ea5d6a70d8b75301b7ad (patch) | |
tree | 5e0d65c2000b6aceee0e49725a127cdc9320cbeb | |
parent | 264341d5466c2b5e690be727839d806826b90915 (diff) |
Check flavor exist before hpa matching
Check whether there is flavor info inside the candidate.
If exists, continue to the hpa matching.
Change-Id: I72762d90050ee35fea672cd06c038f2b6382f730
Signed-off-by: Ruoyu Ying <ruoyu.ying@intel.com>
Issue-ID: OPTFRA-412
-rw-r--r-- | conductor/conductor/data/plugins/inventory_provider/aai.py | 5 | ||||
-rw-r--r-- | conductor/conductor/data/plugins/inventory_provider/hpa_utils.py | 12 |
2 files changed, 15 insertions, 2 deletions
diff --git a/conductor/conductor/data/plugins/inventory_provider/aai.py b/conductor/conductor/data/plugins/inventory_provider/aai.py index f37a40a..bde5b03 100644 --- a/conductor/conductor/data/plugins/inventory_provider/aai.py +++ b/conductor/conductor/data/plugins/inventory_provider/aai.py @@ -1607,7 +1607,10 @@ class AAI(base.InventoryProviderBase): def match_hpa(self, candidate, features): """Match HPA features requirement with the candidate flavors """ hpa_provider = hpa_utils.HpaMatchProvider(candidate, features) - directives = hpa_provider.match_flavor() + if hpa_provider.init_verify(): + directives = hpa_provider.match_flavor() + else: + directives = None return directives diff --git a/conductor/conductor/data/plugins/inventory_provider/hpa_utils.py b/conductor/conductor/data/plugins/inventory_provider/hpa_utils.py index 84d4c87..8af2e36 100644 --- a/conductor/conductor/data/plugins/inventory_provider/hpa_utils.py +++ b/conductor/conductor/data/plugins/inventory_provider/hpa_utils.py @@ -53,10 +53,20 @@ def match_all_operator(big_list, small_list): class HpaMatchProvider(object): def __init__(self, candidate, req_cap_list): - self.flavors_list = candidate['flavors']['flavor'] + self.flavors_list = None + if isinstance(candidate.get('flavors'), dict) \ + and candidate.get('flavors').get('flavor'): + self.flavors_list = candidate.get('flavors').get('flavor') self.req_cap_list = req_cap_list self.m_vim_id = candidate.get('vim-id') + # Find out whether there is flavor info inside the candidate + def init_verify(self): + if self.flavors_list is not None: + return True + else: + return False + # Find the flavor which has all the required capabilities def match_flavor(self): # Keys to find capability match |