aboutsummaryrefslogtreecommitdiffstats
path: root/catalog
diff options
context:
space:
mode:
authoryangyan <yangyanyj@chinamobile.com>2020-03-20 14:43:33 +0800
committerYan Yang <yangyanyj@chinamobile.com>2020-03-20 07:20:33 +0000
commitb2cad09d5c19e0aa59d3b0a2afe60a4cb3b0c36c (patch)
tree5e389a9c5a82c7ca2aa396a0b4637618e9256ce4 /catalog
parent9b4b9f3b7c27efe642d8f7b1ce2a6c947de88873 (diff)
Add etsicatalog api
Add etsicatalog api for nslcm to modify package status" Change-Id: Ib54c19f5908540d233a839a36f387832f9278584 Issue-ID: MODELING-346 Signed-off-by: yangyan <yangyanyj@chinamobile.com>
Diffstat (limited to 'catalog')
-rw-r--r--catalog/packages/biz/ns_descriptor.py5
-rw-r--r--catalog/packages/urls.py3
-rw-r--r--catalog/packages/views/ns_descriptor_views.py18
3 files changed, 26 insertions, 0 deletions
diff --git a/catalog/packages/biz/ns_descriptor.py b/catalog/packages/biz/ns_descriptor.py
index 8b337dc..d14c452 100644
--- a/catalog/packages/biz/ns_descriptor.py
+++ b/catalog/packages/biz/ns_descriptor.py
@@ -19,6 +19,7 @@ import os
import uuid
from catalog.packages.biz.common import parse_file_range, read, save
+from catalog.packages.const import PKG_STATUS
from catalog.pub.config.config import CATALOG_ROOT_PATH
from catalog.pub.database.models import NSPackageModel, PnfPackageModel, VnfPackageModel
from catalog.pub.exceptions import CatalogException, ResourceNotFoundException
@@ -58,6 +59,10 @@ class NsDescriptor(object):
logger.info('A NSD(%s) has been created.' % data['id'])
return data
+ def update(self, data, nsd_info_id):
+ usageState = PKG_STATUS.IN_USE if data["usageState"] else PKG_STATUS.NOT_IN_USE
+ NSPackageModel.objects.filter(nsPackageId=nsd_info_id).update(usageState=usageState)
+
def query_multiple(self, nsdId=None):
if nsdId:
ns_pkgs = NSPackageModel.objects.filter(nsdId=nsdId)
diff --git a/catalog/packages/urls.py b/catalog/packages/urls.py
index 410df80..6a86252 100644
--- a/catalog/packages/urls.py
+++ b/catalog/packages/urls.py
@@ -64,6 +64,9 @@ urlpatterns = [
url(r'^URI-is-provided-by-the-client-when-creating-the-subscription-VnfPackageOnboardingNotification$', PkgOnboardingNotificationView.as_view()),
url(r'^URI-is-provided-by-the-client-when-creating-the-subscription-VnfPackageChangeNotification$', PkgChangeNotificationView.as_view()),
+ # catalog and lcm interaction APIS
+ url(r'^api/catalog/v1/ns_descriptors/(?P<nsdInfoId>[0-9a-zA-Z\-\_]+)$', ns_descriptor_views.ns_descriptors_u, name='ns_descriptors_u'),
+
# health check
url(r'^api/vnfpkgm/v1/health_check$', HealthCheckView.as_view()),
url(r'^api/nsd/v1/health_check$', HealthCheckView.as_view()),
diff --git a/catalog/packages/views/ns_descriptor_views.py b/catalog/packages/views/ns_descriptor_views.py
index 2d98628..44e06e4 100644
--- a/catalog/packages/views/ns_descriptor_views.py
+++ b/catalog/packages/views/ns_descriptor_views.py
@@ -144,3 +144,21 @@ def nsd_content_ru(request, **kwargs):
file_range = request.META.get('HTTP_RANGE')
file_iterator = NsDescriptor().download(nsd_info_id, file_range)
return StreamingHttpResponse(file_iterator, status=status.HTTP_200_OK)
+
+
+@swagger_auto_schema(
+ method='PUT',
+ operation_description="Update a NSD",
+ request_body=no_body,
+ responses={
+ status.HTTP_202_ACCEPTED: "Successfully",
+ status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
+ }
+)
+@api_view(http_method_names=['PUT'])
+@view_safe_call_with_log(logger=logger)
+def ns_descriptors_u(request, **kwargs):
+ if request.method == 'PUT':
+ nsd_info_id = kwargs.get("nsdInfoId")
+ NsDescriptor().update(request.data, nsd_info_id)
+ return Response(data=None, status=status.HTTP_202_ACCEPTED)