summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaili <lai.li@zte.com.cn>2018-08-23 13:28:08 +0800
committerlaili <lai.li@zte.com.cn>2018-08-23 13:28:08 +0800
commit19cb03a20af4add7bea46e7ca508eba7bd24a6a6 (patch)
tree7a81040bfc6abcb514a6532581ca6e5cc2fb58b6
parent86fbd2857df6e6b4ea4cb35ae25e211437936600 (diff)
Ns descriptor related stuffs.
Merge nsd_content_views int ns_descriptor_views. Change-Id: Icaec368383c9f9530166304ded6e9ebb6c2adb9e Issue-ID: VFC-1037 Signed-off-by: laili <lai.li@zte.com.cn>
-rw-r--r--catalog/packages/urls.py5
-rw-r--r--catalog/packages/views/ns_descriptor_views.py24
-rw-r--r--catalog/packages/views/nsd_content_views.py71
3 files changed, 25 insertions, 75 deletions
diff --git a/catalog/packages/urls.py b/catalog/packages/urls.py
index f5dfecc5..19688c6d 100644
--- a/catalog/packages/urls.py
+++ b/catalog/packages/urls.py
@@ -15,8 +15,7 @@
from django.conf.urls import url
from catalog.packages.views import vnf_package_views
-from catalog.packages.views import (catalog_views, ns_descriptor_views,
- nsd_content_views, pnf_descriptor_views,
+from catalog.packages.views import (catalog_views, ns_descriptor_views, pnf_descriptor_views,
pnfd_content_views)
@@ -31,7 +30,7 @@ urlpatterns = [
# NSD
url(r'^api/nsd/v1/ns_descriptors$', ns_descriptor_views.ns_descriptors_rc, name='ns_descriptors_rc'),
url(r'^api/nsd/v1/ns_descriptors/(?P<nsdInfoId>[0-9a-zA-Z\-\_]+)$', ns_descriptor_views.ns_info_rd, name='ns_info_rd'),
- url(r'^api/nsd/v1/ns_descriptors/(?P<nsdInfoId>[0-9a-zA-Z\-\_]+)/nsd_content$', nsd_content_views.upload_nsd_content, name='nsd_content_ru'),
+ url(r'^api/nsd/v1/ns_descriptors/(?P<nsdInfoId>[0-9a-zA-Z\-\_]+)/nsd_content$', ns_descriptor_views.nsd_content_ru, name='nsd_content_ru'),
# PNF
url(r'^api/nsd/v1/pnf_descriptors$', pnf_descriptor_views.create_pnf_descriptors, name='pnf_descriptors_rc'),
diff --git a/catalog/packages/views/ns_descriptor_views.py b/catalog/packages/views/ns_descriptor_views.py
index 455b01ae..68dd4ed5 100644
--- a/catalog/packages/views/ns_descriptor_views.py
+++ b/catalog/packages/views/ns_descriptor_views.py
@@ -20,7 +20,7 @@ from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
-from catalog.packages.biz.ns_descriptor import create, query_multiple, query_single, delete_single
+from catalog.packages.biz.ns_descriptor import create, query_multiple, query_single, delete_single, upload
from catalog.packages.serializers.create_nsd_info_request import \
CreateNsdInfoRequestSerializer
from catalog.packages.serializers.nsd_info import NsdInfoSerializer
@@ -123,3 +123,25 @@ def ns_descriptors_rc(request, *args, **kwargs):
data={'error': 'Query of multiple NS descriptor resources failed.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR
)
+
+
+@swagger_auto_schema(
+ method='PUT',
+ operation_description="Upload NSD content",
+ request_body=no_body,
+ responses={
+ status.HTTP_204_NO_CONTENT: {},
+ status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
+ }
+)
+@api_view(http_method_names=['PUT'])
+def nsd_content_ru(request, *args, **kwargs):
+ nsd_info_id = kwargs.get("nsdInfoId")
+ files = request.FILES.getlist('file')
+ try:
+ upload(files[0], nsd_info_id)
+ return Response(data={}, status=status.HTTP_204_NO_CONTENT)
+ except IOError:
+ logger.error(traceback.format_exc())
+ raise CatalogException
+ return Response(data={'error': 'Uploading nsd content failed.'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
diff --git a/catalog/packages/views/nsd_content_views.py b/catalog/packages/views/nsd_content_views.py
deleted file mode 100644
index ed580e47..00000000
--- a/catalog/packages/views/nsd_content_views.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 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
-import traceback
-
-from drf_yasg.utils import no_body, swagger_auto_schema
-from rest_framework import status
-from rest_framework.decorators import api_view
-from rest_framework.response import Response
-
-from catalog.packages.biz.ns_descriptor import upload
-from catalog.pub.exceptions import CatalogException
-
-logger = logging.getLogger(__name__)
-
-
-@swagger_auto_schema(
- responses={
- # status.HTTP_200_OK: Serializer(),
- status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
- }
-)
-def get(self, request):
- # TODO
- return None
-
-
-@swagger_auto_schema(
- # request_body=CreateVnfReqSerializer(),
- responses={
- # status.HTTP_201_CREATED: CreateVnfRespSerializer(),
- status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
- }
-)
-def post(self, request):
- # TODO
- return None
-
-
-@swagger_auto_schema(
- method='PUT',
- operation_description="Upload NSD content",
- request_body=no_body,
- responses={
- status.HTTP_204_NO_CONTENT: {},
- status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
- }
-)
-@api_view(http_method_names=['PUT'])
-def upload_nsd_content(request, *args, **kwargs):
- nsd_info_id = kwargs.get("nsdInfoId")
- files = request.FILES.getlist('file')
- try:
- upload(files[0], nsd_info_id)
- return Response(data={}, status=status.HTTP_204_NO_CONTENT)
- except IOError:
- logger.error(traceback.format_exc())
- raise CatalogException
- return Response(data={'error': 'Uploading nsd content failed.'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)