vfclcm upgrade from python2 to python3
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf / biz / scale_vnf_to_level.py
index 03189e9..eff83b4 100644 (file)
@@ -16,8 +16,11 @@ import logging
 
 from lcm.nf.biz.scale_vnf import ScaleVnf
 from lcm.nf.const import GRANT_TYPE
+from lcm.nf.const import OPERATION_TYPE
+from lcm.nf.const import OPERATION_TASK
 from lcm.pub.database.models import VmInstModel
 from lcm.pub.exceptions import NFLCMException
+from .operate_vnf_lcm_op_occ import VnfLcmOpOcc
 
 logger = logging.getLogger(__name__)
 
@@ -28,6 +31,13 @@ class ScaleVnfToLevel(ScaleVnf):
                                               nf_inst_id=nf_inst_id,
                                               job_id=job_id)
         self.aspect_id = ''
+        self.lcm_op_occ = VnfLcmOpOcc(
+            vnf_inst_id=nf_inst_id,
+            lcm_op_id=job_id,
+            operation=OPERATION_TYPE.SCALE_TO_LEVEL,
+            task=OPERATION_TASK.SCALE_TO_LEVEL
+        )
+        self.op_type = OPERATION_TYPE.SCALE_TO_LEVEL
 
     def scale_pre(self):
         self.vnfd_info = json.loads(self.vnf_insts[0].vnfd_model)
@@ -76,7 +86,7 @@ class ScaleVnfToLevel(ScaleVnf):
             if policy.get("type") != "tosca.policies.nfv.InstantiationLevels":
                 continue
             levels = policy["properties"]["levels"]
-            for level_id, level_info in levels.items():
+            for level_id, level_info in list(levels.items()):
                 scale_aspect = level_info["scale_info"].get(self.aspect_id)
                 scale_level_in_vnfd = scale_aspect["scale_level"]
                 if scale_level_in_request == scale_level_in_vnfd:
@@ -89,5 +99,5 @@ class ScaleVnfToLevel(ScaleVnf):
                 continue
             levels = policy["properties"]["levels"]
             level_info = levels.get(self.instantiation_level_id)
-            return level_info.get("scale_info").keys()[0]
+            return list(level_info.get("scale_info").keys())[0]
         raise NFLCMException("Failed to get aspect_id in vnfd")