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
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)
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()),
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)