aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog/packages/tests.py475
-rw-r--r--catalog/packages/urls.py3
-rw-r--r--catalog/pub/config/config.py1
-rw-r--r--catalog/pub/database/models.py4
-rw-r--r--catalog/pub/exceptions.py1
-rw-r--r--catalog/pub/msapi/sdc.py16
-rw-r--r--catalog/pub/utils/jobutil.py2
-rw-r--r--catalog/samples/tests.py1
-rw-r--r--catalog/samples/views.py12
-rw-r--r--catalog/swagger/__init__.py9
-rw-r--r--catalog/swagger/tests.py4
-rw-r--r--catalog/swagger/urls.py3
-rw-r--r--catalog/swagger/views.py10
-rw-r--r--catalog/wsgi.py1
-rwxr-xr-xdocker/instance_run.sh2
-rw-r--r--resources/bin/initDB.sh1
-rw-r--r--resources/dbscripts/mysql/vfc-nfvo-catalog-createdb.sql2
-rw-r--r--run.sh1
-rw-r--r--stop.sh1
-rw-r--r--version.properties14
20 files changed, 279 insertions, 284 deletions
diff --git a/catalog/packages/tests.py b/catalog/packages/tests.py
index 4084a791..8482eb0b 100644
--- a/catalog/packages/tests.py
+++ b/catalog/packages/tests.py
@@ -12,18 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import json
+import os
import unittest
+
import mock
-import os
-import catalog.pub.utils.restcall
-import json
-from catalog.packages.ns_package import NsPackage
-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 NSPackageModel, VnfPackageModel, JobStatusModel, JobModel
from rest_framework import status
+
+from catalog.packages.nf_package import NfDistributeThread
+from catalog.packages.nf_package import NfPkgDeleteThread
+from catalog.packages.ns_package import NsPackage
+from catalog.pub.database.models import NSPackageModel, VnfPackageModel, JobStatusModel
from catalog.pub.msapi import nfvolcm
@@ -46,7 +46,7 @@ class PackageTest(unittest.TestCase):
},
{
"csarId": "2",
- "nsdId": "2"
+ "nsdId": "2"
}
]
@@ -54,38 +54,205 @@ class PackageTest(unittest.TestCase):
"csarId": str(self.nf_csarId)
}
- self.vnfd_json = {
- "metadata": {
- "id": "456",
- "vendor": "zte",
- "version": "5.16.10",
- "vnfd_version": "1.1.0",
- "name": "zte_xgw",
- "domain_type": "CN",
- "vnf_type": "XGW",
- "is_shared": "false",
- "cross_dc": "false",
- "vmnumber_overquota_alarm": "false",
- "description": "",
- "vnf_extend_type": "driver&script",
- "plugin_info": "zte_cn_plugin_v6.16.10",
- "script_info": "script/cn.py",
- "adjust_vnf_capacity": "true",
- "custom_properties": "",
- },
- "reserved_total": {
- "vmnum": 10,
- "vcpunum": 20,
- "memorysize": 1000,
- "portnum": 30,
- "hdsize": 1024,
- "shdsize": 2048,
- "isreserve": 0,
- },
- }
+ def tearDown(self):
+ 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]
+ 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)
+
+ @mock.patch.object(NsPackage,'get_nsd')
+ def test_ns_distribute_2(self, mock_get_nsd):
+ local_file_name = "/url/local/filename"
+ 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.assert_nsdmodel_result("VCPE_NS", 0)
+ self.assertEqual("VNF package(456) is not distributed.", response.data["statusDescription"], response.content)
+ 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 = NSPackageModel.objects.filter(nsdId="VCPE_NS")
+ self.assertEqual(len(nsdModel),0)
+
+
+ @mock.patch.object(NfDistributeThread, 'get_vnfd')
+ @mock.patch.object(NsPackage,'get_nsd')
+ def test_ns_distribute(self, mock_get_nsd,mock_get_vnfd):
+ # First distribute a VNF
+ local_file_name = "/url/local/filename"
+ 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()
+
+ # Then distribute a NS associated with the below VNF
+ local_file_name = "/url/local/filename"
+ 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_nsdmodel_result("VCPE_NS", 1)
+ 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):
+ local_file_name = "/url/local/filename"
+ vnfd = json.JSONEncoder().encode(vnfd_json)
+ mock_get_vnfd.return_value = vnfd_json,local_file_name,vnfd
+
+ NfDistributeThread("dd", ["1"], "1", "5").run()
+ self.assert_job_result("5", 100, "CSAR(dd) distribute successfully.")
+ VnfPackageModel.objects.filter(vnfPackageId="dd").delete()
+
+ @mock.patch.object(NfDistributeThread, 'get_vnfd')
+ @mock.patch.object(NsPackage,'get_nsd')
+ @mock.patch.object(nfvolcm,'get_nsInstances')
+ def test_ns_package_delete(self, mock_get_nsInstances,mock_get_nsd,mock_get_vnfd):
+
+ # First distribute a VNF
+ local_file_name = "/url/local/filename"
+ 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
+ local_file_name = "/url/local/filename"
+ 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)
+
+ # Finally delete ns package
+ mock_get_nsInstances.return_value = []
+ response = self.client.delete("/api/catalog/v1/nspackages/" + str(self.ns_csarId))
+ self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content)
+ self.assertEqual("Delete CSAR(123) successfully.", response.data["statusDescription"], response.content)
+ self.assert_nsdmodel_result("VCPE_NS", 0)
+
+ @mock.patch.object(NfDistributeThread, 'get_vnfd')
+ @mock.patch.object(NsPackage,'get_nsd')
+ @mock.patch.object(nfvolcm,'get_nsInstances')
+ def test_ns_package_delete_force(self, mock_get_nsInstances,mock_get_nsd,mock_get_vnfd):
+
+ # First distribute a VNF
+ local_file_name = "/url/local/filename"
+ 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
+ local_file_name = "/url/local/filename"
+ 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)
+
+ # Finally delete ns package
+ mock_get_nsInstances.return_value = [{"csarid":"1"},{"csarid":"2"}]
+ response = self.client.delete("/api/catalog/v1/nspackages/%sforce"% str(self.ns_csarId))
+ self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content)
+ self.assertEqual("Delete CSAR(123) successfully.", response.data["statusDescription"], response.content)
+ self.assert_nsdmodel_result("VCPE_NS", 0)
+
+ def test_nf_package_delete_error(self):
+ # Delete it directly
+ self.assert_nfmodel_result("bb",0)
+ NfPkgDeleteThread("bb", "6", False).run()
+ self.assert_job_result("6", 100, "Error! CSAR(bb) does not exist.")
+
+
+ @mock.patch.object(NfDistributeThread, 'get_vnfd')
+ def test_nf_package_delete(self,mock_get_vnfd):
+ # First distribute a VNF
+ local_file_name = "/url/local/filename"
+ vnfd = json.JSONEncoder().encode(vnfd_json)
+ mock_get_vnfd.return_value = vnfd_json,local_file_name,vnfd
+
+ NfDistributeThread("bb", ["1"], "1", "5").run()
+ self.assert_job_result("5", 100, "CSAR(bb) distribute successfully.")
+ self.assert_nfmodel_result("bb",1)
+
+ # Then delete it
+ NfPkgDeleteThread("bb", "6", False).run()
+ self.assert_nfmodel_result("bb",0)
+
+ def assert_job_result(self, job_id, job_progress, job_detail):
+ jobs = JobStatusModel.objects.filter(
+ jobid=job_id,
+ progress=job_progress,
+ descp=job_detail)
+ self.assertEqual(1, len(jobs))
+
+ def assert_nsdmodel_result(self,nsd_id,size):
+ nsdmodels = NSPackageModel.objects.filter(nsdId = nsd_id)
+ self.assertEquals(size, len(nsdmodels))
+
+ def assert_nfmodel_result(self,csar_id,size):
+ 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)
- self.nsd_json = {
+nsd_json = {
"inputs": {
"sfc_data_network": {
"type": "string",
@@ -447,205 +614,33 @@ class PackageTest(unittest.TestCase):
"description": "vcpe_ns"
}
}
- def tearDown(self):
- 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]
- 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)
-
- @mock.patch.object(NsPackage,'get_nsd')
- def test_ns_distribute_2(self, mock_get_nsd):
- local_file_name = "/url/local/filename"
- nsd = json.JSONEncoder().encode(self.nsd_json)
- mock_get_nsd.return_value = self.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.assert_nsdmodel_result("VCPE_NS", 0)
- self.assertEqual("VNF package(456) is not distributed.", response.data["statusDescription"], response.content)
- 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 = NSPackageModel.objects.filter(nsdId="VCPE_NS")
- self.assertEqual(len(nsdModel),0)
-
-
- @mock.patch.object(NfDistributeThread, 'get_vnfd')
- @mock.patch.object(NsPackage,'get_nsd')
- def test_ns_distribute(self, mock_get_nsd,mock_get_vnfd):
- # First distribute a VNF
- local_file_name = "/url/local/filename"
- vnfd = json.JSONEncoder().encode(self.vnfd_json)
- mock_get_vnfd.return_value = self.vnfd_json,local_file_name,vnfd
- NfDistributeThread(str(self.nf_csarId), ["1"], "1", "4").run()
-
- # Then distribute a NS associated with the below VNF
- local_file_name = "/url/local/filename"
- nsd = json.JSONEncoder().encode(self.nsd_json)
- mock_get_nsd.return_value = self.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_nsdmodel_result("VCPE_NS", 1)
- 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):
- local_file_name = "/url/local/filename"
- vnfd = json.JSONEncoder().encode(self.vnfd_json)
- mock_get_vnfd.return_value = self.vnfd_json,local_file_name,vnfd
-
- NfDistributeThread("dd", ["1"], "1", "5").run()
- self.assert_job_result("5", 100, "CSAR(dd) distribute successfully.")
- VnfPackageModel.objects.filter(vnfPackageId="dd").delete()
-
- @mock.patch.object(NfDistributeThread, 'get_vnfd')
- @mock.patch.object(NsPackage,'get_nsd')
- @mock.patch.object(nfvolcm,'get_nsInstances')
- def test_ns_package_delete(self, mock_get_nsInstances,mock_get_nsd,mock_get_vnfd):
-
- # First distribute a VNF
- local_file_name = "/url/local/filename"
- vnfd = json.JSONEncoder().encode(self.vnfd_json)
- mock_get_vnfd.return_value = self.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
- local_file_name = "/url/local/filename"
- nsd = json.JSONEncoder().encode(self.nsd_json)
- mock_get_nsd.return_value = self.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)
-
- # Finally delete ns package
- mock_get_nsInstances.return_value = []
- response = self.client.delete("/api/catalog/v1/nspackages/" + str(self.ns_csarId))
- self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content)
- self.assertEqual("Delete CSAR(123) successfully.", response.data["statusDescription"], response.content)
- self.assert_nsdmodel_result("VCPE_NS", 0)
-
- @mock.patch.object(NfDistributeThread, 'get_vnfd')
- @mock.patch.object(NsPackage,'get_nsd')
- @mock.patch.object(nfvolcm,'get_nsInstances')
- def test_ns_package_delete_force(self, mock_get_nsInstances,mock_get_nsd,mock_get_vnfd):
-
- # First distribute a VNF
- local_file_name = "/url/local/filename"
- vnfd = json.JSONEncoder().encode(self.vnfd_json)
- mock_get_vnfd.return_value = self.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
- local_file_name = "/url/local/filename"
- nsd = json.JSONEncoder().encode(self.nsd_json)
- mock_get_nsd.return_value = self.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)
-
- # Finally delete ns package
- mock_get_nsInstances.return_value = [{"csarid":"1"},{"csarid":"2"}]
- response = self.client.delete("/api/catalog/v1/nspackages/%sforce"% str(self.ns_csarId))
- self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.content)
- self.assertEqual("Delete CSAR(123) successfully.", response.data["statusDescription"], response.content)
- self.assert_nsdmodel_result("VCPE_NS", 0)
-
- def test_nf_package_delete_error(self):
- # Delete it directly
- self.assert_nfmodel_result("bb",0)
- NfPkgDeleteThread("bb", "6", False).run()
- self.assert_job_result("6", 100, "Error! CSAR(bb) does not exist.")
-
-
- @mock.patch.object(NfDistributeThread, 'get_vnfd')
- def test_nf_package_delete(self,mock_get_vnfd):
- # First distribute a VNF
- local_file_name = "/url/local/filename"
- vnfd = json.JSONEncoder().encode(self.vnfd_json)
- mock_get_vnfd.return_value = self.vnfd_json,local_file_name,vnfd
- NfDistributeThread("bb", ["1"], "1", "5").run()
- self.assert_job_result("5", 100, "CSAR(bb) distribute successfully.")
- self.assert_nfmodel_result("bb",1)
-
- # Then delete it
- NfPkgDeleteThread("bb", "6", False).run()
- self.assert_nfmodel_result("bb",0)
-
- def assert_job_result(self, job_id, job_progress, job_detail):
- jobs = JobStatusModel.objects.filter(
- jobid=job_id,
- progress=job_progress,
- descp=job_detail)
- self.assertEqual(1, len(jobs))
-
- def assert_nsdmodel_result(self,nsd_id,size):
- nsdmodels = NSPackageModel.objects.filter(
- nsdId = nsd_id
- )
-
- self.assertEquals(size, len(nsdmodels))
-
- def assert_nfmodel_result(self,csar_id,size):
- 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(self.vnfd_json)
- mock_get_vnfd.return_value = self.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(self.vnfd_json)
- mock_get_vnfd.return_value = self.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(self.nsd_json)
- mock_get_nsd.return_value = self.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)
+vnfd_json = {
+ "metadata": {
+ "id": "456",
+ "vendor": "zte",
+ "version": "5.16.10",
+ "vnfd_version": "1.1.0",
+ "name": "zte_xgw",
+ "domain_type": "CN",
+ "vnf_type": "XGW",
+ "is_shared": "false",
+ "cross_dc": "false",
+ "vmnumber_overquota_alarm": "false",
+ "description": "",
+ "vnf_extend_type": "driver&script",
+ "plugin_info": "zte_cn_plugin_v6.16.10",
+ "script_info": "script/cn.py",
+ "adjust_vnf_capacity": "true",
+ "custom_properties": ""
+ },
+ "reserved_total": {
+ "vmnum": 10,
+ "vcpunum": 20,
+ "memorysize": 1000,
+ "portnum": 30,
+ "hdsize": 1024,
+ "shdsize": 2048,
+ "isreserve": 0
+ }
+} \ No newline at end of file
diff --git a/catalog/packages/urls.py b/catalog/packages/urls.py
index 4ddf6883..a2b9f9d5 100644
--- a/catalog/packages/urls.py
+++ b/catalog/packages/urls.py
@@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from django.conf.urls import include, url
+from django.conf.urls import url
+
from catalog.packages import views
urlpatterns = [
diff --git a/catalog/pub/config/config.py b/catalog/pub/config/config.py
index d6acc2be..9a13876a 100644
--- a/catalog/pub/config/config.py
+++ b/catalog/pub/config/config.py
@@ -11,7 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-import os
# [MSB]
MSB_SERVICE_IP = '127.0.0.1'
diff --git a/catalog/pub/database/models.py b/catalog/pub/database/models.py
index 5b73d512..a5747a54 100644
--- a/catalog/pub/database/models.py
+++ b/catalog/pub/database/models.py
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
from django.db import models
@@ -33,6 +34,7 @@ class NSPackageModel(models.Model):
class Meta:
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', primary_key=True, max_length=50) #onboardedVnfPkgInfoId
@@ -73,6 +75,7 @@ class SoftwareImageModel(models.Model):
class Meta:
db_table = 'CATALOG_SOFTWAREIMAGEMODEL'
+
class JobModel(models.Model):
jobid = models.CharField(db_column='JOBID', primary_key=True, max_length=255)
jobtype = models.CharField(db_column='JOBTYPE', max_length=255)
@@ -109,4 +112,3 @@ class JobStatusModel(models.Model):
def toJSON(self):
import json
return json.dumps(dict([(attr, getattr(self, attr)) for attr in [f.name for f in self._meta.fields]]))
-
diff --git a/catalog/pub/exceptions.py b/catalog/pub/exceptions.py
index c994b46e..876cf07a 100644
--- a/catalog/pub/exceptions.py
+++ b/catalog/pub/exceptions.py
@@ -12,6 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
class CatalogException(Exception):
pass
diff --git a/catalog/pub/msapi/sdc.py b/catalog/pub/msapi/sdc.py
index e65af4db..2eb8f110 100644
--- a/catalog/pub/msapi/sdc.py
+++ b/catalog/pub/msapi/sdc.py
@@ -25,6 +25,7 @@ logger = logging.getLogger(__name__)
ASSETTYPE_RESOURCES = "resources"
ASSETTYPE_SERVICES = "services"
+
def call_sdc(resource, method, content=''):
additional_headers = {
'X-ECOMP-InstanceID': 'VFC',
@@ -55,6 +56,7 @@ sample of return value
}
]
"""
+
def get_artifacts(asset_type):
resource = "/sdc/v1/catalog/{assetType}"
resource = resource.format(assetType=asset_type)
@@ -64,6 +66,7 @@ def get_artifacts(asset_type):
raise CatalogException("Failed to query artifacts(%s) from sdc." % asset_type)
return json.JSONDecoder().decode(ret[1])
+
def get_artifact(asset_type, csar_id):
artifacts = get_artifacts(asset_type)
for artifact in artifacts:
@@ -71,6 +74,7 @@ def get_artifact(asset_type, csar_id):
return artifact
raise CatalogException("Failed to query artifact(%s,%s) from sdc." % (asset_type, csar_id))
+
def delete_artifact(asset_type, asset_id, artifact_id):
resource = "/sdc/v1/catalog/{assetType}/{uuid}/artifacts/{artifactUUID}"
resource = resource.format(assetType=asset_type, uuid=asset_id, artifactUUID=artifact_id)
@@ -80,6 +84,7 @@ def delete_artifact(asset_type, asset_id, artifact_id):
raise CatalogException("Failed to delete artifacts(%s) from sdc." % artifact_id)
return json.JSONDecoder().decode(ret[1])
+
def download_artifacts(download_url, local_path, file_name):
additional_headers = {
'X-ECOMP-InstanceID': 'VFC',
@@ -100,14 +105,3 @@ def download_artifacts(download_url, local_path, file_name):
local_file.write(ret[1])
local_file.close()
return local_file_name
-
-
-
-
-
-
-
-
-
-
-
diff --git a/catalog/pub/utils/jobutil.py b/catalog/pub/utils/jobutil.py
index c5e8cdf6..79f26122 100644
--- a/catalog/pub/utils/jobutil.py
+++ b/catalog/pub/utils/jobutil.py
@@ -1,4 +1,4 @@
-# Copyright 2016-2017 ZTE Corporation.
+# Copyright 2017 ZTE Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/catalog/samples/tests.py b/catalog/samples/tests.py
index f54c3727..9e4c0279 100644
--- a/catalog/samples/tests.py
+++ b/catalog/samples/tests.py
@@ -31,4 +31,3 @@ class SampleViewTest(unittest.TestCase):
self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
resp_data = json.loads(response.content)
self.assertEqual({"status": "active"}, resp_data)
-
diff --git a/catalog/samples/views.py b/catalog/samples/views.py
index bc1ebea2..b113d06f 100644
--- a/catalog/samples/views.py
+++ b/catalog/samples/views.py
@@ -15,11 +15,9 @@
import logging
import traceback
-from rest_framework.views import APIView
-from rest_framework.response import Response
from rest_framework import status
-from catalog.pub.database import models
-
+from rest_framework.response import Response
+from rest_framework.views import APIView
logger = logging.getLogger(__name__)
@@ -32,6 +30,7 @@ class SampleList(APIView):
logger.debug("get")
return Response({"status": "active"})
+
class TablesList(APIView):
def delete(self, request, modelName):
logger.debug("Start delete model %s", modelName)
@@ -47,7 +46,6 @@ class TablesList(APIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
return Response(data={}, status=status.HTTP_204_NO_CONTENT)
-
def get(self, request, modelName):
logger.debug("Get model %s", modelName)
count = 0
@@ -59,7 +57,3 @@ class TablesList(APIView):
return Response(data={"error": "failed"},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
return Response(data={"count": count}, status=status.HTTP_200_OK)
-
-
-
-
diff --git a/catalog/swagger/__init__.py b/catalog/swagger/__init__.py
index 49c7b944..c7b6818e 100644
--- a/catalog/swagger/__init__.py
+++ b/catalog/swagger/__init__.py
@@ -1,10 +1,13 @@
-# Copyright 2016-2017 ZTE Corporation.
+# Copyright 2017 ZTE Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-# http://www.apache.org/licenses/LICENSE-2.0
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/catalog/swagger/tests.py b/catalog/swagger/tests.py
index 46e3f0db..0664adb8 100644
--- a/catalog/swagger/tests.py
+++ b/catalog/swagger/tests.py
@@ -1,4 +1,4 @@
-# Copyright 2016-2017 ZTE Corporation.
+# Copyright 2017 ZTE Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -10,7 +10,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import unittest
-import json
+
from django.test import Client
from rest_framework import status
diff --git a/catalog/swagger/urls.py b/catalog/swagger/urls.py
index b807b887..a7da03d1 100644
--- a/catalog/swagger/urls.py
+++ b/catalog/swagger/urls.py
@@ -1,4 +1,4 @@
-# Copyright 2016-2017 ZTE Corporation.
+# Copyright 2017 ZTE Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
from django.conf.urls import patterns, url
from rest_framework.urlpatterns import format_suffix_patterns
diff --git a/catalog/swagger/views.py b/catalog/swagger/views.py
index 3dc4c750..2258a663 100644
--- a/catalog/swagger/views.py
+++ b/catalog/swagger/views.py
@@ -1,4 +1,4 @@
-# Copyright 2016-2017 ZTE Corporation.
+# Copyright 2017 ZTE Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -11,27 +11,21 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
import json
import logging
import os
-import traceback
-from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
-
logger = logging.getLogger(__name__)
class SwaggerJsonView(APIView):
-
def get(self, request):
-
json_file = os.path.join(os.path.dirname(__file__), 'vfc.catalog.swagger.json')
f = open(json_file)
json_data = json.JSONDecoder().decode(f.read())
f.close()
-
return Response(json_data)
- \ No newline at end of file
diff --git a/catalog/wsgi.py b/catalog/wsgi.py
index 35f6db05..a0b4d5d5 100644
--- a/catalog/wsgi.py
+++ b/catalog/wsgi.py
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
import os
from django.core.wsgi import get_wsgi_application
diff --git a/docker/instance_run.sh b/docker/instance_run.sh
index 3d894774..19d35eab 100755
--- a/docker/instance_run.sh
+++ b/docker/instance_run.sh
@@ -7,4 +7,4 @@ chmod +x run.sh
while [ ! -f logs/runtime_catalog.log ]; do
sleep 1
done
-tail -F logs/runtime_catalog.log \ No newline at end of file
+tail -F logs/runtime_catalog.log
diff --git a/resources/bin/initDB.sh b/resources/bin/initDB.sh
index 0971e00a..b4fe39ec 100644
--- a/resources/bin/initDB.sh
+++ b/resources/bin/initDB.sh
@@ -47,4 +47,3 @@ do
done
echo "init nfvocatalog database success!"
exit 0
-
diff --git a/resources/dbscripts/mysql/vfc-nfvo-catalog-createdb.sql b/resources/dbscripts/mysql/vfc-nfvo-catalog-createdb.sql
index 5e72e608..5776db4a 100644
--- a/resources/dbscripts/mysql/vfc-nfvo-catalog-createdb.sql
+++ b/resources/dbscripts/mysql/vfc-nfvo-catalog-createdb.sql
@@ -28,4 +28,4 @@ GRANT ALL PRIVILEGES ON mysql.* TO 'nfvocatalog'@'%' IDENTIFIED BY 'nfvocatalog'
GRANT ALL PRIVILEGES ON nfvocatalog.* TO 'nfvocatalog'@'localhost' IDENTIFIED BY 'nfvocatalog' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON mysql.* TO 'nfvocatalog'@'localhost' IDENTIFIED BY 'nfvocatalog' WITH GRANT OPTION;
-FLUSH PRIVILEGES; \ No newline at end of file
+FLUSH PRIVILEGES;
diff --git a/run.sh b/run.sh
index 40136547..d4c10a52 100644
--- a/run.sh
+++ b/run.sh
@@ -12,5 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
sip=127.0.0.1
nohup python manage.py runserver $sip:8806 > /dev/null &
diff --git a/stop.sh b/stop.sh
index 67aceb90..40ed3b60 100644
--- a/stop.sh
+++ b/stop.sh
@@ -12,5 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
sip=127.0.0.1
ps auxww | grep "manage.py runserver $sip:8806" | awk '{print $2}' | xargs kill -9
diff --git a/version.properties b/version.properties
index 7f86aa15..e1751011 100644
--- a/version.properties
+++ b/version.properties
@@ -1,3 +1,17 @@
+# Copyright 2017 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
# Versioning variables
# Note that these variables cannot be structured (e.g. : version.release or version.snapshot etc... )
# because they are used in Jenkins, whose plug-in doesn't support