diff options
author | maopeng zhang <zhang.maopeng1@zte.com.cn> | 2017-09-16 00:49:06 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-09-16 00:49:06 +0000 |
commit | fd6102b82650918168e243d493421fe65714f4c3 (patch) | |
tree | 27b133aa365ca91643a243bdecaa56cf89cdba1f | |
parent | 58ff1c12d57f5972c094a8c320a018f6e47cc42d (diff) | |
parent | 60df812a6f8ef289a331eaba301d8167931fd319 (diff) |
Merge "Modify catalog Schema"
-rw-r--r-- | catalog/packages/nf_package.py | 54 | ||||
-rw-r--r-- | catalog/packages/ns_package.py | 55 | ||||
-rw-r--r-- | catalog/packages/tests.py | 27 | ||||
-rw-r--r-- | catalog/packages/views.py | 2 | ||||
-rw-r--r-- | catalog/pub/database/models.py | 89 | ||||
-rw-r--r-- | catalog/pub/msapi/nfvolcm.py | 9 |
6 files changed, 132 insertions, 104 deletions
diff --git a/catalog/packages/nf_package.py b/catalog/packages/nf_package.py index fe7c49f5..ae8d9011 100644 --- a/catalog/packages/nf_package.py +++ b/catalog/packages/nf_package.py @@ -20,7 +20,7 @@ import threading import traceback from catalog.pub.config.config import CATALOG_ROOT_PATH -from catalog.pub.database.models import NfPackageModel +from catalog.pub.database.models import VnfPackageModel from catalog.pub.exceptions import CatalogException from catalog.pub.msapi import nfvolcm from catalog.pub.msapi import sdc @@ -57,9 +57,9 @@ def nf_get_csar(csar_id): def parser_vnfdmodel(csar_id,inputs): ret= None try: - nf_pkg = NfPackageModel.objects.filter(nfpackageid=csar_id) + nf_pkg = VnfPackageModel.objects.filter(vnfPackageId=csar_id) if nf_pkg: - csar_path=nf_pkg["vnfd_path"] + csar_path=nf_pkg["localFilePath"] ret={"model":toscaparser.parse_vnfd(csar_path,inputs)} except CatalogException as e: return [1, e.message] @@ -103,13 +103,13 @@ class NfDistributeThread(threading.Thread): job_id=self.job_id) JobUtil.add_job_status(self.job_id, 5, "Start CSAR(%s) distribute." % self.csar_id) - if NfPackageModel.objects.filter(nfpackageid=self.csar_id): + if VnfPackageModel.objects.filter(vnfPackageId=self.csar_id): raise CatalogException("NF CSAR(%s) already exists." % self.csar_id) vnfd,local_file_name,vnfd_json = self.get_vnfd(self.csar_id) nfd_id = vnfd["metadata"]["id"] - if NfPackageModel.objects.filter(vnfdid=nfd_id): + if VnfPackageModel.objects.filter(vnfdId=nfd_id): raise CatalogException("NFD(%s) already exists." % nfd_id) JobUtil.add_job_status(self.job_id, 30, "Save CSAR(%s) to database." % self.csar_id) @@ -117,15 +117,16 @@ class NfDistributeThread(threading.Thread): vnfd_ver = vnfd["metadata"].get("vnfd_version") if not vnfd_ver: vnfd_ver = vnfd["metadata"].get("vnfdVersion", "undefined") - NfPackageModel( - uuid=self.csar_id, - nfpackageid=self.csar_id, - vnfdid=nfd_id, - vendor=vnfd["metadata"].get("vendor", "undefined"), - vnfdversion=vnfd_ver, - vnfversion=vnfd["metadata"].get("version", "undefined"), - vnfdmodel=vnfd_json, - vnfd_path=local_file_name + VnfPackageModel( + # uuid=self.csar_id, + vnfPackageId=self.csar_id, + vnfdId=nfd_id, + vnfVendor=vnfd["metadata"].get("vendor", "undefined"), + vnfdVersion=vnfd_ver, + vnfSoftwareVersion=vnfd["metadata"].get("version", "undefined"), + vnfdModel=vnfd_json, + localFilePath=local_file_name, + #vnfPackageUri to do ).save() JobUtil.add_job_status(self.job_id, 100, "CSAR(%s) distribute successfully." % self.csar_id) @@ -134,14 +135,13 @@ class NfDistributeThread(threading.Thread): artifact = sdc.get_artifact(sdc.ASSETTYPE_RESOURCES, self.csar_id) local_path = os.path.join(CATALOG_ROOT_PATH, self.csar_id) local_file_name = sdc.download_artifacts(artifact["toscaModelURL"], local_path) - vnfd_json = toscaparser.parse_vnfd(local_file_name) vnfd = json.JSONDecoder().decode(vnfd_json) return vnfd,local_file_name,vnfd_json def rollback_distribute(self): try: - NfPackageModel.objects.filter(nfpackageid=self.csar_id).delete() + VnfPackageModel.objects.filter(vnfPackageId=self.csar_id).delete() fileutil.delete_dirs(self.csar_save_path) except: logger.error(traceback.format_exc()) @@ -187,11 +187,11 @@ class NfPkgDeleteThread(threading.Thread): nfvolcm.delete_nf_inst_mock() JobUtil.add_job_status(self.job_id, 50, "Delete CSAR(%s) from Database." % self.csar_id) - if not NfPackageModel.objects.filter(nfpackageid=self.csar_id): + if not VnfPackageModel.objects.filter(vnfPackageId=self.csar_id): JobUtil.add_job_status(self.job_id, 100, "Error! CSAR(%s) does not exist." % self.csar_id) return - NfPackageModel.objects.filter(nfpackageid=self.csar_id).delete() + VnfPackageModel.objects.filter(vnfPackageId=self.csar_id).delete() JobUtil.add_job_status(self.job_id, 80, "Delete local CSAR(%s) file." % self.csar_id) @@ -211,26 +211,26 @@ class NfPackage(object): def get_csars(self): csars = {"csars": []} - nf_pkgs = NfPackageModel.objects.filter() + nf_pkgs = VnfPackageModel.objects.filter() for nf_pkg in nf_pkgs: csars["csars"].append({ - "csarId": nf_pkg.nfpackageid, - "vnfdId": nf_pkg.vnfdid + "csarId": nf_pkg.vnfPackageId, + "vnfdId": nf_pkg.vnfdId }) return [0, csars] def get_csar(self, csar_id): pkg_info = {} - nf_pkg = NfPackageModel.objects.filter(nfpackageid=csar_id) + nf_pkg = VnfPackageModel.objects.filter(nfpackageid=csar_id) if nf_pkg: - pkg_info["vnfdId"] = nf_pkg[0].vnfdid - pkg_info["vnfdProvider"] = nf_pkg[0].vendor - pkg_info["vnfdVersion"] = nf_pkg[0].vnfdversion - pkg_info["vnfVersion"] = nf_pkg[0].vnfversion + pkg_info["vnfdId"] = nf_pkg[0].vnfdId + pkg_info["vnfdProvider"] = nf_pkg[0].vnfVendor + pkg_info["vnfdVersion"] = nf_pkg[0].vnfdVersion + pkg_info["vnfVersion"] = nf_pkg[0].vnfSoftwareVersion #vnf_insts = NfInstModel.objects.filter(package_id=csar_id) - vnf_insts = nfvolcm.getNfInsts_mock() + vnf_insts = nfvolcm.get_vnfInstances() vnf_inst_info = [{"vnfInstanceId": vnf_inst["vnfInstanceId"], "vnfInstanceName": vnf_inst["vnfInstanceName"]} for vnf_inst in vnf_insts] diff --git a/catalog/packages/ns_package.py b/catalog/packages/ns_package.py index 79ccf381..90e330d0 100644 --- a/catalog/packages/ns_package.py +++ b/catalog/packages/ns_package.py @@ -19,7 +19,7 @@ import sys import traceback from catalog.pub.config.config import CATALOG_ROOT_PATH -from catalog.pub.database.models import NSDModel, NfPackageModel +from catalog.pub.database.models import NSPackageModel, VnfPackageModel from catalog.pub.exceptions import CatalogException from catalog.pub.msapi import nfvolcm from catalog.pub.msapi import sdc @@ -92,14 +92,14 @@ def ns_get_csar(csar_id): return [1, str(sys.exc_info())] return ret -def parser_nsdmodel(csar_id,inputs): +def parser_NSPackageModel(csar_id,inputs): ret= None try: - nf_pkg = NSDModel.objects.filter(id=csar_id) + nf_pkg = NSPackageModel.objects.filter(nsPackageId=csar_id) if nf_pkg: for pkg in nf_pkg: - csar_path = pkg.nsd_path + csar_path = pkg.localFilePath ret={"model":toscaparser.parse_nsd(csar_path,inputs)} continue except CatalogException as e: @@ -119,30 +119,33 @@ class NsPackage(object): pass def on_distribute(self, csar_id): - if NSDModel.objects.filter(id=csar_id): + if NSPackageModel.objects.filter(nsPackageId=csar_id): raise CatalogException("NS CSAR(%s) already exists." % csar_id) nsd,local_file_name,nsd_json = self.get_nsd(csar_id) nsd_id = nsd["metadata"]["id"] - if NSDModel.objects.filter(nsd_id=nsd_id): + if NSPackageModel.objects.filter(nsdId=nsd_id): raise CatalogException("NSD(%s) already exists." % nsd_id) for vnf in nsd["vnfs"]: vnfd_id = vnf["properties"]["id"] - pkg = NfPackageModel.objects.filter(vnfdid=vnfd_id) + pkg = VnfPackageModel.objects.filter(vnfdId = vnfd_id) if not pkg: raise CatalogException("VNF package(%s) is not distributed." % vnfd_id) - NSDModel( - id=csar_id, - nsd_id=nsd_id, - name=nsd["metadata"].get("name", nsd_id), - vendor=nsd["metadata"].get("vendor", "undefined"), - description=nsd["metadata"].get("description", ""), - version=nsd["metadata"].get("version", "undefined"), - nsd_path=local_file_name, - nsd_model=nsd_json).save() + NSPackageModel( + nsPackageId=csar_id, + nsdId=nsd_id, + nsdName=nsd["metadata"].get("name", nsd_id), + nsdDesginer=nsd["metadata"].get("vendor", "undefined"), + nsdDescription=nsd["metadata"].get("description", ""), + nsdVersion=nsd["metadata"].get("version", "undefined"), + nsPackageUri=local_file_name, + sdcCsarId=csar_id, + localFilePath=local_file_name, + nsdModel=nsd_json + ).save() return [0, "CSAR(%s) distributed successfully." % csar_id] @@ -165,33 +168,33 @@ class NsPackage(object): raise CatalogException("CSAR(%s) is in using, cannot be deleted." % csar_id) ''' #nfvolcm.delete_ns_inst_mock() - NSDModel.objects.filter(id=csar_id).delete() + NSPackageModel.objects.filter(nsPackageId=csar_id).delete() return [0, "Delete CSAR(%s) successfully." % csar_id] def get_csars(self): csars = [] - nss = NSDModel.objects.filter() + nss = NSPackageModel.objects.filter() for ns in nss: csars.append({ - "csarId": ns.id, - "nsdId": ns.nsd_id + "csarId": ns.nsPackageId, + "nsdId": ns.nsdId }) return [0,csars] def get_csar(self, csar_id): package_info = {} - csars = NSDModel.objects.filter(id=csar_id) + csars = NSPackageModel.objects.filter(nsPackageId=csar_id) if csars: - package_info["nsdId"] = csars[0].nsd_id - package_info["nsdProvider"] = csars[0].vendor - package_info["nsdVersion"] = csars[0].version + package_info["nsdId"] = csars[0].nsdId + package_info["nsdProvider"] = csars[0].nsdDesginer + package_info["nsdVersion"] = csars[0].nsdVersion #nss = NSInstModel.objects.filter(nspackage_id=csar_id) - nss = nfvolcm.getNsInsts_mock() + nss = nfvolcm.get_nsInstances(csar_id) ns_instance_info = [{ "nsInstanceId": ns["nsInstanceId"], - "nsInstanceName": ns["nsInstanceName"]} for ns in nss] + "nsInstanceName": ns["nsName"]} for ns in nss] return [0, {"csarId": csar_id, "packageInfo": package_info, diff --git a/catalog/packages/tests.py b/catalog/packages/tests.py index 953fece7..4084a791 100644 --- a/catalog/packages/tests.py +++ b/catalog/packages/tests.py @@ -22,7 +22,7 @@ from catalog.packages.nf_package import NfPackage from catalog.packages.nf_package import NfDistributeThread from catalog.packages.nf_package import NfPkgDeleteThread from django.test import Client -from catalog.pub.database.models import NSDModel, NfPackageModel, JobStatusModel, JobModel +from catalog.pub.database.models import NSPackageModel, VnfPackageModel, JobStatusModel, JobModel from rest_framework import status from catalog.pub.msapi import nfvolcm @@ -448,10 +448,11 @@ class PackageTest(unittest.TestCase): } } def tearDown(self): - NfPackageModel.objects.all().delete() - NSDModel.objects.all().delete() + VnfPackageModel.objects.all().delete() + NSPackageModel.objects.all().delete() JobStatusModel.objects.all().delete() + @mock.patch.object(NsPackage, 'get_csars') def test_nspackages_get(self,mock_get_csars): mock_get_csars.return_value = [0,self.csars] @@ -469,14 +470,14 @@ class PackageTest(unittest.TestCase): self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content) self.assert_nsdmodel_result("VCPE_NS", 0) self.assertEqual("VNF package(456) is not distributed.", response.data["statusDescription"], response.content) - NSDModel.objects.filter(id="VCPE_NS").delete() + NSPackageModel.objects.filter(nsPackageId="VCPE_NS").delete() def test_nfpackages_get(self): response = self.client.get("/api/catalog/v1/vnfpackages") self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) - nsdModel = NSDModel.objects.filter(nsd_id="VCPE_NS") - self.assertSequenceEqual(nsdModel,[]) + nsdModel = NSPackageModel.objects.filter(nsdId="VCPE_NS") + self.assertEqual(len(nsdModel),0) @mock.patch.object(NfDistributeThread, 'get_vnfd') @@ -496,8 +497,8 @@ class PackageTest(unittest.TestCase): self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content) self.assertEqual("CSAR(123) distributed successfully.", response.data["statusDescription"], response.content) self.assert_nsdmodel_result("VCPE_NS", 1) - NfPackageModel.objects.filter(vnfdid=str(self.nf_csarId)).delete() - NSDModel.objects.filter(nsd_id="VCPE_NS").delete() + VnfPackageModel.objects.filter(vnfdId=str(self.nf_csarId)).delete() + NSPackageModel.objects.filter(nsdId="VCPE_NS").delete() @mock.patch.object(NfDistributeThread, 'get_vnfd') def test_nf_distribute(self, mock_get_vnfd): @@ -507,7 +508,7 @@ class PackageTest(unittest.TestCase): NfDistributeThread("dd", ["1"], "1", "5").run() self.assert_job_result("5", 100, "CSAR(dd) distribute successfully.") - NfPackageModel.objects.filter(nfpackageid="dd").delete() + VnfPackageModel.objects.filter(vnfPackageId="dd").delete() @mock.patch.object(NfDistributeThread, 'get_vnfd') @mock.patch.object(NsPackage,'get_nsd') @@ -597,15 +598,15 @@ class PackageTest(unittest.TestCase): self.assertEqual(1, len(jobs)) def assert_nsdmodel_result(self,nsd_id,size): - nsdmodels = NSDModel.objects.filter( - nsd_id = nsd_id + nsdmodels = NSPackageModel.objects.filter( + nsdId = nsd_id ) self.assertEquals(size, len(nsdmodels)) def assert_nfmodel_result(self,csar_id,size): - vnfdmodels = NfPackageModel.objects.filter( - nfpackageid = csar_id + vnfdmodels = VnfPackageModel.objects.filter( + vnfPackageId = csar_id ) self.assertEquals(size, len(vnfdmodels)) diff --git a/catalog/packages/views.py b/catalog/packages/views.py index 5bd121ea..2e001380 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") if request.method == 'POST': - ret = ns_package.parser_nsdmodel(csar_id,inputs) + ret = ns_package.parser_NSPackageModel(csar_id,inputs) normal_status = status.HTTP_202_ACCEPTED else: ret = [1, "Request is not allowed"] diff --git a/catalog/pub/database/models.py b/catalog/pub/database/models.py index 83379cfb..d53e45f6 100644 --- a/catalog/pub/database/models.py +++ b/catalog/pub/database/models.py @@ -14,48 +14,65 @@ from django.db import models -class NSDModel(models.Model): - id = models.CharField(db_column='ID', primary_key=True, max_length=200) - nsd_id = models.CharField(db_column='NSDID', max_length=200) - name = models.CharField(db_column='NAME', max_length=200) - vendor = models.CharField(db_column='VENDOR', max_length=200, null=True, blank=True) - description = models.CharField(db_column='DESCRIPTION', max_length=200, null=True, blank=True) - version = models.CharField(db_column='VERSION', max_length=200, null=True, blank=True) - nsd_model = models.TextField(db_column='NSDMODEL', max_length=65535, null=True, blank=True) - nsd_path = models.CharField(db_column='NSDPATH', max_length=300, null=True, blank=True) - +class NSPackageModel(models.Model): + nsPackageId = models.CharField(db_column='NSPACKAGEID', primary_key=True, max_length=200) + nsPackageUri = models.CharField(db_column='NSPACKAGEURI', max_length=300, null=True, blank=True) + checksum = models.CharField(db_column='CHECKSUM', max_length=300, null=True, blank=True) # checksum + sdcCsarId = models.CharField(db_column='SDCCSARID', max_length=300, null=True, blank=True) # SdcCSARUri + operationalState = models.TextField(db_column='OPERATIONALSTATE', max_length=20, blank=True,null=True) # operationalState + usageState = models.TextField(db_column='USAGESTATE', max_length=20, blank=True, null=True) # usageState + deletionPending = models.TextField(db_column='DELETIONPENDING', max_length=20, blank=True, null=True) # deletionPending + nsdId = models.CharField(db_column='NSDID', max_length=200) + nsdName = models.CharField(db_column='NSDNAME', max_length=200) + nsdDesginer = models.CharField(db_column='NSDDESIGNER', max_length=200, null=True, blank=True) + nsdDescription = models.CharField(db_column='NSDDESCRIPTION', max_length=200, null=True, blank=True) + nsdVersion = models.CharField(db_column='NSDVERSION', max_length=200, null=True, blank=True) + userDefinedData = models.TextField(db_column='USERDEFINEDDATA', max_length=1024, blank=True, null=True) # userDefinedData + localFilePath = models.CharField(db_column='LOCALFILEPATH', max_length=300, null=True, blank=True) + nsdModel = models.TextField(db_column='NSDMODEL', max_length=65535, null=True, blank=True) class Meta: - db_table = 'NFVO_NSPACKAGE' - -class NfPackageModel(models.Model): - uuid = models.CharField(db_column='UUID', primary_key=True, max_length=255) - nfpackageid = models.CharField(db_column='NFPACKAGEID', max_length=200) - vnfdid = models.CharField(db_column='VNFDID', max_length=255) - vendor = models.CharField(db_column='VENDOR', max_length=255) - vnfdversion = models.CharField(db_column='VNFDVERSION', max_length=255) - vnfversion = models.CharField(db_column='VNFVERSION', max_length=255) - vnfdmodel = models.TextField(db_column='VNFDMODEL', max_length=65535, blank=True, null=True) - vnfd_path = models.CharField(db_column='VNFDPATH', max_length=300, null=True, blank=True) - + db_table = 'CATALOG_NSPACKAGE' + +class VnfPackageModel(models.Model): + #uuid = models.CharField(db_column='UUID', primary_key=True, max_length=255) + vnfPackageId = models.CharField(db_column='VNFPACKAGEID', max_length=200) #onboardedVnfPkgInfoId + vnfPackageUri = models.CharField(db_column='VNFPACKAGEURI', max_length=300, null=True, blank=True) # downloadUri + SdcCSARUri = models.CharField(db_column='SDCCSARURI', max_length=300, null=True, blank=True) # SdcCSARUri + checksum = models.CharField(db_column='CHECKSUM', max_length=300, null=True, blank=True) # checksum + operationalState = models.TextField(db_column='OPERATIONALSTATE', max_length=20, blank=True,null=True) # operationalState + usageState = models.TextField(db_column='USAGESTATE', max_length=20, blank=True, null=True) # usageState + deletionPending = models.TextField(db_column='DELETIONPENDING', max_length=20, blank=True, null=True) # deletionPending + vnfdId = models.CharField(db_column='VNFDID', max_length=255) #vnfdId + vnfVendor = models.CharField(db_column='VENDOR', max_length=255) # vnfProvider + vnfdProductName = models.CharField(db_column='vnfdProductName', max_length=200) #vnfProductName + vnfdVersion = models.CharField(db_column='VNFDVERSION', max_length=255) #vnfdVersion + vnfSoftwareVersion = models.CharField(db_column='VNFSOFTWAREVERSION', max_length=255) #vnfSoftwareVersion + userDefinedData = models.TextField(db_column='USERDEFINEDDATA', max_length=1024, blank=True, null=True) # userDefinedData + localFilePath = models.CharField(db_column='LOCALFILEPATH', max_length=300, null=True, blank=True) + vnfdModel = models.TextField(db_column='VNFDMODEL', max_length=65535, blank=True, null=True) # vnfd class Meta: - db_table = 'NFVO_NFPACKAGE' + db_table = 'CATALOG_VNFPACKAGE' -class VnfPackageFileModel(models.Model): +class SoftwareImageModel(models.Model): id = models.AutoField(db_column='ID', primary_key=True) - vnfpid = models.CharField(db_column='NFPACKAGEID', max_length=50) - filename = models.CharField(db_column='FILENAME', max_length=100) - filetype = models.CharField(db_column='FILETYPE', max_length=2) + diskFormat = models.CharField(db_column='DISKFORMAT', max_length=10) + containerFormat = models.CharField(db_column='CONTAINERFORMAT', max_length=20) + diskFormat = models.CharField(db_column='DISKFORMAT', max_length=20) + mindisk = models.CharField(db_column='MINDISK', max_length=20) + minram = models.CharField(db_column='MINRAM', max_length=20) + usermetadata = models.CharField(db_column='USAERMETADATA', max_length=1024) + vnfPackageId = models.CharField(db_column='VNFPACKAGEID', max_length=50) + filePath = models.CharField(db_column='FILEPATH', max_length=100) + status = models.CharField(db_column='STATUS', max_length=10) imageid = models.CharField(db_column='IMAGEID', max_length=50) vimid = models.CharField(db_column='VIMID', max_length=50) - vimuser = models.CharField(db_column='VIMUSER', max_length=50) - tenant = models.CharField(db_column='TENANT', max_length=50) - purpose = models.CharField(db_column='PURPOSE', max_length=1000) - status = models.CharField(db_column='STATUS', max_length=10) - + #filetype = models.CharField(db_column='FILETYPE', max_length=2) + #vimuser = models.CharField(db_column='VIMUSER', max_length=50) + #tenant = models.CharField(db_column='TENANT', max_length=50) + #purpose = models.CharField(db_column='PURPOSE', max_length=1000) class Meta: - db_table = 'NFVO_NFPACKAGEFILE' - + db_table = 'CATALOG_SOFTWAREIMAGEMODEL' class JobModel(models.Model): jobid = models.CharField(db_column='JOBID', primary_key=True, max_length=255) @@ -71,7 +88,7 @@ class JobModel(models.Model): resname = models.CharField(db_column='RESNAME', max_length=255, null=True, blank=True) class Meta: - db_table = 'NFVO_JOB' + db_table = 'CATALOG_JOB' def toJSON(self): import json @@ -88,7 +105,7 @@ class JobStatusModel(models.Model): addtime = models.CharField(db_column='ADDTIME', max_length=255, null=True, blank=True) class Meta: - db_table = 'NFVO_JOB_STATUS' + db_table = 'CATALOG_JOB_STATUS' def toJSON(self): import json diff --git a/catalog/pub/msapi/nfvolcm.py b/catalog/pub/msapi/nfvolcm.py index 550679a7..619195d8 100644 --- a/catalog/pub/msapi/nfvolcm.py +++ b/catalog/pub/msapi/nfvolcm.py @@ -34,12 +34,19 @@ def call_lcm(resource, method, content=''): content=content) def get_nsInstances(csarid): - ret=call_lcm("/nlcm/v1/ns?csarId=%s"% csarid,"get") + ret=call_lcm("/nslcm/v1/ns?nsPackageId=%s"% csarid,"get") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) raise CatalogException("Failed to query NS Instances(%s) from NSLCM." % csarid) return json.JSONDecoder().decode(ret[1]) +def get_vnfInstances(csarid): + ret=call_lcm("/nslcm/v1/vnfs?vnfPackageId=%s"% csarid,"get") + if ret[0] != 0: + logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) + raise CatalogException("Failed to query VNF Instances(%s) from NSLCM." % csarid) + return json.JSONDecoder().decode(ret[1]) + # Mock code because the REST API from nfvolcm to delete ns instance is not implemented def delete_ns_inst_mock(): return [0,'success'] |