diff options
-rw-r--r-- | catalog/packages/nf_package.py | 8 | ||||
-rw-r--r-- | catalog/packages/ns_package.py | 15 | ||||
-rw-r--r-- | catalog/packages/views.py | 4 |
3 files changed, 12 insertions, 15 deletions
diff --git a/catalog/packages/nf_package.py b/catalog/packages/nf_package.py index ae8d9011..b07c5839 100644 --- a/catalog/packages/nf_package.py +++ b/catalog/packages/nf_package.py @@ -54,19 +54,19 @@ def nf_get_csar(csar_id): return [1, str(sys.exc_info())] return ret -def parser_vnfdmodel(csar_id,inputs): +def parse_vnfd(csar_id, inputs): ret= None try: nf_pkg = VnfPackageModel.objects.filter(vnfPackageId=csar_id) if nf_pkg: - csar_path=nf_pkg["localFilePath"] - ret={"model":toscaparser.parse_vnfd(csar_path,inputs)} + csar_path = nf_pkg[0].localFilePath + ret = {"model": toscaparser.parse_vnfd(csar_path, inputs)} except CatalogException as e: return [1, e.message] except: logger.error(traceback.format_exc()) return [1, str(sys.exc_info())] - return [0,ret] + return [0, ret] class NfDistributeThread(threading.Thread): diff --git a/catalog/packages/ns_package.py b/catalog/packages/ns_package.py index 90e330d0..a5ee049c 100644 --- a/catalog/packages/ns_package.py +++ b/catalog/packages/ns_package.py @@ -92,22 +92,19 @@ def ns_get_csar(csar_id): return [1, str(sys.exc_info())] return ret -def parser_NSPackageModel(csar_id,inputs): +def parse_nsd(csar_id, inputs): ret= None try: - nf_pkg = NSPackageModel.objects.filter(nsPackageId=csar_id) - - if nf_pkg: - for pkg in nf_pkg: - csar_path = pkg.localFilePath - ret={"model":toscaparser.parse_nsd(csar_path,inputs)} - continue + ns_pkg = NSPackageModel.objects.filter(nsPackageId=csar_id) + if ns_pkg: + csar_path = ns_pkg[0].localFilePath + ret = {"model": toscaparser.parse_nsd(csar_path, inputs)} except CatalogException as e: return [1, e.message] except: logger.error(traceback.format_exc()) return [1, str(sys.exc_info())] - return [0,ret] + return [0, ret] class NsPackage(object): diff --git a/catalog/packages/views.py b/catalog/packages/views.py index d2875510..50899160 100644 --- a/catalog/packages/views.py +++ b/catalog/packages/views.py @@ -115,7 +115,7 @@ def ns_model_parser(request, *args, **kwargs): csar_id = ignore_case_get(request.data, "csarId") inputs = ignore_case_get(request.data, "inputs") logger.debug("Enter %s, csar_id=%s, inputs=%s", fun_name(), csar_id, inputs) - ret = ns_package.parser_NSPackageModel(csar_id, inputs) + ret = ns_package.parse_nsd(csar_id, inputs) logger.info("Leave %s, Return value is %s", fun_name(), ret) if ret[0] != 0: return Response(data={'error': ret[1]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) @@ -127,7 +127,7 @@ def vnf_model_parser(request, *args, **kwargs): csar_id = ignore_case_get(request.data, "csarId") inputs = ignore_case_get(request.data, "inputs") logger.debug("Enter %s, csar_id=%s, inputs=%s", fun_name(), csar_id, inputs) - nf_package.parser_vnfdmodel(csar_id, inputs) + nf_package.parse_vnfd(csar_id, inputs) logger.info("Leave %s, Return value is %s", fun_name(), ret) if ret[0] != 0: return Response(data={'error': ret[1]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) |