Changes while processing optimation policy 87/67887/1
authorChayal, Avteet (ac229e) <ac229e@att.com>
Wed, 19 Sep 2018 20:48:25 +0000 (20:48 +0000)
committerChayal, Avteet (ac229e) <ac229e@att.com>
Wed, 19 Sep 2018 20:51:45 +0000 (20:51 +0000)
Generalize the logic that fetches the "parameter" and
"resource" fields while processing optimization policy

Issue-ID: OPTFRA-354

Change-Id: Ic84f837b63d430a9adabf4a17d0b396ff1e8ac54
Signed-off-by: Chayal, Avteet (ac229e) <ac229e@att.com>
osdf/optimizers/placementopt/conductor/translation.py

index 6e42ba2..76cbabd 100644 (file)
@@ -54,12 +54,13 @@ def gen_optimization_policy(vnf_list, optimization_policy):
     for policy in optimization_policy:
         content = policy['content']
         parameter_list = []
+        parameters = ["cloud_version"]
 
         for attr in content['objectiveParameter']['parameterAttributes']:
-            parameter = attr['parameter'] if attr['parameter'] == "cloud_version" else attr['parameter']+"_between"
+            parameter = attr['parameter'] if attr['parameter'] in parameters else attr['parameter']+"_between"
             vnfs = get_matching_vnfs(attr['resources'], vnf_list)
             for vnf in vnfs:
-                value = [vnf] if attr['parameter'] == "cloud_version" else [attr['customerLocationInfo'], vnf]
+                value = [vnf] if attr['parameter'] in parameters else [attr['customerLocationInfo'], vnf]
                 parameter_list.append({
                     attr['operator']: [attr['weight'], {parameter: value}]
                 })