summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-09-19 10:30:19 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-09-19 10:30:19 +0800
commit1ad68beeaf0f3e65d2f945763d2e95c136ad5ea2 (patch)
tree67f14ea20bc3c9ee088c9b0202d5c1fadc357b4d
parentae9e7301bbdf23ccf564d2d6f49eeb7042728905 (diff)
Move heal ns view as single
Change-Id: Id8e8686604d7acc0b1f2687b7bd0057e75d50db4 Issue-ID: VFC-1009 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--lcm/ns/urls.py3
-rw-r--r--lcm/ns/views/heal_ns_view.py57
-rw-r--r--lcm/ns/views/views.py32
3 files changed, 59 insertions, 33 deletions
diff --git a/lcm/ns/urls.py b/lcm/ns/urls.py
index 7c804875..2aaa4eb3 100644
--- a/lcm/ns/urls.py
+++ b/lcm/ns/urls.py
@@ -17,8 +17,9 @@ from rest_framework.urlpatterns import format_suffix_patterns
from lcm.ns.views.create_ns_view import CreateNSView
from lcm.ns.views.inst_ns_view import NSInstView
from lcm.ns.views.term_ns_view import TerminateNSView
+from lcm.ns.views.heal_ns_view import NSHealView
from lcm.ns.views.views import NSDetailView, NSInstPostDealView, \
- NSManualScaleView, NSHealView
+ NSManualScaleView
urlpatterns = [
# API will be deprecated in the future release
diff --git a/lcm/ns/views/heal_ns_view.py b/lcm/ns/views/heal_ns_view.py
new file mode 100644
index 00000000..a0534e33
--- /dev/null
+++ b/lcm/ns/views/heal_ns_view.py
@@ -0,0 +1,57 @@
+# Copyright 2016-2017 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import logging
+
+from rest_framework import status
+from rest_framework.response import Response
+from rest_framework.views import APIView
+from drf_yasg.utils import swagger_auto_schema
+
+from lcm.ns.biz.ns_heal import NSHealService
+from lcm.ns.serializers.ns_serializers import HealNsReqSerializer
+from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer
+from lcm.pub.exceptions import NSLCMException
+from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
+
+logger = logging.getLogger(__name__)
+
+
+class NSHealView(APIView):
+ @swagger_auto_schema(
+ request_body=HealNsReqSerializer(),
+ responses={
+ status.HTTP_202_ACCEPTED: NsOperateJobSerializer(),
+ status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error"
+ }
+ )
+ def post(self, request, ns_instance_id):
+ try:
+ logger.debug("Enter HealNSView::post %s", request.data)
+ logger.debug("Enter HealNSView:: %s", ns_instance_id)
+ req_serializer = HealNsReqSerializer(data=request.data)
+ if not req_serializer.is_valid():
+ raise NSLCMException(req_serializer.errors)
+
+ job_id = JobUtil.create_job("VNF", JOB_TYPE.HEAL_VNF, ns_instance_id)
+ NSHealService(ns_instance_id, request.data, job_id).start()
+
+ resp_serializer = NsOperateJobSerializer(data={'jobId': job_id})
+ if not resp_serializer.is_valid():
+ raise NSLCMException(resp_serializer.errors)
+
+ logger.debug("Leave HealNSView::post ret=%s", resp_serializer.data)
+ return Response(data=resp_serializer.data, status=status.HTTP_202_ACCEPTED)
+ except Exception as e:
+ logger.error("Exception in HealNSView: %s", e.message)
+ return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
diff --git a/lcm/ns/views/views.py b/lcm/ns/views/views.py
index 7f6f70f7..9f3bdd58 100644
--- a/lcm/ns/views/views.py
+++ b/lcm/ns/views/views.py
@@ -17,14 +17,12 @@ import traceback
from drf_yasg.utils import swagger_auto_schema
from lcm.ns.biz.ns_get import GetNSInfoService
-from lcm.ns.biz.ns_heal import NSHealService
from lcm.ns.biz.ns_manual_scale import NSManualScaleService
from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
from lcm.ns.biz.ns_delete import DeleteNsService
-from lcm.ns.serializers.ns_serializers import HealNsReqSerializer
from lcm.ns.serializers.ns_serializers import InstNsPostDealReqSerializer
from lcm.ns.serializers.ns_serializers import ManualScaleNsReqSerializer
from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer
@@ -38,36 +36,6 @@ from lcm.pub.utils.values import ignore_case_get
logger = logging.getLogger(__name__)
-class NSHealView(APIView):
- @swagger_auto_schema(
- request_body=HealNsReqSerializer(),
- responses={
- status.HTTP_202_ACCEPTED: NsOperateJobSerializer(),
- status.HTTP_500_INTERNAL_SERVER_ERROR: "Inner error"
- }
- )
- def post(self, request, ns_instance_id):
- try:
- logger.debug("Enter HealNSView::post %s", request.data)
- logger.debug("Enter HealNSView:: %s", ns_instance_id)
- req_serializer = HealNsReqSerializer(data=request.data)
- if not req_serializer.is_valid():
- raise NSLCMException(req_serializer.errors)
-
- job_id = JobUtil.create_job("VNF", JOB_TYPE.HEAL_VNF, ns_instance_id)
- NSHealService(ns_instance_id, request.data, job_id).start()
-
- resp_serializer = NsOperateJobSerializer(data={'jobId': job_id})
- if not resp_serializer.is_valid():
- raise NSLCMException(resp_serializer.errors)
-
- logger.debug("Leave HealNSView::post ret=%s", resp_serializer.data)
- return Response(data=resp_serializer.data, status=status.HTTP_202_ACCEPTED)
- except Exception as e:
- logger.error("Exception in HealNSView: %s", e.message)
- return Response(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-
-
class NSDetailView(APIView):
@swagger_auto_schema(
request_body=None,