diff options
author | Fu Jinhua <fu.jinhua@zte.com.cn> | 2018-11-14 12:06:40 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-11-14 12:06:40 +0000 |
commit | 1146c172c675cc55507aff13949470fde3ca89d8 (patch) | |
tree | c2829a679d992e0052084104eb56ec58dad4bd32 | |
parent | 3b9ecad6a9f97f5691cb67de32a94fd07f32fd78 (diff) | |
parent | eb04294f49cbac2ca9709d0377722813a60a2354 (diff) |
Merge "fix NS update error"3.0.1-ONAP1.2.1
-rw-r--r-- | lcm/ns/biz/ns_update.py | 8 | ||||
-rw-r--r-- | lcm/ns/serializers/update_serializers.py | 8 | ||||
-rw-r--r-- | lcm/ns/views/update_ns_view.py | 2 | ||||
-rw-r--r-- | lcm/ns_vnfs/biz/update_vnfs.py | 7 | ||||
-rw-r--r-- | lcm/pub/utils/jobutil.py | 2 |
5 files changed, 11 insertions, 16 deletions
diff --git a/lcm/ns/biz/ns_update.py b/lcm/ns/biz/ns_update.py index cb00ced8..eba18c68 100644 --- a/lcm/ns/biz/ns_update.py +++ b/lcm/ns/biz/ns_update.py @@ -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 diff --git a/lcm/ns/serializers/update_serializers.py b/lcm/ns/serializers/update_serializers.py index 06217d80..2964a100 100644 --- a/lcm/ns/serializers/update_serializers.py +++ b/lcm/ns/serializers/update_serializers.py @@ -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) diff --git a/lcm/ns/views/update_ns_view.py b/lcm/ns/views/update_ns_view.py index 45aa2735..47930aba 100644 --- a/lcm/ns/views/update_ns_view.py +++ b/lcm/ns/views/update_ns_view.py @@ -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}) diff --git a/lcm/ns_vnfs/biz/update_vnfs.py b/lcm/ns_vnfs/biz/update_vnfs.py index 11b182ba..7a58b359 100644 --- a/lcm/ns_vnfs/biz/update_vnfs.py +++ b/lcm/ns_vnfs/biz/update_vnfs.py @@ -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') diff --git a/lcm/pub/utils/jobutil.py b/lcm/pub/utils/jobutil.py index 30c7b444..89a3af02 100644 --- a/lcm/pub/utils/jobutil.py +++ b/lcm/pub/utils/jobutil.py @@ -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): |