diff options
author | 2017-09-22 14:20:28 +0800 | |
---|---|---|
committer | 2017-09-22 14:20:28 +0800 | |
commit | cdfc47f63589b2fbca73cc34f188416d78460511 (patch) | |
tree | 867d799e468074fc2fbd2ba2e3bbb62372ce6762 | |
parent | b5cb295b5f938c1f4d0004aa5df14328b0938aa3 (diff) |
Remove call nslcm logic for ns pkg api
Change-Id: Ic644cca60df5e1419fe60aef367c5e28e3474b21
Issue-Id: VFC-422
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r-- | catalog/packages/ns_package.py | 17 | ||||
-rw-r--r-- | catalog/packages/tests.py | 47 | ||||
-rw-r--r-- | catalog/pub/msapi/nslcm.py | 14 |
3 files changed, 3 insertions, 75 deletions
diff --git a/catalog/packages/ns_package.py b/catalog/packages/ns_package.py index 8eb27fcd..ec6a854c 100644 --- a/catalog/packages/ns_package.py +++ b/catalog/packages/ns_package.py @@ -21,7 +21,6 @@ import traceback from catalog.pub.config.config import CATALOG_ROOT_PATH from catalog.pub.database.models import NSPackageModel from catalog.pub.exceptions import CatalogException -from catalog.pub.msapi import nslcm from catalog.pub.msapi import sdc from catalog.pub.utils import fileutil from catalog.pub.utils import toscaparser @@ -53,7 +52,7 @@ def ns_on_distribute(csar_id): def ns_delete_csar(csar_id, force_delete): ret = None try: - ret = NsPackage().delete_csar(csar_id, force_delete) + ret = NsPackage().delete_csar(csar_id) except NSLCMException as e: return fmt_ns_pkg_rsp(STATUS_FAILED, e.message) except: @@ -144,11 +143,7 @@ class NsPackage(object): return [0, "CSAR(%s) distributed successfully." % csar_id] - def delete_csar(self, csar_id, force_delete): - if force_delete: - nslcm.delete_nf_inst(csar_id) - elif nslcm.get_nsInstances(csar_id): - raise NSLCMException("CSAR(%s) is in using, cannot be deleted." % csar_id) + def delete_csar(self, csar_id): NSDModel.objects.filter(id=csar_id).delete() return [0, "Delete CSAR(%s) successfully." % csar_id] @@ -170,14 +165,8 @@ class NsPackage(object): package_info["nsdProvider"] = csars[0].nsdDesginer package_info["nsdVersion"] = csars[0].nsdVersion - nss = nslcm.get_nsInstances(csar_id) - ns_instance_info = [{ - "nsInstanceId": ns["nsInstanceId"], - "nsInstanceName": ns["nsName"]} for ns in nss] - return [0, {"csarId": csar_id, - "packageInfo": package_info, - "nsInstanceInfo": ns_instance_info}] + "packageInfo": package_info}] def delete_catalog(self, csar_id): local_path = os.path.join(CATALOG_ROOT_PATH, csar_id) diff --git a/catalog/packages/tests.py b/catalog/packages/tests.py index 50cf15ef..50b214b6 100644 --- a/catalog/packages/tests.py +++ b/catalog/packages/tests.py @@ -59,13 +59,6 @@ class PackageTest(unittest.TestCase): 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] - response = self.client.get("/api/catalog/v1/nspackages") - self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) - self.assertEquals(self.csars,response.data) def test_nfpackages_get(self): response = self.client.get("/api/catalog/v1/vnfpackages") @@ -135,46 +128,6 @@ class PackageTest(unittest.TestCase): vnfdmodels = VnfPackageModel.objects.filter(vnfPackageId = csar_id) self.assertEquals(size, len(vnfdmodels)) - # @mock.patch.object(NfDistributeThread, 'get_vnfd') - # def test_nf_package_parser(self, mock_get_vnfd): - # # First distribute a VNF - # template_file_name = "resource-TestFyx-template.yml" - # local_file_name = os.path.join(os.path.dirname(__file__), template_file_name) - # vnfd = json.JSONEncoder().encode(vnfd_json) - # mock_get_vnfd.return_value = vnfd_json,local_file_name,vnfd - # NfDistributeThread(str(self.nf_csarId), ["1"], "1", "4").run() - # self.assert_nfmodel_result(str(self.nf_csarId), 1) - # reqdata={"csarId":"456"} - # #response = self.client.post("/api/catalog/v1/parservnfd",reqdata) - # #self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content) - # - # @mock.patch.object(NfDistributeThread, 'get_vnfd') - # @mock.patch.object(NsPackage,'get_nsd') - # def test_ns_package_parser(self, mock_get_nsd,mock_get_vnfd): - # # First distribute a VNF - # template_file_name = "resource-TestFyx-template.yml" - # local_file_name = os.path.join(os.path.dirname(__file__), template_file_name) - # vnfd = json.JSONEncoder().encode(vnfd_json) - # mock_get_vnfd.return_value = vnfd_json,local_file_name,vnfd - # NfDistributeThread(str(self.nf_csarId), ["1"], "1", "4").run() - # self.assert_nfmodel_result(str(self.nf_csarId), 1) - # - # # Then distribute a NS associated with the below VNF - # template_file_name = "service-TestServiceFyx-template.yml" - # local_file_name = os.path.join(os.path.dirname(__file__), template_file_name) - # nsd = json.JSONEncoder().encode(nsd_json) - # mock_get_nsd.return_value = nsd_json,local_file_name,nsd - # response = self.client.post("/api/catalog/v1/nspackages",self.nsdata) - # self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content) - # self.assertEqual("CSAR(123) distributed successfully.", response.data["statusDescription"], response.content) - # self.assert_nfmodel_result(str(self.nf_csarId), 1) - # self.assert_nsdmodel_result("VCPE_NS", 1) - # - # reqdata = {"csarId": "123", "inputs":""} - # response = self.client.post("/api/catalog/v1/parsernsd",reqdata) - # #self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content) - - nsd_json = { "inputs": { "sfc_data_network": { diff --git a/catalog/pub/msapi/nslcm.py b/catalog/pub/msapi/nslcm.py index 27054b01..16c3996e 100644 --- a/catalog/pub/msapi/nslcm.py +++ b/catalog/pub/msapi/nslcm.py @@ -16,24 +16,10 @@ import json import logging from catalog.pub.exceptions import CatalogException from catalog.pub.utils import restcall -from catalog.pub.config.config import NFVOLCM_BASE_URL,NFVOLCM_USER,NFVOLCM_PASSWD from catalog.pub.utils.restcall import req_by_msb logger = logging.getLogger(__name__) -# ASSETTYPE_RESOURCES = "resources" -# ASSETTYPE_SERVICES = "services" - - -# def call_lcm(resource, method, content=''): -# return restcall.call_req(base_url=NFVOLCM_BASE_URL, -# user="", -# passwd="", -# auth_type=restcall.rest_no_auth, -# resource=resource, -# method=method, -# content=content) - def get_nsInstances(csarid): ret=req_by_msb("/nslcm/v1/ns?nsPackageId=%s"% csarid, "GET") |