Fixing the HPA parameters from Homing Template 97/39297/4
authorDileep Ranganathan <dileep.ranganathan@intel.com>
Tue, 27 Mar 2018 14:07:53 +0000 (07:07 -0700)
committerDileep Ranganathan <dileep.ranganathan@intel.com>
Wed, 28 Mar 2018 12:53:28 +0000 (05:53 -0700)
Fixed the label to flavorLabel
Fixed the features to flavorProperties

Change-Id: I157afbf5969e9434c29de21c6041e9ede7b511af
Issue-ID: OPTFRA-170
Signed-off-by: Dileep Ranganathan <dileep.ranganathan@intel.com>
conductor/conductor/data/service.py
conductor/conductor/solver/optimizer/constraints/hpa.py
conductor/conductor/solver/utils/constraint_engine_interface.py
conductor/conductor/tests/unit/data/hpa_constraints.json
conductor/conductor/tests/unit/data/test_service.py
conductor/conductor/tests/unit/solver/hpa_constraints.json

index 4948656..5912963 100644 (file)
@@ -443,7 +443,7 @@ class DataEndpoint(object):
         error = False
         candidate_list = arg["candidate_list"]
         label_name = arg["label_name"]
-        features = arg["features"]
+        flavorProperties = arg["flavorProperties"]
         discard_set = set()
         for candidate in candidate_list:
             # perform this check only for cloud candidates
@@ -463,7 +463,7 @@ class DataEndpoint(object):
             results = self.ip_ext_manager.map_method(
                 'match_hpa',
                 candidate=candidate,
-                features=features
+                features=flavorProperties
             )
 
             if results and len(results) > 0:
index a7e8d3c..9ef37df 100644 (file)
@@ -54,11 +54,11 @@ class HPA(constraint.Constraint):
             self.constraint_type, demand_name))
         vm_label_list = self.properties.get('evaluate')
         for vm_demand in vm_label_list:
-            label_name = vm_demand['label']
-            features = vm_demand['features']
+            label_name = vm_demand['flavorLabel']
+            flavorProperties = vm_demand['flavorProperties']
             response = (cei.get_candidates_with_hpa(label_name,
                                                     _candidate_list,
-                                                    features))
+                                                    flavorProperties))
             if response:
                 _candidate_list = response
             else:
index a662425..43331aa 100644 (file)
@@ -117,18 +117,19 @@ class ConstraintEngineInterface(object):
         # response is a list of (candidate, cost) tuples
         return response
 
-    def get_candidates_with_hpa(self, label_name, candidate_list, features):
+    def get_candidates_with_hpa(self, label_name, candidate_list,
+                                flavorProperties):
         '''
         Returns the candidate_list with an addition of flavor_mapping for
         matching cloud candidates with hpa constraints.
         :param label_name: vm_label_name passed from the SO/Policy
         :param candidate_list: list of candidates to process
-        :param features: hpa features for this vm_label_name
+        :param flavorProperties: hpa features for this vm_label_name
         :return: candidate_list with hpa features and flavor mapping
         '''
         ctxt = {}
         args = {"candidate_list": candidate_list,
-                "features": features,
+                "flavorProperties": flavorProperties,
                 "label_name": label_name}
         response = self.client.call(ctxt=ctxt,
                                     method="get_candidates_with_hpa",
index 9139204..829eaf3 100644 (file)
@@ -9,7 +9,7 @@
           "properties": {
             "evaluate": [
               {
-                "features": [
+                "flavorProperties": [
                   {
                     "architecture": "generic",
                     "hpa-feature": "basicCapabilities",
                     "hpa-version": "v1"
                   }
                 ],
-                "label": "flavor_label_1"
+                "flavorLabel": "flavor_label_1"
               },
               {
-                "features": [
+                "flavorProperties": [
                   {
                     "architecture": "generic",
                     "hpa-feature": "basicCapabilities",
                     "hpa-version": "v1"
                   }
                 ],
-                "label": "flavor_label_2"
+                "flavorLabel": "flavor_label_2"
               }
             ]
           }
index 3f2adde..4b841de 100644 (file)
@@ -237,14 +237,14 @@ class TestDataEndpoint(unittest.TestCase):
         (constraint_id, constraint_info) = \
             hpa_json["conductor_solver"]["constraints"][0].items()[0]
         hpa_constraint = constraint_info['properties']
-        features = hpa_constraint['evaluate'][0]['features']
-        label_name = hpa_constraint['evaluate'][0]['label']
+        flavorProperties = hpa_constraint['evaluate'][0]['flavorProperties']
+        label_name = hpa_constraint['evaluate'][0]['flavorLabel']
         ext_mock1.return_value = ['aai']
         flavor_info = {"flavor-id": "vim-flavor-id1",
                        "flavor-name": "vim-flavor-name1"}
         hpa_mock.return_value = [flavor_info]
         self.maxDiff = None
-        args = generate_args(candidate_list, features, label_name)
+        args = generate_args(candidate_list, flavorProperties, label_name)
         hpa_candidate_list = copy.deepcopy(candidate_list)
         hpa_candidate_list[1]['flavor_map'] = {}
         hpa_candidate_list[1]['flavor_map'][label_name] = "vim-flavor-name1"
@@ -254,7 +254,7 @@ class TestDataEndpoint(unittest.TestCase):
 
         hpa_candidate_list2 = list()
         hpa_candidate_list2.append(copy.deepcopy(candidate_list[0]))
-        args = generate_args(candidate_list, features, label_name)
+        args = generate_args(candidate_list, flavorProperties, label_name)
         hpa_mock.return_value = []
         expected_response = {'response': hpa_candidate_list2, 'error': False}
         self.assertEqual(expected_response,
@@ -315,10 +315,10 @@ class TestDataEndpoint(unittest.TestCase):
                                                                        args))
 
 
-def generate_args(candidate_list, features, label_name):
+def generate_args(candidate_list, flavorProperties, label_name):
     arg_candidate_list = copy.deepcopy(candidate_list)
     args = {"candidate_list": arg_candidate_list,
-            "features": features,
+            "flavorProperties": flavorProperties,
             "label_name": label_name}
     return args
 
index 9139204..829eaf3 100644 (file)
@@ -9,7 +9,7 @@
           "properties": {
             "evaluate": [
               {
-                "features": [
+                "flavorProperties": [
                   {
                     "architecture": "generic",
                     "hpa-feature": "basicCapabilities",
                     "hpa-version": "v1"
                   }
                 ],
-                "label": "flavor_label_1"
+                "flavorLabel": "flavor_label_1"
               },
               {
-                "features": [
+                "flavorProperties": [
                   {
                     "architecture": "generic",
                     "hpa-feature": "basicCapabilities",
                     "hpa-version": "v1"
                   }
                 ],
-                "label": "flavor_label_2"
+                "flavorLabel": "flavor_label_2"
               }
             ]
           }