fix NS update error 19/72619/2
authormaopengzhang <zhang.maopeng1@zte.com.cn>
Wed, 14 Nov 2018 09:00:07 +0000 (17:00 +0800)
committermaopengzhang <zhang.maopeng1@zte.com.cn>
Wed, 14 Nov 2018 11:47:00 +0000 (19:47 +0800)
fix  NS update error, STOPTYPE in NSLCM

Change-Id: I21f59c723723e45779206824fef6a6a99428a718
Issue-ID: VFC-1185
Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
lcm/ns/biz/ns_update.py
lcm/ns/serializers/update_serializers.py
lcm/ns/views/update_ns_view.py
lcm/ns_vnfs/biz/update_vnfs.py
lcm/pub/utils/jobutil.py

index cb00ced..eba18c6 100644 (file)
@@ -110,20 +110,18 @@ class NSUpdateService(threading.Thread):
         if not change_state_to:
             raise NSLCMException(
                 'ChangeStateTo does not exist or value is incorrect.')
-        Stop_Type = ''
         graceful_stop_timeout = ''
         operational_states = ignore_case_get(change_state_to, 'OperationalStates')
         if operational_states == OPERATIONAL_STATES.STOPPED:
             stop_type = ignore_case_get(vnf_data, 'stopType')
-            Stop_Type = ignore_case_get(stop_type, 'StopType')
-            if Stop_Type == STOP_TYPE.GRACEFUL:
+            if stop_type == STOP_TYPE.GRACEFUL:
                 graceful_stop_timeout = ignore_case_get(vnf_data, 'gracefulStopTimeout')
 
         result = {
             "vnfInstanceId": vnf_instance_id,
             "changeStateTo": operational_states,
-            "stopType": Stop_Type,
-            "gracefulStopTimeout": graceful_stop_timeout
+            "stopType": stop_type,
+            "gracefulStopTimeout": graceful_stop_timeout if graceful_stop_timeout else 0
         }
         return result
 
index 06217d8..2964a10 100644 (file)
@@ -146,16 +146,12 @@ class OperationalStatesSerializer(serializers.Serializer):
                                                 choices=["STARTED", "STOPPED"])
 
 
-class StopTypeSerializer(serializers.Serializer):
-    StopType = serializers.ChoiceField(help_text="Type of stop", choices=["FORCEFUL", "GRACEFUL"])
-
-
 class OperateVnfDataSerializer(serializers.Serializer):
     vnfInstanceId = serializers.CharField(help_text="Identifier of the VNF instance.", required=True)
     changeStateTo = OperationalStatesSerializer(help_text="The desired operational state to change the VNF to.",
                                                 required=True)
-    stopType = StopTypeSerializer(help_text="It signals whether forceful or graceful stop is requested.",
-                                  required=False, allow_null=True)
+    stopType = serializers.ChoiceField(help_text="It signals whether forceful or graceful stop is requested.",
+                                       choices=["FORCEFUL", "GRACEFUL"], required=False, allow_null=True)
     gracefulStopTimeout = serializers.CharField(help_text="The time interval to wait for the VNF to be taken out of"
                                                           "service during graceful stop.",
                                                 required=False, allow_null=True)
index 45aa273..47930ab 100644 (file)
@@ -43,7 +43,7 @@ class NSUpdateView(APIView):
             if not req_serializer.is_valid():
                 raise NSLCMException(req_serializer.errors)
 
-            job_id = JobUtil.create_job("VNF", JOB_TYPE.HEAL_VNF, ns_instance_id)
+            job_id = JobUtil.create_job("NS", JOB_TYPE.UPDATE_NS, ns_instance_id)
             NSUpdateService(ns_instance_id, request.data, job_id).start()
 
             resp_serializer = NsOperateJobSerializer(data={'jobId': job_id})
index 11b182b..7a58b35 100644 (file)
@@ -19,7 +19,7 @@ import traceback
 
 from lcm.pub.database.models import NfInstModel
 from lcm.pub.exceptions import NSLCMException
-from lcm.pub.msapi.vnfmdriver import send_nf_heal_request
+from lcm.pub.msapi.vnfmdriver import send_nf_operate_request
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS
 from lcm.pub.utils.values import ignore_case_get
 from lcm.ns_vnfs.const import VNF_STATUS
@@ -39,7 +39,7 @@ class NFOperateService(threading.Thread):
 
         self.nf_model = {}
         self.nf_additional_params = {}
-        self.nf_operate_params = {}
+        self.nf_operate_params = data
         self.m_nf_inst_id = ''
         self.vnfm_inst_id = ''
 
@@ -73,7 +73,8 @@ class NFOperateService(threading.Thread):
 
     def send_nf_operating_request(self):
         req_param = json.JSONEncoder().encode(self.nf_operate_params)
-        rsp = send_nf_heal_request(self.vnfm_inst_id, self.m_nf_inst_id, req_param)
+        # rsp = send_nf_heal_request(self.vnfm_inst_id, self.m_nf_inst_id, req_param)
+        rsp = send_nf_operate_request(self.vnfm_inst_id, self.m_nf_inst_id, req_param)
         vnfm_job_id = ignore_case_get(rsp, 'jobId')
         ret = wait_job_finish(self.vnfm_inst_id, self.job_id, vnfm_job_id, progress_range=None, timeout=1200,
                               mode='1')
index 30c7b44..89a3af0 100644 (file)
@@ -30,7 +30,7 @@ JOB_STATUS = enum(PROCESSING=0, FINISH=1)
 JOB_MODEL_STATUS = enum(STARTED='started', PROCESSING='processing', FINISHED='finished', ERROR='error',
                         TIMEOUT='timeout')
 JOB_TYPE = enum(CREATE_VNF="create vnf", TERMINATE_VNF="terminate vnf", GRANT_VNF="grant vnf", MANUAL_SCALE_VNF="manual scale vnf",
-                HEAL_VNF="heal vnf", TERMINATE_NS="terminate ns")
+                HEAL_VNF="heal vnf", TERMINATE_NS="terminate ns", UPDATE_NS="update ns")
 
 
 class JobUtil(object):