diff options
-rw-r--r-- | LICENSE | 2 | ||||
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | assembly.xml | 8 | ||||
-rw-r--r-- | catalog/__init__.py (renamed from genericparser/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/jobs/__init__.py (renamed from genericparser/jobs/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/jobs/job_get.py (renamed from genericparser/jobs/job_get.py) | 2 | ||||
-rw-r--r-- | catalog/jobs/tests/__init__.py (renamed from genericparser/jobs/tests/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/jobs/tests/tests.py (renamed from genericparser/jobs/tests/tests.py) | 6 | ||||
-rw-r--r-- | catalog/jobs/urls.py (renamed from genericparser/jobs/urls.py) | 4 | ||||
-rw-r--r-- | catalog/jobs/views.py (renamed from genericparser/jobs/views.py) | 12 | ||||
-rw-r--r-- | catalog/log.yml (renamed from genericparser/log.yml) | 14 | ||||
-rw-r--r-- | catalog/middleware.py (renamed from genericparser/middleware.py) | 2 | ||||
-rw-r--r-- | catalog/packages/__init__.py (renamed from genericparser/packages/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/packages/biz/__init__.py (renamed from genericparser/packages/biz/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/packages/biz/common.py (renamed from genericparser/packages/biz/common.py) | 6 | ||||
-rw-r--r-- | catalog/packages/biz/ns_descriptor.py (renamed from genericparser/packages/biz/ns_descriptor.py) | 34 | ||||
-rw-r--r-- | catalog/packages/biz/nsdm_subscription.py (renamed from genericparser/packages/biz/nsdm_subscription.py) | 20 | ||||
-rw-r--r-- | catalog/packages/biz/pnf_descriptor.py (renamed from genericparser/packages/biz/pnf_descriptor.py) | 44 | ||||
-rw-r--r-- | catalog/packages/biz/sdc_ns_package.py (renamed from genericparser/packages/biz/sdc_ns_package.py) | 36 | ||||
-rw-r--r-- | catalog/packages/biz/sdc_service_package.py (renamed from genericparser/packages/biz/sdc_service_package.py) | 22 | ||||
-rw-r--r-- | catalog/packages/biz/sdc_vnf_package.py (renamed from genericparser/packages/biz/sdc_vnf_package.py) | 48 | ||||
-rw-r--r-- | catalog/packages/biz/service_descriptor.py (renamed from genericparser/packages/biz/service_descriptor.py) | 25 | ||||
-rw-r--r-- | catalog/packages/biz/vnf_package.py (renamed from genericparser/packages/biz/vnf_package.py) | 38 | ||||
-rw-r--r-- | catalog/packages/biz/vnf_pkg_artifacts.py (renamed from genericparser/packages/biz/vnf_pkg_artifacts.py) | 6 | ||||
-rw-r--r-- | catalog/packages/biz/vnf_pkg_subscription.py (renamed from genericparser/packages/biz/vnf_pkg_subscription.py) | 8 | ||||
-rw-r--r-- | catalog/packages/const.py (renamed from genericparser/packages/const.py) | 2 | ||||
-rw-r--r-- | catalog/packages/serializers/__init__.py (renamed from genericparser/packages/serializers/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/catalog_serializers.py (renamed from genericparser/packages/serializers/genericparser_serializers.py) | 4 | ||||
-rw-r--r-- | catalog/packages/serializers/checksum.py (renamed from genericparser/packages/serializers/checksum.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/create_nsd_info_request.py (renamed from genericparser/packages/serializers/create_nsd_info_request.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/create_pnfd_info_request.py (renamed from genericparser/packages/serializers/create_pnfd_info_request.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/create_vnf_pkg_info_req.py (renamed from genericparser/packages/serializers/create_vnf_pkg_info_req.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/link.py (renamed from genericparser/packages/serializers/link.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/nsd_info.py (renamed from genericparser/packages/serializers/nsd_info.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/nsd_infos.py (renamed from genericparser/packages/serializers/nsd_infos.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/nsdm_filter_data.py (renamed from genericparser/packages/serializers/nsdm_filter_data.py) | 2 | ||||
-rw-r--r-- | catalog/packages/serializers/nsdm_subscription.py (renamed from genericparser/packages/serializers/nsdm_subscription.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/pnfd_info.py (renamed from genericparser/packages/serializers/pnfd_info.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/pnfd_infos.py (renamed from genericparser/packages/serializers/pnfd_infos.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/problem_details.py (renamed from genericparser/packages/serializers/problem_details.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/response.py (renamed from genericparser/packages/serializers/response.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/subscription_auth_data.py (renamed from genericparser/packages/serializers/subscription_auth_data.py) | 2 | ||||
-rw-r--r-- | catalog/packages/serializers/upload_vnf_pkg_from_uri_req.py (renamed from genericparser/packages/serializers/upload_vnf_pkg_from_uri_req.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/vnf_pkg_artifact_info.py (renamed from genericparser/packages/serializers/vnf_pkg_artifact_info.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/vnf_pkg_info.py (renamed from genericparser/packages/serializers/vnf_pkg_info.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/vnf_pkg_infos.py (renamed from genericparser/packages/serializers/vnf_pkg_infos.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/vnf_pkg_notifications.py (renamed from genericparser/packages/serializers/vnf_pkg_notifications.py) | 2 | ||||
-rw-r--r-- | catalog/packages/serializers/vnf_pkg_software_image_info.py (renamed from genericparser/packages/serializers/vnf_pkg_software_image_info.py) | 0 | ||||
-rw-r--r-- | catalog/packages/serializers/vnf_pkg_subscription.py (renamed from genericparser/packages/serializers/vnf_pkg_subscription.py) | 4 | ||||
-rw-r--r-- | catalog/packages/tests/__init__.py (renamed from genericparser/packages/tests/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/packages/tests/const.py (renamed from genericparser/packages/tests/const.py) | 0 | ||||
-rw-r--r-- | catalog/packages/tests/test_health_check.py (renamed from genericparser/packages/tests/test_health_check.py) | 6 | ||||
-rw-r--r-- | catalog/packages/tests/test_ns_descriptor.py (renamed from genericparser/packages/tests/test_ns_descriptor.py) | 28 | ||||
-rw-r--r-- | catalog/packages/tests/test_nsdm_subscription.py (renamed from genericparser/packages/tests/test_nsdm_subscription.py) | 20 | ||||
-rw-r--r-- | catalog/packages/tests/test_nspackage.py (renamed from genericparser/packages/tests/test_nspackage.py) | 46 | ||||
-rw-r--r-- | catalog/packages/tests/test_pnf_descriptor.py (renamed from genericparser/packages/tests/test_pnf_descriptor.py) | 31 | ||||
-rw-r--r-- | catalog/packages/tests/test_service_descriptor.py (renamed from genericparser/packages/tests/test_service_descriptor.py) | 12 | ||||
-rw-r--r-- | catalog/packages/tests/test_servicepackage.py (renamed from genericparser/packages/tests/test_servicepackage.py) | 26 | ||||
-rw-r--r-- | catalog/packages/tests/test_vnf_package.py (renamed from genericparser/packages/tests/test_vnf_package.py) | 61 | ||||
-rw-r--r-- | catalog/packages/tests/test_vnf_pkg_subscription.py (renamed from genericparser/packages/tests/test_vnf_pkg_subscription.py) | 2 | ||||
-rw-r--r-- | catalog/packages/tests/test_vnfpackage.py (renamed from genericparser/packages/tests/test_vnfpackage.py) | 109 | ||||
-rw-r--r-- | catalog/packages/urls.py (renamed from genericparser/packages/urls.py) | 22 | ||||
-rw-r--r-- | catalog/packages/views/__init__.py (renamed from genericparser/packages/views/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/packages/views/catalog_views.py (renamed from genericparser/packages/views/catalog_views.py) | 36 | ||||
-rw-r--r-- | catalog/packages/views/common.py (renamed from genericparser/packages/views/common.py) | 22 | ||||
-rw-r--r-- | catalog/packages/views/health_check_views.py (renamed from genericparser/packages/views/health_check_views.py) | 0 | ||||
-rw-r--r-- | catalog/packages/views/ns_descriptor_views.py (renamed from genericparser/packages/views/ns_descriptor_views.py) | 22 | ||||
-rw-r--r-- | catalog/packages/views/nsdm_subscription_views.py (renamed from genericparser/packages/views/nsdm_subscription_views.py) | 16 | ||||
-rw-r--r-- | catalog/packages/views/pnf_descriptor_views.py (renamed from genericparser/packages/views/pnf_descriptor_views.py) | 30 | ||||
-rw-r--r-- | catalog/packages/views/vnf_package_artifact_views.py (renamed from genericparser/packages/views/vnf_package_artifact_views.py) | 4 | ||||
-rw-r--r-- | catalog/packages/views/vnf_package_subscription_views.py (renamed from genericparser/packages/views/vnf_package_subscription_views.py) | 21 | ||||
-rw-r--r-- | catalog/packages/views/vnf_package_views.py (renamed from genericparser/packages/views/vnf_package_views.py) | 29 | ||||
-rw-r--r-- | catalog/pub/__init__.py (renamed from genericparser/pub/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/pub/config/__init__.py (renamed from genericparser/pub/config/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/pub/config/config.py (renamed from genericparser/pub/config/config.py) | 23 | ||||
-rw-r--r-- | catalog/pub/database/__init__.py (renamed from genericparser/pub/database/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/pub/database/admin.py (renamed from genericparser/pub/database/admin.py) | 18 | ||||
-rw-r--r-- | catalog/pub/database/migrations/0001_initial.py (renamed from genericparser/pub/database/migrations/0001_initial.py) | 0 | ||||
-rw-r--r-- | catalog/pub/database/migrations/__init__.py (renamed from genericparser/pub/database/migrations/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/pub/database/models.py (renamed from genericparser/pub/database/models.py) | 16 | ||||
-rw-r--r-- | catalog/pub/exceptions.py (renamed from genericparser/pub/exceptions.py) | 22 | ||||
-rw-r--r-- | catalog/pub/msapi/__init__.py (renamed from genericparser/pub/msapi/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/pub/msapi/extsys.py (renamed from genericparser/pub/msapi/extsys.py) | 22 | ||||
-rw-r--r-- | catalog/pub/msapi/sdc.py (renamed from genericparser/pub/msapi/sdc.py) | 27 | ||||
-rw-r--r-- | catalog/pub/redisco/__init__.py (renamed from genericparser/pub/redisco/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/pub/redisco/containers.py (renamed from genericparser/pub/redisco/containers.py) | 0 | ||||
-rw-r--r-- | catalog/pub/ssl/cert/foobar.crt (renamed from genericparser/pub/ssl/cert/foobar.crt) | 0 | ||||
-rw-r--r-- | catalog/pub/ssl/cert/foobar.csr (renamed from genericparser/pub/ssl/cert/foobar.csr) | 0 | ||||
-rw-r--r-- | catalog/pub/ssl/cert/foobar.key (renamed from genericparser/pub/ssl/cert/foobar.key) | 0 | ||||
-rw-r--r-- | catalog/pub/utils/__init__.py (renamed from genericparser/pub/utils/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/pub/utils/fileutil.py (renamed from genericparser/pub/utils/fileutil.py) | 0 | ||||
-rw-r--r-- | catalog/pub/utils/idutil.py (renamed from genericparser/pub/utils/idutil.py) | 2 | ||||
-rw-r--r-- | catalog/pub/utils/jobutil.py (renamed from genericparser/pub/utils/jobutil.py) | 4 | ||||
-rw-r--r-- | catalog/pub/utils/restcall.py (renamed from genericparser/pub/utils/restcall.py) | 2 | ||||
-rw-r--r-- | catalog/pub/utils/syscomm.py (renamed from genericparser/pub/utils/syscomm.py) | 0 | ||||
-rw-r--r-- | catalog/pub/utils/tests.py (renamed from genericparser/pub/utils/tests.py) | 4 | ||||
-rw-r--r-- | catalog/pub/utils/timeutil.py (renamed from genericparser/pub/utils/timeutil.py) | 0 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/__init__.py (renamed from genericparser/pub/utils/toscaparsers/__init__.py) | 8 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/basemodel.py (renamed from genericparser/pub/utils/toscaparsers/basemodel.py) | 19 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/const.py (renamed from genericparser/pub/utils/toscaparsers/const.py) | 0 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/dataentityext.py (renamed from genericparser/pub/utils/toscaparsers/dataentityext.py) | 0 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/graph.py (renamed from genericparser/pub/utils/toscaparsers/graph.py) | 0 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/nsdmodel.py (renamed from genericparser/pub/utils/toscaparsers/nsdmodel.py) | 6 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/pnfmodel.py (renamed from genericparser/pub/utils/toscaparsers/pnfmodel.py) | 2 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/sdmodel.py (renamed from genericparser/pub/utils/toscaparsers/sdmodel.py) | 4 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/servicemodel.py (renamed from genericparser/pub/utils/toscaparsers/servicemodel.py) | 4 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/ns/ran.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/ns/ran.csar) | bin | 3007 -> 3007 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/ns/service-vIMS.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/ns/service-vIMS.csar) | bin | 47518 -> 47518 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/pnf/ran-du.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/pnf/ran-du.csar) | bin | 2688 -> 2688 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vSBC.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vSBC.csar) | bin | 11516 -> 11516 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/infra.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/infra.csar) | bin | 15716 -> 15716 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbng.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vbng.csar) | bin | 15357 -> 15357 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbrgemu.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vbrgemu.csar) | bin | 14527 -> 14527 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgmux.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vgmux.csar) | bin | 14970 -> 14970 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgw.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vgw.csar) | bin | 15008 -> 15008 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/infra.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/infra.csar) | bin | 15432 -> 15432 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbng.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vbng.csar) | bin | 15410 -> 15410 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbrgemu.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vbrgemu.csar) | bin | 14569 -> 14569 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgmux.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vgmux.csar) | bin | 15023 -> 15023 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar (renamed from genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vgw.csar) | bin | 23182 -> 23182 bytes | |||
-rw-r--r-- | catalog/pub/utils/toscaparser/tests.py (renamed from genericparser/pub/utils/toscaparsers/tests.py) | 7 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/vnfdmodel.py (renamed from genericparser/pub/utils/toscaparsers/vnfdmodel.py) | 6 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/vnfdparser/__init__.py (renamed from genericparser/pub/utils/toscaparsers/vnfdparser/__init__.py) | 5 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_251.py (renamed from genericparser/pub/utils/toscaparsers/vnfdparser/vnfd_sol_251.py) | 46 | ||||
-rw-r--r-- | catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_base.py (renamed from genericparser/pub/utils/toscaparsers/vnfdparser/vnfd_sol_base.py) | 0 | ||||
-rw-r--r-- | catalog/pub/utils/values.py (renamed from genericparser/pub/utils/values.py) | 0 | ||||
-rw-r--r-- | catalog/samples/__init__.py (renamed from genericparser/samples/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/samples/tests.py (renamed from genericparser/samples/tests.py) | 2 | ||||
-rw-r--r-- | catalog/samples/urls.py (renamed from genericparser/samples/urls.py) | 6 | ||||
-rw-r--r-- | catalog/samples/views.py (renamed from genericparser/samples/views.py) | 0 | ||||
-rw-r--r-- | catalog/settings.py (renamed from genericparser/settings.py) | 48 | ||||
-rw-r--r-- | catalog/swagger/__init__.py (renamed from genericparser/swagger/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/swagger/management/__init__.py (renamed from genericparser/swagger/management/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/swagger/management/commands/__init__.py (renamed from genericparser/swagger/management/commands/__init__.py) | 0 | ||||
-rw-r--r-- | catalog/swagger/management/commands/export_swagger.py (renamed from genericparser/swagger/management/commands/export_swagger.py) | 2 | ||||
-rw-r--r-- | catalog/swagger/tests.py (renamed from genericparser/swagger/tests.py) | 2 | ||||
-rw-r--r-- | catalog/swagger/urls.py (renamed from genericparser/swagger/urls.py) | 18 | ||||
-rw-r--r-- | catalog/swagger/vfc.catalog.swagger.json | 793 | ||||
-rw-r--r-- | catalog/swagger/views.py (renamed from genericparser/swagger/views.py) | 2 | ||||
-rw-r--r-- | catalog/urls.py (renamed from genericparser/urls.py) | 19 | ||||
-rw-r--r-- | catalog/wsgi.py (renamed from genericparser/wsgi.py) | 2 | ||||
-rw-r--r-- | docker/Dockerfile | 2 | ||||
-rwxr-xr-x | docker/build_image.sh | 2 | ||||
-rwxr-xr-x | docker/docker-entrypoint.sh | 6 | ||||
-rwxr-xr-x | docker/docker-env-conf.sh | 10 | ||||
-rwxr-xr-x | docker/instance_config.sh | 16 | ||||
-rwxr-xr-x | docker/instance_init.sh | 4 | ||||
-rwxr-xr-x | docker/instance_run.sh | 6 | ||||
-rw-r--r-- | genericparser/pub/database/migrations/0002_auto_20190422_1442.py | 47 | ||||
-rw-r--r-- | manage.py | 2 | ||||
-rw-r--r-- | pom.xml | 8 | ||||
-rwxr-xr-x | resources/bin/initDB.sh | 8 | ||||
-rw-r--r-- | resources/dbscripts/mysql/modeling-etsicatalog-createdb.sql (renamed from resources/dbscripts/mysql/modeling-gengricparser-createdb.sql) | 8 | ||||
-rwxr-xr-x | run.sh | 8 | ||||
-rw-r--r-- | static/catalog/empty.txt (renamed from static/genericparser/empty.txt) | 0 | ||||
-rw-r--r-- | static/catalog/resource_test.csar (renamed from static/genericparser/resource_test.csar) | bin | 227 -> 227 bytes | |||
-rw-r--r-- | tox.ini | 2 |
157 files changed, 1486 insertions, 688 deletions
@@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Micro service of modeling genericparser. +# Micro service of modeling etsicatalog. @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Micro service of generic parser. +# Micro service of etsicatalog. 1. Code structure guide ./ project files @@ -29,6 +29,6 @@ ./tests All the test case. At least each API should have a test case ./jobs Related job ./pub Common class, including database, external micro service API, utils, and config parameters. - ./samples generic parser micro service health check - ./swagger Auto-generate generic parser swagger json or yaml files - ./static/genericparser package storage + ./samples Catalog micro service health check + ./swagger Auto-generate catalog swagger json or yaml files + ./static/catalog package storage diff --git a/assembly.xml b/assembly.xml index b2ef1aa..0eb35f0 100644 --- a/assembly.xml +++ b/assembly.xml @@ -16,14 +16,14 @@ <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> - <id>genericparser</id> + <id>etsicatalog</id> <formats> <format>zip</format> </formats> <fileSets> <fileSet> - <directory>genericparser</directory> - <outputDirectory>/genericparser</outputDirectory> + <directory>etsicatalog</directory> + <outputDirectory>/etsicatalog</outputDirectory> <includes> <include>**/*.py</include> <include>**/*.json</include> @@ -76,5 +76,5 @@ </includes> </fileSet> </fileSets> - <baseDirectory>modeling/genericparser</baseDirectory> + <baseDirectory>modeling/etsicatalog</baseDirectory> </assembly> diff --git a/genericparser/__init__.py b/catalog/__init__.py index 68cf954..68cf954 100644 --- a/genericparser/__init__.py +++ b/catalog/__init__.py diff --git a/genericparser/jobs/__init__.py b/catalog/jobs/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/jobs/__init__.py +++ b/catalog/jobs/__init__.py diff --git a/genericparser/jobs/job_get.py b/catalog/jobs/job_get.py index 56e20b6..32ee243 100644 --- a/genericparser/jobs/job_get.py +++ b/catalog/jobs/job_get.py @@ -13,7 +13,7 @@ # limitations under the License. import logging -from genericparser.pub.utils.jobutil import JobUtil +from catalog.pub.utils.jobutil import JobUtil logger = logging.getLogger(__name__) diff --git a/genericparser/jobs/tests/__init__.py b/catalog/jobs/tests/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/jobs/tests/__init__.py +++ b/catalog/jobs/tests/__init__.py diff --git a/genericparser/jobs/tests/tests.py b/catalog/jobs/tests/tests.py index 3cdcd72..460c854 100644 --- a/genericparser/jobs/tests/tests.py +++ b/catalog/jobs/tests/tests.py @@ -14,7 +14,7 @@ from django.test import TestCase, Client from rest_framework import status -from genericparser.pub.database.models import JobModel, JobStatusModel +from catalog.pub.database.models import JobModel, JobStatusModel class JobsViewTest(TestCase): @@ -28,13 +28,13 @@ class JobsViewTest(TestCase): def test_job_normal(self): JobModel(jobid=self.job_id, jobtype='VNF', jobaction='INST', resid='1').save() JobStatusModel(indexid=1, jobid=self.job_id, status='inst', errcode='0', progress=20, descp='inst').save() - response = self.client.get("/api/parser/v1/jobs/%s" % self.job_id) + response = self.client.get("/api/catalog/v1/jobs/%s" % self.job_id) self.assertEqual(status.HTTP_200_OK, response.status_code) def test_job_when_jobid_not_exist(self): job_id = 'test_new_job_id' JobModel(jobid=self.job_id, jobtype='VNF', jobaction='INST', resid='1').save() JobStatusModel(indexid=1, jobid=self.job_id, status='inst', progress=20, descp='inst').save() - response = self.client.get("/api/parser/v1/jobs/%s" % job_id) + response = self.client.get("/api/catalog/v1/jobs/%s" % job_id) self.assertIn('jobId', response.data) self.assertNotIn('responseDescriptor', response.data) diff --git a/genericparser/jobs/urls.py b/catalog/jobs/urls.py index 5cea865..ea1fcd6 100644 --- a/genericparser/jobs/urls.py +++ b/catalog/jobs/urls.py @@ -13,8 +13,8 @@ # limitations under the License. from django.conf.urls import url -from genericparser.jobs.views import JobView +from catalog.jobs.views import JobView urlpatterns = [ - url(r'^api/parser/v1/jobs/(?P<job_id>[0-9a-zA-Z_-]+)$', JobView.as_view()), + url(r'^api/catalog/v1/jobs/(?P<job_id>[0-9a-zA-Z_-]+)$', JobView.as_view()), ] diff --git a/genericparser/jobs/views.py b/catalog/jobs/views.py index b9c5121..123af00 100644 --- a/genericparser/jobs/views.py +++ b/catalog/jobs/views.py @@ -19,12 +19,12 @@ from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView -from genericparser.jobs.job_get import GetJobInfoService -from genericparser.packages.serializers.genericparser_serializers import GetJobResponseSerializer -from genericparser.packages.serializers.genericparser_serializers import PostJobRequestSerializer -from genericparser.packages.serializers.genericparser_serializers import PostJobResponseResultSerializer -from genericparser.pub.utils.jobutil import JobUtil -from genericparser.pub.utils.values import ignore_case_get +from catalog.jobs.job_get import GetJobInfoService +from catalog.packages.serializers.catalog_serializers import GetJobResponseSerializer +from catalog.packages.serializers.catalog_serializers import PostJobRequestSerializer +from catalog.packages.serializers.catalog_serializers import PostJobResponseResultSerializer +from catalog.pub.utils.jobutil import JobUtil +from catalog.pub.utils.values import ignore_case_get logger = logging.getLogger(__name__) diff --git a/genericparser/log.yml b/catalog/log.yml index 602cd40..5ac5fef 100644 --- a/genericparser/log.yml +++ b/catalog/log.yml @@ -2,8 +2,8 @@ version: 1 disable_existing_loggers: False loggers: - genericparser: - handlers: [genericparserlocal_handler, genericparser_handler] + catalog: + handlers: [cataloglocal_handler, catalog_handler] level: "DEBUG" propagate: False django: @@ -11,24 +11,24 @@ loggers: level: "DEBUG" propagate: False tosca: - handlers: [genericparserlocal_handler, genericparser_handler] + handlers: [cataloglocal_handler, catalog_handler] level: "DEBUG" propagate: False handlers: - genericparserlocal_handler: + cataloglocal_handler: level: "DEBUG" class: "logging.handlers.RotatingFileHandler" - filename: "logs/runtime_genericparser.log" + filename: "logs/runtime_catalog.log" formatter: "standard" maxBytes: 52428800 backupCount: 10 - genericparser_handler: + catalog_handler: level: "DEBUG" class: "logging.handlers.RotatingFileHandler" - filename: "/var/log/onap/modeling/genericparser/runtime_genericparser.log" + filename: "/var/log/onap/modeling/etsicatalog/runtime_catalog.log" formatter: "mdcFormat" maxBytes: 52428800 diff --git a/genericparser/middleware.py b/catalog/middleware.py index 8cb8f45..cd6aa8b 100644 --- a/genericparser/middleware.py +++ b/catalog/middleware.py @@ -13,7 +13,7 @@ import uuid from onaplogging.mdcContext import MDC -from genericparser.pub.config.config import FORWARDED_FOR_FIELDS, SERVICE_NAME +from catalog.pub.config.config import FORWARDED_FOR_FIELDS, SERVICE_NAME class LogContextMiddleware(object): diff --git a/genericparser/packages/__init__.py b/catalog/packages/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/packages/__init__.py +++ b/catalog/packages/__init__.py diff --git a/genericparser/packages/biz/__init__.py b/catalog/packages/biz/__init__.py index 342c2a8..342c2a8 100644 --- a/genericparser/packages/biz/__init__.py +++ b/catalog/packages/biz/__init__.py diff --git a/genericparser/packages/biz/common.py b/catalog/packages/biz/common.py index 9b72b63..ce77a41 100644 --- a/genericparser/packages/biz/common.py +++ b/catalog/packages/biz/common.py @@ -14,15 +14,15 @@ import os -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH -from genericparser.pub.utils import fileutil +from catalog.pub.config.config import CATALOG_ROOT_PATH +from catalog.pub.utils import fileutil CHUNK_SIZE = 1024 * 8 def save(remote_file, vnf_pkg_id): local_file_name = remote_file.name - local_file_dir = os.path.join(GENERICPARSER_ROOT_PATH, vnf_pkg_id) + local_file_dir = os.path.join(CATALOG_ROOT_PATH, vnf_pkg_id) local_file_name = os.path.join(local_file_dir, local_file_name) if not os.path.exists(local_file_dir): fileutil.make_dirs(local_file_dir) diff --git a/genericparser/packages/biz/ns_descriptor.py b/catalog/packages/biz/ns_descriptor.py index 60d4a26..f0e0572 100644 --- a/genericparser/packages/biz/ns_descriptor.py +++ b/catalog/packages/biz/ns_descriptor.py @@ -18,13 +18,13 @@ import logging import os import uuid -from genericparser.packages.biz.common import parse_file_range, read, save -from genericparser.packages.const import PKG_STATUS -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH -from genericparser.pub.database.models import NSPackageModel, PnfPackageModel, VnfPackageModel -from genericparser.pub.exceptions import GenericparserException, ResourceNotFoundException -from genericparser.pub.utils import fileutil, toscaparsers -from genericparser.pub.utils.values import ignore_case_get +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 +from catalog.pub.utils import fileutil, toscaparser +from catalog.pub.utils.values import ignore_case_get logger = logging.getLogger(__name__) @@ -84,13 +84,13 @@ class NsDescriptor(object): ''' if ns_pkgs[0].operationalState != PKG_STATUS.DISABLED: logger.error('NSD(%s) shall be DISABLED.' % nsd_info_id) - raise GenericparserException('NSD(%s) shall be DISABLED.' % nsd_info_id) + raise CatalogException('NSD(%s) shall be DISABLED.' % nsd_info_id) if ns_pkgs[0].usageState != PKG_STATUS.NOT_IN_USE: logger.error('NSD(%s) shall be NOT_IN_USE.' % nsd_info_id) - raise GenericparserException('NSD(%s) shall be NOT_IN_USE.' % nsd_info_id) + raise CatalogException('NSD(%s) shall be NOT_IN_USE.' % nsd_info_id) ''' ns_pkgs.delete() - ns_pkg_path = os.path.join(GENERICPARSER_ROOT_PATH, nsd_info_id) + ns_pkg_path = os.path.join(CATALOG_ROOT_PATH, nsd_info_id) fileutil.delete_dirs(ns_pkg_path) logger.info('NSD(%s) has been deleted.' % nsd_info_id) @@ -99,7 +99,7 @@ class NsDescriptor(object): ns_pkgs = NSPackageModel.objects.filter(nsPackageId=nsd_info_id) if not ns_pkgs.exists(): logger.error('NSD(%s) does not exist.' % nsd_info_id) - raise GenericparserException('NSD(%s) does not exist.' % nsd_info_id) + raise CatalogException('NSD(%s) does not exist.' % nsd_info_id) ns_pkgs.update(onboardingState=PKG_STATUS.UPLOADING) local_file_name = save(remote_file, nsd_info_id) @@ -114,7 +114,7 @@ class NsDescriptor(object): raise ResourceNotFoundException('NSD(%s) does not exist.' % nsd_info_id) if ns_pkgs[0].onboardingState != PKG_STATUS.ONBOARDED: logger.error('NSD(%s) is not ONBOARDED.' % nsd_info_id) - raise GenericparserException('NSD(%s) is not ONBOARDED.' % nsd_info_id) + raise CatalogException('NSD(%s) is not ONBOARDED.' % nsd_info_id) local_file_path = ns_pkgs[0].localFilePath start, end = parse_file_range(local_file_path, file_range) @@ -126,7 +126,7 @@ class NsDescriptor(object): ns_pkgs = NSPackageModel.objects.filter(nsPackageId=nsd_info_id) ns_pkgs.update(onboardingState=PKG_STATUS.PROCESSING) - nsd_json = toscaparsers.parse_nsd(local_file_name) + nsd_json = toscaparser.parse_nsd(local_file_name) logger.debug("%s", nsd_json) nsd = json.JSONDecoder().decode(nsd_json) @@ -136,11 +136,11 @@ class NsDescriptor(object): nsd_designer = nsd.get("ns", {}).get("properties", {}).get("designer", "") invariant_id = nsd.get("ns", {}).get("properties", {}).get("invariant_id", "") if nsd_id == "": - raise GenericparserException("nsd_id(%s) does not exist in metadata." % nsd_id) + raise CatalogException("nsd_id(%s) does not exist in metadata." % nsd_id) other_nspkg = NSPackageModel.objects.filter(nsdId=nsd_id) if other_nspkg and other_nspkg[0].nsPackageId != nsd_info_id: logger.warn("NSD(%s,%s) already exists.", nsd_id, other_nspkg[0].nsPackageId) - raise GenericparserException("NSD(%s) already exists." % nsd_id) + raise CatalogException("NSD(%s) already exists." % nsd_id) for vnf in nsd["vnfs"]: vnfd_id = vnf["properties"].get("descriptor_id", "undefined") @@ -152,7 +152,7 @@ class NsDescriptor(object): if not pkg: vnfd_name = vnf.get("vnf_id", "undefined") logger.error("[%s] is not distributed.", vnfd_name) - raise GenericparserException("VNF package(%s) is not distributed." % vnfd_id) + raise CatalogException("VNF package(%s) is not distributed." % vnfd_id) for pnf in nsd["pnfs"]: pnfd_id = pnf["properties"].get("descriptor_id", "undefined") @@ -164,7 +164,7 @@ class NsDescriptor(object): if not pkg: pnfd_name = pnf.get("pnf_id", "undefined") logger.error("[%s] is not distributed.", pnfd_name) - raise GenericparserException("PNF package(%s) is not distributed." % pnfd_name) + raise CatalogException("PNF package(%s) is not distributed." % pnfd_name) ns_pkgs.update( nsdId=nsd_id, diff --git a/genericparser/packages/biz/nsdm_subscription.py b/catalog/packages/biz/nsdm_subscription.py index dfcd2ec..e2af6e4 100644 --- a/genericparser/packages/biz/nsdm_subscription.py +++ b/catalog/packages/biz/nsdm_subscription.py @@ -22,12 +22,12 @@ from collections import Counter from rest_framework import status -from genericparser.packages import const -from genericparser.pub.database.models import NsdmSubscriptionModel -from genericparser.pub.exceptions import GenericparserException, \ +from catalog.packages import const +from catalog.pub.database.models import NsdmSubscriptionModel +from catalog.pub.exceptions import CatalogException, \ ResourceNotFoundException, \ NsdmBadRequestException, NsdmDuplicateSubscriptionException -from genericparser.pub.utils.values import ignore_case_get +from catalog.pub.utils.values import ignore_case_get logger = logging.getLogger(__name__) @@ -93,12 +93,12 @@ class NsdmSubscription: try: response = requests.get(self.callback_uri, timeout=2) if response.status_code != status.HTTP_204_NO_CONTENT: - raise GenericparserException("callbackUri %s returns %s status " - "code." % (self.callback_uri, - response.status_code)) + raise CatalogException("callbackUri %s returns %s status " + "code." % (self.callback_uri, + response.status_code)) except Exception: - raise GenericparserException("callbackUri %s didn't return 204 status" - "code." % self.callback_uri) + raise CatalogException("callbackUri %s didn't return 204 status" + "code." % self.callback_uri) def fill_resp_data(self, subscription): subscription_filter = dict() @@ -201,7 +201,7 @@ class NsdmSubscription: links = { "self": { "href": - const.NSDM_SUBSCRIPTION_ROOT_URI + self.subscription_id + const.NSDM_SUBSCRIPTION_ROOT_URI + self.subscription_id } } subscription_save_db = { diff --git a/genericparser/packages/biz/pnf_descriptor.py b/catalog/packages/biz/pnf_descriptor.py index 561c8fa..547c198 100644 --- a/genericparser/packages/biz/pnf_descriptor.py +++ b/catalog/packages/biz/pnf_descriptor.py @@ -18,13 +18,13 @@ import logging import os import uuid -from genericparser.packages.biz.common import read, save -from genericparser.packages.const import PKG_STATUS -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH -from genericparser.pub.database.models import NSPackageModel, PnfPackageModel -from genericparser.pub.exceptions import GenericparserException, ResourceNotFoundException -from genericparser.pub.utils import fileutil, toscaparsers -from genericparser.pub.utils.values import ignore_case_get +from catalog.packages.biz.common import 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 +from catalog.pub.exceptions import CatalogException, ResourceNotFoundException +from catalog.pub.utils import fileutil, toscaparser +from catalog.pub.utils.values import ignore_case_get logger = logging.getLogger(__name__) @@ -77,7 +77,7 @@ class PnfDescriptor(object): pnf_pkgs = PnfPackageModel.objects.filter(pnfPackageId=pnfd_info_id) if not pnf_pkgs.exists(): logger.info('PNFD(%s) does not exist.' % pnfd_info_id) - raise GenericparserException('PNFD (%s) does not exist.' % pnfd_info_id) + raise CatalogException('PNFD (%s) does not exist.' % pnfd_info_id) pnf_pkgs.update(onboardingState=PKG_STATUS.UPLOADING) local_file_name = save(remote_file, pnfd_info_id) @@ -93,7 +93,7 @@ class PnfDescriptor(object): ''' if pnf_pkgs[0].usageState != PKG_STATUS.NOT_IN_USE: logger.info('PNFD(%s) shall be NOT_IN_USE.' % pnfd_info_id) - raise GenericparserException('PNFD(%s) shall be NOT_IN_USE.' % pnfd_info_id) + raise CatalogException('PNFD(%s) shall be NOT_IN_USE.' % pnfd_info_id) ''' del_pnfd_id = pnf_pkgs[0].pnfdId ns_pkgs = NSPackageModel.objects.all() @@ -106,9 +106,9 @@ class PnfDescriptor(object): for pnf in nsd_model['pnfs']: if del_pnfd_id == pnf["properties"]["id"]: logger.warn("PNFD(%s) is referenced in NSD", del_pnfd_id) - raise GenericparserException('PNFD(%s) is referenced.' % pnfd_info_id) + raise CatalogException('PNFD(%s) is referenced.' % pnfd_info_id) pnf_pkgs.delete() - pnf_pkg_path = os.path.join(GENERICPARSER_ROOT_PATH, pnfd_info_id) + pnf_pkg_path = os.path.join(CATALOG_ROOT_PATH, pnfd_info_id) fileutil.delete_dirs(pnf_pkg_path) logger.debug('PNFD(%s) has been deleted.' % pnfd_info_id) @@ -120,7 +120,7 @@ class PnfDescriptor(object): raise ResourceNotFoundException('PNFD(%s) does not exist.' % pnfd_info_id) if pnf_pkgs[0].onboardingState != PKG_STATUS.ONBOARDED: logger.error('PNFD(%s) is not ONBOARDED.' % pnfd_info_id) - raise GenericparserException('PNFD(%s) is not ONBOARDED.' % pnfd_info_id) + raise CatalogException('PNFD(%s) is not ONBOARDED.' % pnfd_info_id) local_file_path = pnf_pkgs[0].localFilePath start, end = 0, os.path.getsize(local_file_path) @@ -131,7 +131,7 @@ class PnfDescriptor(object): logger.info('Start to process PNFD(%s)...' % pnfd_info_id) pnf_pkgs = PnfPackageModel.objects.filter(pnfPackageId=pnfd_info_id) pnf_pkgs.update(onboardingState=PKG_STATUS.PROCESSING) - pnfd_json = toscaparsers.parse_pnfd(local_file_name) + pnfd_json = toscaparser.parse_pnfd(local_file_name) pnfd = json.JSONDecoder().decode(pnfd_json) logger.debug("pnfd_json is %s" % pnfd_json) @@ -152,7 +152,7 @@ class PnfDescriptor(object): if pnfd_id == "": pnfd_id = pnfd["metadata"].get("UUID", "") if pnfd_id == "": - raise GenericparserException('pnfd_id is Null.') + raise CatalogException('pnfd_id is Null.') if pnfdVersion == "": pnfdVersion = pnfd["metadata"].get("template_version", "") @@ -169,11 +169,10 @@ class PnfDescriptor(object): if pnfdVersion == "": pnfdName = pnfd["metadata"].get("name", "") - if pnfd_id: - other_pnf = PnfPackageModel.objects.filter(pnfdId=pnfd_id) - if other_pnf and other_pnf[0].pnfPackageId != pnfd_info_id: - logger.info('PNFD(%s) already exists.' % pnfd_id) - raise GenericparserException("PNFD(%s) already exists." % pnfd_id) + other_pnf = PnfPackageModel.objects.filter(pnfdId=pnfd_id) + if other_pnf and other_pnf[0].pnfPackageId != pnfd_info_id: + logger.info('PNFD(%s) already exists.' % pnfd_id) + raise CatalogException("PNFD(%s) already exists." % pnfd_id) pnf_pkgs.update( pnfdId=pnfd_id, @@ -213,14 +212,13 @@ class PnfDescriptor(object): pnf_pkg.update(onboardingState=PKG_STATUS.CREATED) def parse_pnfd(self, csar_id, inputs): - try: pnf_pkg = PnfPackageModel.objects.filter(pnfPackageId=csar_id) if not pnf_pkg: - raise GenericparserException("PNF CSAR(%s) does not exist." % csar_id) + raise CatalogException("PNF CSAR(%s) does not exist." % csar_id) csar_path = pnf_pkg[0].localFilePath - ret = {"model": toscaparsers.parse_pnfd(csar_path, inputs)} - except GenericparserException as e: + ret = {"model": toscaparser.parse_pnfd(csar_path, inputs)} + except CatalogException as e: return [1, e.args[0]] except Exception as e: logger.error(e.args[0]) diff --git a/genericparser/packages/biz/sdc_ns_package.py b/catalog/packages/biz/sdc_ns_package.py index 63a077f..4f9d460 100644 --- a/genericparser/packages/biz/sdc_ns_package.py +++ b/catalog/packages/biz/sdc_ns_package.py @@ -17,14 +17,14 @@ import os import sys import traceback -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH, GENERICPARSER_URL_PATH -from genericparser.pub.config.config import REG_TO_MSB_REG_PARAM -from genericparser.pub.database.models import NSPackageModel -from genericparser.pub.exceptions import GenericparserException -from genericparser.pub.msapi import sdc -from genericparser.pub.utils import toscaparsers -from genericparser.packages.biz.ns_descriptor import NsDescriptor -from genericparser.pub.utils import fileutil +from catalog.pub.config.config import CATALOG_ROOT_PATH, CATALOG_URL_PATH +from catalog.pub.config.config import REG_TO_MSB_REG_PARAM +from catalog.pub.database.models import NSPackageModel +from catalog.pub.exceptions import CatalogException +from catalog.pub.msapi import sdc +from catalog.pub.utils import toscaparser +from catalog.packages.biz.ns_descriptor import NsDescriptor +from catalog.pub.utils import fileutil logger = logging.getLogger(__name__) @@ -41,7 +41,7 @@ def ns_on_distribute(csar_id): ret = None try: ret = NsPackage().on_distribute(csar_id) - except GenericparserException as e: + except CatalogException as e: NsPackage().delete_csar(csar_id) return fmt_ns_pkg_rsp(STATUS_FAILED, e.args[0]) except: @@ -57,7 +57,7 @@ def ns_delete_csar(csar_id): ret = None try: ret = NsPackage().delete_csar(csar_id) - except GenericparserException as e: + except CatalogException as e: return fmt_ns_pkg_rsp(STATUS_FAILED, e.args[0]) except: logger.error(traceback.format_exc()) @@ -69,7 +69,7 @@ def ns_get_csars(): ret = None try: ret = NsPackage().get_csars() - except GenericparserException as e: + except CatalogException as e: return [1, e.args[0]] except: logger.error(traceback.format_exc()) @@ -81,7 +81,7 @@ def ns_get_csar(csar_id): ret = None try: ret = NsPackage().get_csar(csar_id) - except GenericparserException as e: + except CatalogException as e: return [1, e.args[0]] except Exception as e: logger.error(e.args[0]) @@ -95,10 +95,10 @@ def parse_nsd(csar_id, inputs): try: ns_pkg = NSPackageModel.objects.filter(nsPackageId=csar_id) if not ns_pkg: - raise GenericparserException("NS CSAR(%s) does not exist." % csar_id) + raise CatalogException("NS CSAR(%s) does not exist." % csar_id) csar_path = ns_pkg[0].localFilePath - ret = {"model": toscaparsers.parse_nsd(csar_path, inputs)} - except GenericparserException as e: + ret = {"model": toscaparser.parse_nsd(csar_path, inputs)} + except CatalogException as e: return [1, e.args[0]] except Exception as e: logger.error(e.args[0]) @@ -120,7 +120,7 @@ class NsPackage(object): return [1, "NS CSAR(%s) already exists." % csar_id] artifact = sdc.get_artifact(sdc.ASSETTYPE_SERVICES, csar_id) - local_path = os.path.join(GENERICPARSER_ROOT_PATH, csar_id) + local_path = os.path.join(CATALOG_ROOT_PATH, csar_id) csar_name = "%s.csar" % artifact.get("name", csar_id) local_file_name = sdc.download_artifacts(artifact["toscaModelURL"], local_path, csar_name) if local_file_name.endswith(".csar") or local_file_name.endswith(".zip"): @@ -163,10 +163,10 @@ class NsPackage(object): package_info["downloadUrl"] = "http://%s:%s/%s/%s/%s" % ( REG_TO_MSB_REG_PARAM[0]["nodes"][0]["ip"], REG_TO_MSB_REG_PARAM[0]["nodes"][0]["port"], - GENERICPARSER_URL_PATH, + CATALOG_URL_PATH, csar_id, csars[0].nsPackageUri) else: - raise GenericparserException("Ns package[%s] not Found." % csar_id) + raise CatalogException("Ns package[%s] not Found." % csar_id) return [0, {"csarId": csar_id, "packageInfo": package_info}] diff --git a/genericparser/packages/biz/sdc_service_package.py b/catalog/packages/biz/sdc_service_package.py index 0d57ceb..d0db6bf 100644 --- a/genericparser/packages/biz/sdc_service_package.py +++ b/catalog/packages/biz/sdc_service_package.py @@ -17,13 +17,13 @@ import traceback from coverage.xmlreport import os -from genericparser.packages.biz.service_descriptor import ServiceDescriptor -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH, REG_TO_MSB_REG_PARAM, GENERICPARSER_URL_PATH -from genericparser.pub.database.models import ServicePackageModel, VnfPackageModel, PnfPackageModel -from genericparser.pub.exceptions import GenericparserException, PackageNotFoundException, \ +from catalog.packages.biz.service_descriptor import ServiceDescriptor +from catalog.pub.config.config import CATALOG_ROOT_PATH, REG_TO_MSB_REG_PARAM, CATALOG_URL_PATH +from catalog.pub.database.models import ServicePackageModel, VnfPackageModel, PnfPackageModel +from catalog.pub.exceptions import CatalogException, PackageNotFoundException, \ PackageHasExistsException -from genericparser.pub.msapi import sdc -from genericparser.pub.utils import fileutil, toscaparsers +from catalog.pub.msapi import sdc +from catalog.pub.utils import fileutil, toscaparser logger = logging.getLogger(__name__) @@ -49,10 +49,10 @@ class ServicePackage(object): if not VnfPackageModel.objects.filter(vnfPackageId=resource['resourceUUID']) and \ not PnfPackageModel.objects.filter(pnfPackageId=resource['resourceUUID']): logger.error("Resource [%s] is not distributed.", resource['resourceUUID']) - raise GenericparserException("Resource (%s) is not distributed." % resource['resourceUUID']) + raise CatalogException("Resource (%s) is not distributed." % resource['resourceUUID']) # download csar package - local_path = os.path.join(GENERICPARSER_ROOT_PATH, csar_id) + local_path = os.path.join(CATALOG_ROOT_PATH, csar_id) csar_name = "%s.csar" % service.get("name", csar_id) local_file_name = sdc.download_artifacts(service["toscaModelURL"], local_path, csar_name) if local_file_name.endswith(".csar") or local_file_name.endswith(".zip"): @@ -96,7 +96,7 @@ class ServicePackage(object): package_info["downloadUrl"] = "http://%s:%s/%s/%s/%s" % ( REG_TO_MSB_REG_PARAM[0]["nodes"][0]["ip"], REG_TO_MSB_REG_PARAM[0]["nodes"][0]["port"], - GENERICPARSER_URL_PATH, + CATALOG_URL_PATH, csar_id, csars[0].servicePackageUri) else: @@ -113,9 +113,9 @@ class ServicePackage(object): try: csar_path = service_pkg[0].localFilePath - ret = {"model": toscaparsers.parse_sd(csar_path, inputs)} + ret = {"model": toscaparser.parse_sd(csar_path, inputs)} return ret - except GenericparserException as e: + except CatalogException as e: logger.error(e.args[0]) raise e except Exception as e: diff --git a/genericparser/packages/biz/sdc_vnf_package.py b/catalog/packages/biz/sdc_vnf_package.py index 3a271b7..571c3bb 100644 --- a/genericparser/packages/biz/sdc_vnf_package.py +++ b/catalog/packages/biz/sdc_vnf_package.py @@ -19,15 +19,15 @@ import sys import threading import traceback -from genericparser.packages.const import PKG_STATUS -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH, GENERICPARSER_URL_PATH -from genericparser.pub.config.config import REG_TO_MSB_REG_PARAM -from genericparser.pub.database.models import VnfPackageModel -from genericparser.pub.exceptions import GenericparserException -from genericparser.pub.msapi import sdc -from genericparser.pub.utils import fileutil -from genericparser.pub.utils import toscaparsers -from genericparser.pub.utils.jobutil import JobUtil +from catalog.packages.const import PKG_STATUS +from catalog.pub.config.config import CATALOG_ROOT_PATH, CATALOG_URL_PATH +from catalog.pub.config.config import REG_TO_MSB_REG_PARAM +from catalog.pub.database.models import VnfPackageModel +from catalog.pub.exceptions import CatalogException +from catalog.pub.msapi import sdc +from catalog.pub.utils import fileutil +from catalog.pub.utils import toscaparser +from catalog.pub.utils.jobutil import JobUtil logger = logging.getLogger(__name__) @@ -38,7 +38,7 @@ def nf_get_csars(): ret = None try: ret = NfPackage().get_csars() - except GenericparserException as e: + except CatalogException as e: return [1, e.args[0]] except Exception as e: logger.error(e.args[0]) @@ -51,7 +51,7 @@ def nf_get_csar(csar_id): ret = None try: ret = NfPackage().get_csar(csar_id) - except GenericparserException as e: + except CatalogException as e: return [1, e.args[0]] except Exception as e: logger.error(e.args[0]) @@ -65,10 +65,10 @@ def parse_vnfd(csar_id, inputs): try: nf_pkg = VnfPackageModel.objects.filter(vnfPackageId=csar_id) if not nf_pkg: - raise GenericparserException("VNF CSAR(%s) does not exist." % csar_id) + raise CatalogException("VNF CSAR(%s) does not exist." % csar_id) csar_path = nf_pkg[0].localFilePath - ret = {"model": toscaparsers.parse_vnfd(csar_path, inputs)} - except GenericparserException as e: + ret = {"model": toscaparser.parse_vnfd(csar_path, inputs)} + except CatalogException as e: return [1, e.args[0]] except Exception as e: logger.error(e.args[0]) @@ -89,12 +89,12 @@ class NfDistributeThread(threading.Thread): self.lab_vim_id = lab_vim_id self.job_id = job_id - self.csar_save_path = os.path.join(GENERICPARSER_ROOT_PATH, csar_id) + self.csar_save_path = os.path.join(CATALOG_ROOT_PATH, csar_id) def run(self): try: self.on_distribute() - except GenericparserException as e: + except CatalogException as e: self.rollback_distribute() JobUtil.add_job_status(self.job_id, JOB_ERROR, e.args[0]) except Exception as e: @@ -118,7 +118,7 @@ class NfDistributeThread(threading.Thread): return artifact = sdc.get_artifact(sdc.ASSETTYPE_RESOURCES, self.csar_id) - local_path = os.path.join(GENERICPARSER_ROOT_PATH, self.csar_id) + local_path = os.path.join(CATALOG_ROOT_PATH, self.csar_id) csar_name = "%s.csar" % artifact.get("name", self.csar_id) local_file_name = sdc.download_artifacts(artifact["toscaModelURL"], local_path, csar_name) if local_file_name.endswith(".csar") or local_file_name.endswith(".zip"): @@ -126,16 +126,16 @@ class NfDistributeThread(threading.Thread): if os.path.exists(artifact_vnf_file): local_file_name = artifact_vnf_file - vnfd_json = toscaparsers.parse_vnfd(local_file_name) + vnfd_json = toscaparser.parse_vnfd(local_file_name) vnfd = json.JSONDecoder().decode(vnfd_json) if not vnfd.get("vnf"): - raise GenericparserException("VNF properties and metadata in VNF Package(id=%s) are empty." % self.csar_id) + raise CatalogException("VNF properties and metadata in VNF Package(id=%s) are empty." % self.csar_id) vnfd_id = vnfd["vnf"]["properties"].get("descriptor_id", "") if VnfPackageModel.objects.filter(vnfdId=vnfd_id): logger.error("VNF package(%s) already exists.", vnfd_id) - raise GenericparserException("VNF package(%s) already exists." % vnfd_id) + raise CatalogException("VNF package(%s) already exists." % vnfd_id) JobUtil.add_job_status(self.job_id, 30, "Save CSAR(%s) to database." % self.csar_id) vnfd_ver = vnfd["vnf"]["properties"].get("descriptor_version", "") vnf_provider = vnfd["vnf"]["properties"].get("provider", "") @@ -180,7 +180,7 @@ class NfPkgDeleteThread(threading.Thread): def run(self): try: self.delete_csar() - except GenericparserException as e: + except CatalogException as e: JobUtil.add_job_status(self.job_id, JOB_ERROR, e.args[0]) except Exception as e: logger.error(e.args[0]) @@ -200,7 +200,7 @@ class NfPkgDeleteThread(threading.Thread): JobUtil.add_job_status(self.job_id, 50, "Delete local CSAR(%s) file." % self.csar_id) - csar_save_path = os.path.join(GENERICPARSER_ROOT_PATH, self.csar_id) + csar_save_path = os.path.join(CATALOG_ROOT_PATH, self.csar_id) fileutil.delete_dirs(csar_save_path) JobUtil.add_job_status(self.job_id, 100, "Delete CSAR(%s) successfully." % self.csar_id) @@ -240,11 +240,11 @@ class NfPackage(object): pkg_info["downloadUrl"] = "http://%s:%s/%s/%s/%s" % ( REG_TO_MSB_REG_PARAM[0]["nodes"][0]["ip"], REG_TO_MSB_REG_PARAM[0]["nodes"][0]["port"], - GENERICPARSER_URL_PATH, + CATALOG_URL_PATH, db_csar_id, nf_pkg[0].vnfPackageUri) else: - raise GenericparserException("Vnf package[%s] not Found." % csar_id) + raise CatalogException("Vnf package[%s] not Found." % csar_id) csar_info = { "csarId": db_csar_id, diff --git a/genericparser/packages/biz/service_descriptor.py b/catalog/packages/biz/service_descriptor.py index b8cba6d..11b6fb3 100644 --- a/genericparser/packages/biz/service_descriptor.py +++ b/catalog/packages/biz/service_descriptor.py @@ -17,13 +17,12 @@ import logging import os import uuid - -from genericparser.packages.const import PKG_STATUS -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH -from genericparser.pub.database.models import ServicePackageModel, VnfPackageModel, PnfPackageModel -from genericparser.pub.exceptions import GenericparserException, PackageNotFoundException -from genericparser.pub.utils import toscaparsers, fileutil -from genericparser.pub.utils.values import ignore_case_get +from catalog.packages.const import PKG_STATUS +from catalog.pub.config.config import CATALOG_ROOT_PATH +from catalog.pub.database.models import ServicePackageModel, VnfPackageModel, PnfPackageModel +from catalog.pub.exceptions import CatalogException, PackageNotFoundException +from catalog.pub.utils import toscaparser, fileutil +from catalog.pub.utils.values import ignore_case_get logger = logging.getLogger(__name__) @@ -62,7 +61,7 @@ class ServiceDescriptor(object): service_pkgs = ServicePackageModel.objects.filter(servicePackageId=serviced_info_id) service_pkgs.update(onboardingState=PKG_STATUS.PROCESSING) - serviced_json = toscaparsers.parse_sd(local_file_name) + serviced_json = toscaparser.parse_sd(local_file_name) serviced = json.JSONDecoder().decode(serviced_json) serviced_id = serviced.get("service", {}).get("properties", {}).get("descriptor_id", "") @@ -71,11 +70,11 @@ class ServiceDescriptor(object): serviced_designer = serviced.get("service", {}).get("properties", {}).get("designer", "") invariant_id = serviced.get("service", {}).get("properties", {}).get("invariant_id", "") if serviced_id == "": - raise GenericparserException("serviced_id(%s) does not exist in metadata." % serviced_id) + raise CatalogException("serviced_id(%s) does not exist in metadata." % serviced_id) other_nspkg = ServicePackageModel.objects.filter(servicedId=serviced_id) if other_nspkg and other_nspkg[0].servicePackageId != serviced_info_id: logger.warn("ServiceD(%s,%s) already exists.", serviced_id, other_nspkg[0].servicePackageId) - raise GenericparserException("ServiceD(%s) already exists." % serviced_id) + raise CatalogException("ServiceD(%s) already exists." % serviced_id) for vnf in serviced["vnfs"]: vnfd_id = vnf["properties"].get("descriptor_id", "undefined") @@ -87,7 +86,7 @@ class ServiceDescriptor(object): if not pkg: vnfd_name = vnf.get("vnf_id", "undefined") logger.error("[%s] is not distributed.", vnfd_name) - raise GenericparserException("VNF package(%s) is not distributed." % vnfd_id) + raise CatalogException("VNF package(%s) is not distributed." % vnfd_id) for pnf in serviced["pnfs"]: pnfd_id = pnf["properties"].get("descriptor_id", "undefined") @@ -99,7 +98,7 @@ class ServiceDescriptor(object): if not pkg: pnfd_name = pnf.get("pnf_id", "undefined") logger.error("[%s] is not distributed.", pnfd_name) - raise GenericparserException("PNF package(%s) is not distributed." % pnfd_name) + raise CatalogException("PNF package(%s) is not distributed." % pnfd_name) service_pkgs.update( servicedId=serviced_id, @@ -125,6 +124,6 @@ class ServiceDescriptor(object): logger.warn('ServiceD(%s) not found.' % serviced_info_id) raise PackageNotFoundException("Service package[%s] not Found." % serviced_info_id) service_pkgs.delete() - service_pkg_path = os.path.join(GENERICPARSER_ROOT_PATH, serviced_info_id) + service_pkg_path = os.path.join(CATALOG_ROOT_PATH, serviced_info_id) fileutil.delete_dirs(service_pkg_path) logger.info('ServiceD(%s) has been deleted.' % serviced_info_id) diff --git a/genericparser/packages/biz/vnf_package.py b/catalog/packages/biz/vnf_package.py index cf67a76..585a599 100644 --- a/genericparser/packages/biz/vnf_package.py +++ b/catalog/packages/biz/vnf_package.py @@ -21,13 +21,13 @@ import traceback import urllib import uuid -from genericparser.packages.biz.common import parse_file_range, read, save -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH -from genericparser.pub.database.models import VnfPackageModel, NSPackageModel -from genericparser.pub.exceptions import GenericparserException, ResourceNotFoundException -from genericparser.pub.utils.values import ignore_case_get -from genericparser.pub.utils import fileutil, toscaparsers -from genericparser.packages.const import PKG_STATUS +from catalog.packages.biz.common import parse_file_range, read, save +from catalog.pub.config.config import CATALOG_ROOT_PATH +from catalog.pub.database.models import VnfPackageModel, NSPackageModel +from catalog.pub.exceptions import CatalogException, ResourceNotFoundException +from catalog.pub.utils.values import ignore_case_get +from catalog.pub.utils import fileutil, toscaparser +from catalog.packages.const import PKG_STATUS logger = logging.getLogger(__name__) @@ -80,9 +80,9 @@ class VnfPackage(object): return ''' if vnf_pkg[0].operationalState != PKG_STATUS.DISABLED: - raise GenericparserException("The VNF package (%s) is not disabled" % vnf_pkg_id) + raise CatalogException("The VNF package (%s) is not disabled" % vnf_pkg_id) if vnf_pkg[0].usageState != PKG_STATUS.NOT_IN_USE: - raise GenericparserException("The VNF package (%s) is in use" % vnf_pkg_id) + raise CatalogException("The VNF package (%s) is in use" % vnf_pkg_id) ''' del_vnfd_id = vnf_pkg[0].vnfdId ns_pkgs = NSPackageModel.objects.all() @@ -94,9 +94,9 @@ class VnfPackage(object): continue for vnf in nsd_model['vnfs']: if del_vnfd_id == vnf["properties"]["descriptor_id"]: - raise GenericparserException('VNFD(%s) is referenced.' % del_vnfd_id) + raise CatalogException('VNFD(%s) is referenced.' % del_vnfd_id) vnf_pkg.delete() - vnf_pkg_path = os.path.join(GENERICPARSER_ROOT_PATH, vnf_pkg_id) + vnf_pkg_path = os.path.join(CATALOG_ROOT_PATH, vnf_pkg_id) fileutil.delete_dirs(vnf_pkg_path) logger.info('VNF package(%s) has been deleted.' % vnf_pkg_id) @@ -105,7 +105,7 @@ class VnfPackage(object): vnf_pkg = VnfPackageModel.objects.filter(vnfPackageId=vnf_pkg_id) # if vnf_pkg[0].onboardingState != PKG_STATUS.CREATED: # logger.error("VNF package(%s) is not CREATED" % vnf_pkg_id) - # raise GenericparserException("VNF package(%s) is not CREATED" % vnf_pkg_id) + # raise CatalogException("VNF package(%s) is not CREATED" % vnf_pkg_id) vnf_pkg.update(onboardingState=PKG_STATUS.UPLOADING) local_file_name = save(remote_file, vnf_pkg_id) @@ -119,7 +119,7 @@ class VnfPackage(object): logger.error('VNF package(%s) does not exist.' % vnf_pkg_id) raise ResourceNotFoundException('VNF package(%s) does not exist.' % vnf_pkg_id) if nf_pkg[0].onboardingState != PKG_STATUS.ONBOARDED: - raise GenericparserException("VNF package (%s) is not on-boarded" % vnf_pkg_id) + raise CatalogException("VNF package (%s) is not on-boarded" % vnf_pkg_id) local_file_path = nf_pkg[0].localFilePath start, end = parse_file_range(local_file_path, file_range) @@ -138,7 +138,7 @@ class VnfPkgUploadThread(threading.Thread): try: self.upload_vnf_pkg_from_uri() parse_vnfd_and_save(self.vnf_pkg_id, self.upload_file_name) - except GenericparserException as e: + except CatalogException as e: logger.error(e.args[0]) except Exception as e: logger.error(e.args[0]) @@ -150,13 +150,13 @@ class VnfPkgUploadThread(threading.Thread): vnf_pkg = VnfPackageModel.objects.filter(vnfPackageId=self.vnf_pkg_id) if vnf_pkg[0].onboardingState != PKG_STATUS.CREATED: logger.error("VNF package(%s) is not CREATED" % self.vnf_pkg_id) - raise GenericparserException("VNF package (%s) is not created" % self.vnf_pkg_id) + raise CatalogException("VNF package (%s) is not created" % self.vnf_pkg_id) vnf_pkg.update(onboardingState=PKG_STATUS.UPLOADING) uri = ignore_case_get(self.data, "addressInformation") response = urllib.request.urlopen(uri) - local_file_dir = os.path.join(GENERICPARSER_ROOT_PATH, self.vnf_pkg_id) + local_file_dir = os.path.join(CATALOG_ROOT_PATH, self.vnf_pkg_id) self.upload_file_name = os.path.join(local_file_dir, os.path.basename(uri)) if not os.path.exists(local_file_dir): fileutil.make_dirs(local_file_dir) @@ -190,7 +190,7 @@ def parse_vnfd_and_save(vnf_pkg_id, vnf_pkg_path): logger.info('Start to process VNF package(%s)...' % vnf_pkg_id) vnf_pkg = VnfPackageModel.objects.filter(vnfPackageId=vnf_pkg_id) vnf_pkg.update(onboardingState=PKG_STATUS.PROCESSING) - vnfd_json = toscaparsers.parse_vnfd(vnf_pkg_path) + vnfd_json = toscaparser.parse_vnfd(vnf_pkg_path) vnfd = json.JSONDecoder().decode(vnfd_json) if vnfd.get("vnf", "") != "": @@ -198,7 +198,7 @@ def parse_vnfd_and_save(vnf_pkg_id, vnf_pkg_path): other_pkg = VnfPackageModel.objects.filter(vnfdId=vnfd_id) if other_pkg and other_pkg[0].vnfPackageId != vnf_pkg_id: logger.error("VNF package(%s,%s) already exists.", other_pkg[0].vnfPackageId, vnfd_id) - raise GenericparserException("VNF package(%s) already exists." % vnfd_id) + raise CatalogException("VNF package(%s) already exists." % vnfd_id) vnf_provider = vnfd["vnf"]["properties"].get("provider", "") vnfd_ver = vnfd["vnf"]["properties"].get("descriptor_version", "") vnf_software_version = vnfd["vnf"]["properties"].get("software_version", "") @@ -218,7 +218,7 @@ def parse_vnfd_and_save(vnf_pkg_id, vnf_pkg_path): vnfPackageUri=os.path.split(vnf_pkg_path)[-1] ) else: - raise GenericparserException("VNF propeties and metadata in VNF Package(id=%s) are empty." % vnf_pkg_id) + raise CatalogException("VNF propeties and metadata in VNF Package(id=%s) are empty." % vnf_pkg_id) logger.info('VNF package(%s) has been processed(done).' % vnf_pkg_id) diff --git a/genericparser/packages/biz/vnf_pkg_artifacts.py b/catalog/packages/biz/vnf_pkg_artifacts.py index 0cec274..37021eb 100644 --- a/genericparser/packages/biz/vnf_pkg_artifacts.py +++ b/catalog/packages/biz/vnf_pkg_artifacts.py @@ -14,9 +14,9 @@ import logging -from genericparser.pub.database.models import VnfPackageModel -from genericparser.pub.exceptions import ResourceNotFoundException, ArtifactNotFoundException -from genericparser.pub.utils import fileutil +from catalog.pub.database.models import VnfPackageModel +from catalog.pub.exceptions import ResourceNotFoundException, ArtifactNotFoundException +from catalog.pub.utils import fileutil logger = logging.getLogger(__name__) diff --git a/genericparser/packages/biz/vnf_pkg_subscription.py b/catalog/packages/biz/vnf_pkg_subscription.py index 8da82ad..29ef92e 100644 --- a/genericparser/packages/biz/vnf_pkg_subscription.py +++ b/catalog/packages/biz/vnf_pkg_subscription.py @@ -22,11 +22,11 @@ import uuid from collections import Counter from rest_framework import status -from genericparser.packages import const -from genericparser.pub.database.models import VnfPkgSubscriptionModel -from genericparser.pub.exceptions import VnfPkgSubscriptionException,\ +from catalog.packages import const +from catalog.pub.database.models import VnfPkgSubscriptionModel +from catalog.pub.exceptions import VnfPkgSubscriptionException,\ VnfPkgDuplicateSubscriptionException, SubscriptionDoesNotExistsException -from genericparser.pub.utils.values import ignore_case_get +from catalog.pub.utils.values import ignore_case_get logger = logging.getLogger(__name__) diff --git a/genericparser/packages/const.py b/catalog/packages/const.py index 2b8778b..cd09b40 100644 --- a/genericparser/packages/const.py +++ b/catalog/packages/const.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from genericparser.pub.utils.jobutil import enum +from catalog.pub.utils.jobutil import enum PKG_STATUS = enum( CREATED="CREATED", diff --git a/genericparser/packages/serializers/__init__.py b/catalog/packages/serializers/__init__.py index 342c2a8..342c2a8 100644 --- a/genericparser/packages/serializers/__init__.py +++ b/catalog/packages/serializers/__init__.py diff --git a/genericparser/packages/serializers/genericparser_serializers.py b/catalog/packages/serializers/catalog_serializers.py index 7bcb9ef..f53b06d 100644 --- a/genericparser/packages/serializers/genericparser_serializers.py +++ b/catalog/packages/serializers/catalog_serializers.py @@ -14,8 +14,8 @@ from rest_framework import serializers -from genericparser.pub.utils.toscaparsers.nsdmodel import EtsiNsdInfoModel -from genericparser.pub.utils.toscaparsers.vnfdmodel import EtsiVnfdInfoModel +from catalog.pub.utils.toscaparser.nsdmodel import EtsiNsdInfoModel +from catalog.pub.utils.toscaparser.vnfdmodel import EtsiVnfdInfoModel class PostJobRequestSerializer(serializers.Serializer): diff --git a/genericparser/packages/serializers/checksum.py b/catalog/packages/serializers/checksum.py index 1296626..1296626 100644 --- a/genericparser/packages/serializers/checksum.py +++ b/catalog/packages/serializers/checksum.py diff --git a/genericparser/packages/serializers/create_nsd_info_request.py b/catalog/packages/serializers/create_nsd_info_request.py index 24fe3b7..24fe3b7 100644 --- a/genericparser/packages/serializers/create_nsd_info_request.py +++ b/catalog/packages/serializers/create_nsd_info_request.py diff --git a/genericparser/packages/serializers/create_pnfd_info_request.py b/catalog/packages/serializers/create_pnfd_info_request.py index 01d8229..01d8229 100644 --- a/genericparser/packages/serializers/create_pnfd_info_request.py +++ b/catalog/packages/serializers/create_pnfd_info_request.py diff --git a/genericparser/packages/serializers/create_vnf_pkg_info_req.py b/catalog/packages/serializers/create_vnf_pkg_info_req.py index 6da281d..6da281d 100644 --- a/genericparser/packages/serializers/create_vnf_pkg_info_req.py +++ b/catalog/packages/serializers/create_vnf_pkg_info_req.py diff --git a/genericparser/packages/serializers/link.py b/catalog/packages/serializers/link.py index a6a503c..a6a503c 100644 --- a/genericparser/packages/serializers/link.py +++ b/catalog/packages/serializers/link.py diff --git a/genericparser/packages/serializers/nsd_info.py b/catalog/packages/serializers/nsd_info.py index 9450582..9450582 100644 --- a/genericparser/packages/serializers/nsd_info.py +++ b/catalog/packages/serializers/nsd_info.py diff --git a/genericparser/packages/serializers/nsd_infos.py b/catalog/packages/serializers/nsd_infos.py index d63c332..d63c332 100644 --- a/genericparser/packages/serializers/nsd_infos.py +++ b/catalog/packages/serializers/nsd_infos.py diff --git a/genericparser/packages/serializers/nsdm_filter_data.py b/catalog/packages/serializers/nsdm_filter_data.py index 43213e0..47d7680 100644 --- a/genericparser/packages/serializers/nsdm_filter_data.py +++ b/catalog/packages/serializers/nsdm_filter_data.py @@ -14,7 +14,7 @@ from rest_framework import serializers -from genericparser.packages.const import NSDM_NOTIFICATION_TYPES +from catalog.packages.const import NSDM_NOTIFICATION_TYPES class NsdmNotificationsFilter(serializers.Serializer): diff --git a/genericparser/packages/serializers/nsdm_subscription.py b/catalog/packages/serializers/nsdm_subscription.py index 87aa48d..87aa48d 100644 --- a/genericparser/packages/serializers/nsdm_subscription.py +++ b/catalog/packages/serializers/nsdm_subscription.py diff --git a/genericparser/packages/serializers/pnfd_info.py b/catalog/packages/serializers/pnfd_info.py index f9f4b6b..f9f4b6b 100644 --- a/genericparser/packages/serializers/pnfd_info.py +++ b/catalog/packages/serializers/pnfd_info.py diff --git a/genericparser/packages/serializers/pnfd_infos.py b/catalog/packages/serializers/pnfd_infos.py index 0874c9e..0874c9e 100644 --- a/genericparser/packages/serializers/pnfd_infos.py +++ b/catalog/packages/serializers/pnfd_infos.py diff --git a/genericparser/packages/serializers/problem_details.py b/catalog/packages/serializers/problem_details.py index 68d4500..68d4500 100644 --- a/genericparser/packages/serializers/problem_details.py +++ b/catalog/packages/serializers/problem_details.py diff --git a/genericparser/packages/serializers/response.py b/catalog/packages/serializers/response.py index e2cca92..e2cca92 100644 --- a/genericparser/packages/serializers/response.py +++ b/catalog/packages/serializers/response.py diff --git a/genericparser/packages/serializers/subscription_auth_data.py b/catalog/packages/serializers/subscription_auth_data.py index 9248fb1..bf512d6 100644 --- a/genericparser/packages/serializers/subscription_auth_data.py +++ b/catalog/packages/serializers/subscription_auth_data.py @@ -14,7 +14,7 @@ from rest_framework import serializers -from genericparser.packages import const +from catalog.packages import const class OAuthCredentialsSerializer(serializers.Serializer): diff --git a/genericparser/packages/serializers/upload_vnf_pkg_from_uri_req.py b/catalog/packages/serializers/upload_vnf_pkg_from_uri_req.py index b847484..b847484 100644 --- a/genericparser/packages/serializers/upload_vnf_pkg_from_uri_req.py +++ b/catalog/packages/serializers/upload_vnf_pkg_from_uri_req.py diff --git a/genericparser/packages/serializers/vnf_pkg_artifact_info.py b/catalog/packages/serializers/vnf_pkg_artifact_info.py index c63b3c2..c63b3c2 100644 --- a/genericparser/packages/serializers/vnf_pkg_artifact_info.py +++ b/catalog/packages/serializers/vnf_pkg_artifact_info.py diff --git a/genericparser/packages/serializers/vnf_pkg_info.py b/catalog/packages/serializers/vnf_pkg_info.py index 3fa4b17..3fa4b17 100644 --- a/genericparser/packages/serializers/vnf_pkg_info.py +++ b/catalog/packages/serializers/vnf_pkg_info.py diff --git a/genericparser/packages/serializers/vnf_pkg_infos.py b/catalog/packages/serializers/vnf_pkg_infos.py index 9ffd6f0..9ffd6f0 100644 --- a/genericparser/packages/serializers/vnf_pkg_infos.py +++ b/catalog/packages/serializers/vnf_pkg_infos.py diff --git a/genericparser/packages/serializers/vnf_pkg_notifications.py b/catalog/packages/serializers/vnf_pkg_notifications.py index 4bfdf84..5e023af 100644 --- a/genericparser/packages/serializers/vnf_pkg_notifications.py +++ b/catalog/packages/serializers/vnf_pkg_notifications.py @@ -14,7 +14,7 @@ from rest_framework import serializers -from genericparser.packages.const import NOTIFICATION_TYPES +from catalog.packages.const import NOTIFICATION_TYPES PackageOperationalStateType = ["ENABLED", "DISABLED"] PackageUsageStateType = ["IN_USE", "NOT_IN_USE"] diff --git a/genericparser/packages/serializers/vnf_pkg_software_image_info.py b/catalog/packages/serializers/vnf_pkg_software_image_info.py index 790c61e..790c61e 100644 --- a/genericparser/packages/serializers/vnf_pkg_software_image_info.py +++ b/catalog/packages/serializers/vnf_pkg_software_image_info.py diff --git a/genericparser/packages/serializers/vnf_pkg_subscription.py b/catalog/packages/serializers/vnf_pkg_subscription.py index b5a0bc4..edcd6fe 100644 --- a/genericparser/packages/serializers/vnf_pkg_subscription.py +++ b/catalog/packages/serializers/vnf_pkg_subscription.py @@ -14,8 +14,8 @@ from rest_framework import serializers -from genericparser.packages.serializers import subscription_auth_data -from genericparser.packages.serializers import vnf_pkg_notifications +from catalog.packages.serializers import subscription_auth_data +from catalog.packages.serializers import vnf_pkg_notifications class LinkSerializer(serializers.Serializer): diff --git a/genericparser/packages/tests/__init__.py b/catalog/packages/tests/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/packages/tests/__init__.py +++ b/catalog/packages/tests/__init__.py diff --git a/genericparser/packages/tests/const.py b/catalog/packages/tests/const.py index 991c87c..991c87c 100644 --- a/genericparser/packages/tests/const.py +++ b/catalog/packages/tests/const.py diff --git a/genericparser/packages/tests/test_health_check.py b/catalog/packages/tests/test_health_check.py index e074bba..f8c3b56 100644 --- a/genericparser/packages/tests/test_health_check.py +++ b/catalog/packages/tests/test_health_check.py @@ -37,6 +37,12 @@ class TestHealthCheck(TestCase): resp_data = json.loads(response.content) self.assertEqual({"status": "active"}, resp_data) + def test_catalog_health_check(self): + response = self.client.get("/api/catalog/v1/health_check") + self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) + resp_data = json.loads(response.content) + self.assertEqual({"status": "active"}, resp_data) + def test_parser_health_check(self): response = self.client.get("/api/parser/v1/health_check") self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) diff --git a/genericparser/packages/tests/test_ns_descriptor.py b/catalog/packages/tests/test_ns_descriptor.py index 36933ac..473786e 100644 --- a/genericparser/packages/tests/test_ns_descriptor.py +++ b/catalog/packages/tests/test_ns_descriptor.py @@ -20,12 +20,12 @@ import os from django.test import TestCase from rest_framework import status from rest_framework.test import APIClient -from genericparser.packages.biz.ns_descriptor import NsDescriptor -from genericparser.packages.const import PKG_STATUS -from genericparser.packages.tests.const import nsd_data -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH -from genericparser.pub.database.models import NSPackageModel, VnfPackageModel, PnfPackageModel -from genericparser.pub.utils import toscaparsers +from catalog.packages.biz.ns_descriptor import NsDescriptor +from catalog.packages.const import PKG_STATUS +from catalog.packages.tests.const import nsd_data +from catalog.pub.config.config import CATALOG_ROOT_PATH +from catalog.pub.database.models import NSPackageModel, VnfPackageModel, PnfPackageModel +from catalog.pub.utils import toscaparser class TestNsDescriptor(TestCase): @@ -78,9 +78,7 @@ class TestNsDescriptor(TestCase): ) response.data.pop('id') self.assertEqual(response.status_code, status.HTTP_201_CREATED) - # self.assertEqual(expected_reponse_data, response.data) - for key, value in expected_reponse_data.items(): - self.assertEqual(response.data[key], value) + self.assertEqual(expected_reponse_data, response.data) def test_query_multiple_nsds_normal(self): expected_reponse_data = [ @@ -156,7 +154,7 @@ class TestNsDescriptor(TestCase): response = self.client.delete("/api/nsd/v1/ns_descriptors/21", format='json') self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) - @mock.patch.object(toscaparsers, 'parse_nsd') + @mock.patch.object(toscaparser, 'parse_nsd') def test_nsd_content_upload_normal(self, mock_parse_nsd): user_defined_data_json = json.JSONEncoder().encode(self.user_defined_data) mock_parse_nsd.return_value = json.JSONEncoder().encode(nsd_data) @@ -185,7 +183,7 @@ class TestNsDescriptor(TestCase): {'file': fp}, ) file_content = '' - with open(os.path.join(GENERICPARSER_ROOT_PATH, '22/nsd_content.txt')) as fp: + with open(os.path.join(CATALOG_ROOT_PATH, '22/nsd_content.txt')) as fp: data = fp.read() file_content = '%s%s' % (file_content, data) ns_pkg = NSPackageModel.objects.filter(nsPackageId="22") @@ -220,9 +218,9 @@ class TestNsDescriptor(TestCase): ) file_content = "" for data in response.streaming_content: - file_content = '%s%s' % (file_content, data) + file_content = '%s%s' % (file_content, data.decode()) self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual("b'test1test2'", file_content) + self.assertEqual("test1test2", file_content) os.remove('nsd_content.txt') def test_nsd_content_download_when_ns_not_exist(self): @@ -255,9 +253,9 @@ class TestNsDescriptor(TestCase): ) partial_file_content = '' for data in response.streaming_content: - partial_file_content = '%s%s' % (partial_file_content, data) + partial_file_content = '%s%s' % (partial_file_content, data.decode()) self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual("b'test2'", partial_file_content) + self.assertEqual("test2", partial_file_content) os.remove('nsd_content.txt') @mock.patch.object(NsDescriptor, 'create') diff --git a/genericparser/packages/tests/test_nsdm_subscription.py b/catalog/packages/tests/test_nsdm_subscription.py index c6c194e..f73c416 100644 --- a/genericparser/packages/tests/test_nsdm_subscription.py +++ b/catalog/packages/tests/test_nsdm_subscription.py @@ -19,8 +19,8 @@ from django.test import TestCase from rest_framework.test import APIClient from rest_framework import status -from genericparser.packages.biz.nsdm_subscription import NsdmSubscription -from genericparser.pub.database.models import NsdmSubscriptionModel +from catalog.packages.biz.nsdm_subscription import NsdmSubscription +from catalog.pub.database.models import NsdmSubscriptionModel class TestNsdmSubscription(TestCase): @@ -150,7 +150,7 @@ class TestNsdmSubscription(TestCase): expected_data = { 'status': 303, 'detail': 'Already Subscription exists with' - ' the same callbackUri and filter', + ' the same callbackUri and filter' } response = self.client.post("/api/nsd/v1/subscriptions", data=self.subscription, format='json') @@ -192,7 +192,7 @@ class TestNsdmSubscription(TestCase): mock_requests.get.return_value.status_code = 204 expected_data = { 'status': 400, - 'detail': 'Auth type should be BASIC', + 'detail': 'Auth type should be BASIC' } response = self.client.post("/api/nsd/v1/subscriptions", data=dummy_subscription, format='json') @@ -217,7 +217,7 @@ class TestNsdmSubscription(TestCase): mock_requests.get.return_value.status_code = 204 expected_data = { 'status': 400, - 'detail': 'Auth type should be OAUTH2_CLIENT_CREDENTIALS', + 'detail': 'Auth type should be OAUTH2_CLIENT_CREDENTIALS' } response = self.client.post("/api/nsd/v1/subscriptions", data=dummy_subscription, format='json') @@ -239,7 +239,7 @@ class TestNsdmSubscription(TestCase): mock_requests.get.return_value.status_code = 204 expected_data = { 'status': 400, - 'detail': 'userName and password needed for BASIC', + 'detail': 'userName and password needed for BASIC' } response = self.client.post("/api/nsd/v1/subscriptions", data=dummy_subscription, format='json') @@ -264,7 +264,7 @@ class TestNsdmSubscription(TestCase): expected_data = { 'status': 400, 'detail': 'clientId, clientPassword and tokenEndpoint' - ' required for OAUTH2_CLIENT_CREDENTIALS', + ' required for OAUTH2_CLIENT_CREDENTIALS' } response = self.client.post("/api/nsd/v1/subscriptions", data=dummy_subscription, format='json') @@ -292,7 +292,7 @@ class TestNsdmSubscription(TestCase): expected_data = { 'status': 400, 'detail': 'Notification Filter should contain' - ' either nsdId or nsdInfoId', + ' either nsdId or nsdInfoId' } response = self.client.post("/api/nsd/v1/subscriptions", data=dummy_subscription, format='json') @@ -320,7 +320,7 @@ class TestNsdmSubscription(TestCase): expected_data = { 'status': 400, 'detail': 'Notification Filter should contain' - ' either pnfdId or pnfdInfoIds', + ' either pnfdId or pnfdInfoIds' } response = self.client.post("/api/nsd/v1/subscriptions", data=dummy_subscription, format='json') @@ -456,7 +456,7 @@ class TestNsdmSubscription(TestCase): expected_data = { "status": 404, "detail": "Subscription(" + self.subscription_id + ") " - "doesn't exists" + "doesn't exists" } response = self.client.get('/api/nsd/v1/' 'subscriptions/' + self.subscription_id, diff --git a/genericparser/packages/tests/test_nspackage.py b/catalog/packages/tests/test_nspackage.py index 393e0f7..91f3503 100644 --- a/genericparser/packages/tests/test_nspackage.py +++ b/catalog/packages/tests/test_nspackage.py @@ -18,9 +18,9 @@ from rest_framework import status from django.test import TestCase from django.test import Client -from genericparser.pub.utils import restcall, toscaparsers -from genericparser.pub.database.models import NSPackageModel, VnfPackageModel, PnfPackageModel -from genericparser.pub.msapi import sdc +from catalog.pub.utils import restcall, toscaparser +from catalog.pub.database.models import NSPackageModel, VnfPackageModel, PnfPackageModel +from catalog.pub.msapi import sdc from .const import nsd_data @@ -37,7 +37,7 @@ class TestNsPackage(TestCase): def test_ns_pkg_distribute_when_ns_exists(self): NSPackageModel(nsPackageId="1", nsdId="2").save() resp = self.client.post( - "/api/parser/v1/nspackages", {"csarId": "1"}, format='json') + "/api/catalog/v1/nspackages", {"csarId": "1"}, format='json') self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) self.assertEqual("failed", resp.data["status"]) self.assertEqual( @@ -48,7 +48,7 @@ class TestNsPackage(TestCase): def test_ns_pkg_distribute_when_csar_not_exist(self, mock_call_req): mock_call_req.return_value = [0, "[]", '200'] resp = self.client.post( - "/api/parser/v1/nspackages", {"csarId": "1"}, format='json') + "/api/catalog/v1/nspackages", {"csarId": "1"}, format='json') self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) self.assertEqual("failed", resp.data["status"]) self.assertEqual( @@ -57,7 +57,7 @@ class TestNsPackage(TestCase): @mock.patch.object(restcall, 'call_req') @mock.patch.object(sdc, 'download_artifacts') - @mock.patch.object(toscaparsers, 'parse_nsd') + @mock.patch.object(toscaparser, 'parse_nsd') def test_ns_pkg_distribute_when_nsd_already_exists( self, mock_parse_nsd, mock_download_artifacts, mock_call_req): mock_parse_nsd.return_value = json.JSONEncoder().encode(self.nsd_data) @@ -69,7 +69,7 @@ class TestNsPackage(TestCase): }]), '200'] NSPackageModel(nsPackageId="2", nsdId="VCPE_NS").save() resp = self.client.post( - "/api/parser/v1/nspackages", {"csarId": "1"}, format='json') + "/api/catalog/v1/nspackages", {"csarId": "1"}, format='json') self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) self.assertEqual("failed", resp.data["status"]) self.assertEqual( @@ -78,7 +78,7 @@ class TestNsPackage(TestCase): @mock.patch.object(restcall, 'call_req') @mock.patch.object(sdc, 'download_artifacts') - @mock.patch.object(toscaparsers, 'parse_nsd') + @mock.patch.object(toscaparser, 'parse_nsd') def test_ns_pkg_distribute_when_nf_not_distributed( self, mock_parse_nsd, mock_download_artifacts, mock_call_req): mock_parse_nsd.return_value = json.JSONEncoder().encode(self.nsd_data) @@ -89,7 +89,7 @@ class TestNsPackage(TestCase): "distributionStatus": "DISTRIBUTED", }]), '200'] resp = self.client.post( - "/api/parser/v1/nspackages", {"csarId": "1"}, format='json') + "/api/catalog/v1/nspackages", {"csarId": "1"}, format='json') self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) self.assertEqual("failed", resp.data["status"]) self.assertEqual( @@ -98,7 +98,7 @@ class TestNsPackage(TestCase): @mock.patch.object(restcall, 'call_req') @mock.patch.object(sdc, 'download_artifacts') - @mock.patch.object(toscaparsers, 'parse_nsd') + @mock.patch.object(toscaparser, 'parse_nsd') def test_ns_pkg_distribute_when_successfully( self, mock_parse_nsd, mock_download_artifacts, mock_call_req): mock_parse_nsd.return_value = json.JSONEncoder().encode(self.nsd_data) @@ -111,7 +111,7 @@ class TestNsPackage(TestCase): VnfPackageModel(vnfPackageId="1", vnfdId="vcpe_vfw_zte_1_0").save() PnfPackageModel(pnfPackageId="1", pnfdId="m6000_s").save() resp = self.client.post( - "/api/parser/v1/nspackages", {"csarId": "1"}, format='json') + "/api/catalog/v1/nspackages", {"csarId": "1"}, format='json') self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) self.assertEqual("success", resp.data["status"]) self.assertEqual( @@ -125,7 +125,7 @@ class TestNsPackage(TestCase): "invariantUUID": "63eaec39-ffbe-411c-a838-448f2c73f7eb", "name": "underlayvpn", "version": "2.0", - "toscaModelURL": "/sdc/v1/genericparser/resources/c94490a0-f7ef-48be-b3f8-8d8662a37236/toscaModel", + "toscaModelURL": "/sdc/v1/catalog/resources/c94490a0-f7ef-48be-b3f8-8d8662a37236/toscaModel", "category": "Volte", "subCategory": "VolteVNF", "resourceType": "VF", @@ -134,7 +134,7 @@ class TestNsPackage(TestCase): "lastUpdaterUserId": "jh0003" }] resp = self.client.post( - "/api/parser/v1/nspackages", {"csarId": "1"}, format='json') + "/api/catalog/v1/nspackages", {"csarId": "1"}, format='json') self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) self.assertEqual("failed", resp.data["status"]) self.assertEqual( @@ -145,7 +145,7 @@ class TestNsPackage(TestCase): def test_ns_pkg_normal_delete(self): NSPackageModel(nsPackageId="8", nsdId="2").save() - resp = self.client.delete("/api/parser/v1/nspackages/8") + resp = self.client.delete("/api/catalog/v1/nspackages/8") self.assertEqual(resp.status_code, status.HTTP_200_OK) self.assertEqual("success", resp.data["status"]) self.assertEqual( @@ -167,14 +167,14 @@ class TestNsPackage(TestCase): nsdVersion="3", nsPackageUri="14.csar", nsdModel="").save() - resp = self.client.get("/api/parser/v1/nspackages") + resp = self.client.get("/api/catalog/v1/nspackages") self.assertEqual(resp.status_code, status.HTTP_200_OK) expect_data = [{"csarId": "13", "packageInfo": {"csarName": "13.csar", "nsdProvider": "2", "nsdId": "2", "nsPackageId": "13", - "downloadUrl": "http://127.0.0.1:8806/static/genericparser/13/13.csar", + "downloadUrl": "http://127.0.0.1:8806/static/catalog/13/13.csar", "nsdModel": "", "nsdVersion": "2", "nsdInvariantId": None @@ -184,7 +184,7 @@ class TestNsPackage(TestCase): "nsdProvider": "3", "nsdId": "3", "nsPackageId": "14", - "downloadUrl": "http://127.0.0.1:8806/static/genericparser/14/14.csar", + "downloadUrl": "http://127.0.0.1:8806/static/catalog/14/14.csar", "nsdModel": "", "nsdVersion": "3", "nsdInvariantId": None}}] @@ -198,7 +198,7 @@ class TestNsPackage(TestCase): nsdVersion="4", nsPackageUri="14.csar", nsdModel="").save() - resp = self.client.get("/api/parser/v1/nspackages/14") + resp = self.client.get("/api/catalog/v1/nspackages/14") self.assertEqual(resp.status_code, status.HTTP_200_OK) expect_data = { "csarId": "14", @@ -209,12 +209,12 @@ class TestNsPackage(TestCase): "nsdVersion": "4", "csarName": "14.csar", "nsdModel": "", - "downloadUrl": "http://127.0.0.1:8806/static/genericparser/14/14.csar", + "downloadUrl": "http://127.0.0.1:8806/static/catalog/14/14.csar", "nsdInvariantId": None}} self.assertEqual(expect_data, resp.data) def test_ns_pkg_get_one_not_found(self): - resp = self.client.get("/api/parser/v1/nspackages/22") + resp = self.client.get("/api/catalog/v1/nspackages/22") self.assertEqual(resp.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) self.assertEqual( {"error": "Ns package[22] not Found."}, @@ -222,13 +222,13 @@ class TestNsPackage(TestCase): ########################################################################## - @mock.patch.object(toscaparsers, 'parse_nsd') + @mock.patch.object(toscaparser, 'parse_nsd') def test_nsd_parse_normal(self, mock_parse_nsd): NSPackageModel(nsPackageId="18", nsdId="12").save() mock_parse_nsd.return_value = json.JSONEncoder().encode({"a": "b"}) req_data = {"csarId": "18", "inputs": []} resp = self.client.post( - "/api/parser/v1/parsernsd", + "/api/catalog/v1/parsernsd", req_data, format='json') self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) @@ -237,7 +237,7 @@ class TestNsPackage(TestCase): def test_nsd_parse_when_csar_not_exist(self): req_data = {"csarId": "1", "inputs": []} resp = self.client.post( - "/api/parser/v1/parsernsd", + "/api/catalog/v1/parsernsd", req_data, format='json') self.assertEqual( diff --git a/genericparser/packages/tests/test_pnf_descriptor.py b/catalog/packages/tests/test_pnf_descriptor.py index 770d74b..8af8614 100644 --- a/genericparser/packages/tests/test_pnf_descriptor.py +++ b/catalog/packages/tests/test_pnf_descriptor.py @@ -19,15 +19,16 @@ import mock import os import shutil + from django.test import TestCase from rest_framework import status from rest_framework.test import APIClient -from genericparser.packages.biz.pnf_descriptor import PnfDescriptor -from genericparser.packages.const import PKG_STATUS -from genericparser.packages.tests.const import pnfd_data -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH -from genericparser.pub.database.models import PnfPackageModel, NSPackageModel -from genericparser.pub.utils import toscaparsers +from catalog.packages.biz.pnf_descriptor import PnfDescriptor +from catalog.packages.const import PKG_STATUS +from catalog.packages.tests.const import pnfd_data +from catalog.pub.config.config import CATALOG_ROOT_PATH +from catalog.pub.database.models import PnfPackageModel, NSPackageModel +from catalog.pub.utils import toscaparser class TestPnfDescriptor(TestCase): @@ -56,7 +57,7 @@ class TestPnfDescriptor(TestCase): } def tearDown(self): - file_path = os.path.join(GENERICPARSER_ROOT_PATH, "22") + file_path = os.path.join(CATALOG_ROOT_PATH, "22") if os.path.exists(file_path): shutil.rmtree(file_path) @@ -76,9 +77,7 @@ class TestPnfDescriptor(TestCase): ) response.data.pop('id') self.assertEqual(response.status_code, status.HTTP_201_CREATED) - # self.assertEqual(expected_reponse_data, response.data) - for key, value in expected_reponse_data.items(): - self.assertEqual(response.data[key], value) + self.assertEqual(expected_reponse_data, response.data) def test_query_multiple_pnfds_normal(self): expected_reponse_data = [ @@ -141,7 +140,7 @@ class TestPnfDescriptor(TestCase): self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT) self.assertEqual(None, resp.data) - @mock.patch.object(toscaparsers, "parse_pnfd") + @mock.patch.object(toscaparser, "parse_pnfd") def test_pnfd_content_upload_normal(self, mock_parse_pnfd): user_defined_data_json = json.JSONEncoder().encode(self.user_defined_data) PnfPackageModel( @@ -176,7 +175,7 @@ class TestPnfDescriptor(TestCase): ) self.assertEqual(resp.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) - @mock.patch.object(toscaparsers, "parse_pnfd") + @mock.patch.object(toscaparser, "parse_pnfd") def test_pnfd_content_upload_when_pnfd_exist(self, mock_parse_pnfd): with open('pnfd_content.txt', 'wt') as fp: fp.write('test') @@ -214,9 +213,9 @@ class TestPnfDescriptor(TestCase): resp = self.client.get("/api/nsd/v1/pnf_descriptors/22/pnfd_content") file_content = "" for data in resp.streaming_content: - file_content = '%s%s' % (file_content, data) + file_content = '%s%s' % (file_content, data.decode()) self.assertEqual(resp.status_code, status.HTTP_200_OK) - self.assertEqual("b'test1test2'", file_content) + self.assertEqual("test1test2", file_content) os.remove('pnfd_content.txt') def test_pnfd_download_failed(self): @@ -277,11 +276,11 @@ class TestPnfDescriptor(TestCase): response = self.client.get("/api/nsd/v1/pnf_descriptors/22/pnfd_content") self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) - @mock.patch.object(toscaparsers, 'parse_pnfd') + @mock.patch.object(toscaparser, 'parse_pnfd') def test_pnfd_parse_normal(self, mock_parse_pnfd): PnfPackageModel(pnfPackageId="8", pnfdId="10").save() mock_parse_pnfd.return_value = json.JSONEncoder().encode({"c": "d"}) req_data = {"csarId": "8", "inputs": []} - resp = self.client.post("/api/parser/v1/parserpnfd", req_data, format='json') + resp = self.client.post("/api/catalog/v1/parserpnfd", req_data, format='json') self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) self.assertEqual({"model": '{"c": "d"}'}, resp.data) diff --git a/genericparser/packages/tests/test_service_descriptor.py b/catalog/packages/tests/test_service_descriptor.py index 59bffa8..08a6f03 100644 --- a/genericparser/packages/tests/test_service_descriptor.py +++ b/catalog/packages/tests/test_service_descriptor.py @@ -17,11 +17,11 @@ import logging from django.test import TestCase from mock import mock -from genericparser.packages.biz.service_descriptor import ServiceDescriptor -from genericparser.packages.const import PKG_STATUS -from genericparser.pub.database.models import ServicePackageModel, VnfPackageModel, PnfPackageModel -from genericparser.pub.exceptions import PackageNotFoundException -from genericparser.pub.utils import toscaparsers +from catalog.packages.biz.service_descriptor import ServiceDescriptor +from catalog.packages.const import PKG_STATUS +from catalog.pub.database.models import ServicePackageModel, VnfPackageModel, PnfPackageModel +from catalog.pub.exceptions import PackageNotFoundException +from catalog.pub.utils import toscaparser from .const import sd_data logger = logging.getLogger(__name__) @@ -63,7 +63,7 @@ class TestServiceDescription(TestCase): self.assertEqual(PKG_STATUS.CREATED, service_package.onboardingState) self.assertEqual(PKG_STATUS.NOT_IN_USE, service_package.usageState) - @mock.patch.object(toscaparsers, 'parse_sd') + @mock.patch.object(toscaparser, 'parse_sd') def test_parse_serviced_and_save(self, mock_parse_sd): mock_parse_sd.return_value = json.JSONEncoder().encode(self.sd_data) servcie_desc = ServiceDescriptor() diff --git a/genericparser/packages/tests/test_servicepackage.py b/catalog/packages/tests/test_servicepackage.py index 786e34c..241d80d 100644 --- a/genericparser/packages/tests/test_servicepackage.py +++ b/catalog/packages/tests/test_servicepackage.py @@ -17,12 +17,12 @@ from django.test import TestCase, Client from mock import mock from rest_framework import status -from genericparser.packages.biz.sdc_service_package import ServicePackage -from genericparser.packages.const import PKG_STATUS -from genericparser.pub.database.models import ServicePackageModel, VnfPackageModel, PnfPackageModel -from genericparser.pub.exceptions import PackageNotFoundException, PackageHasExistsException, GenericparserException -from genericparser.pub.msapi import sdc -from genericparser.pub.utils import toscaparsers +from catalog.packages.biz.sdc_service_package import ServicePackage +from catalog.packages.const import PKG_STATUS +from catalog.pub.database.models import ServicePackageModel, VnfPackageModel, PnfPackageModel +from catalog.pub.exceptions import PackageNotFoundException, PackageHasExistsException, CatalogException +from catalog.pub.msapi import sdc +from catalog.pub.utils import toscaparser PARSER_BASE_URL = "/api/parser/v1" @@ -296,12 +296,12 @@ class TestServicePackage(TestCase): @mock.patch.object(sdc, 'get_asset') def test_service_pkg_distribute_when_fail_get_artifacts(self, mock_get_asset): - mock_get_asset.side_effect = GenericparserException("Failed to query artifact(services,1) from sdc.") + mock_get_asset.side_effect = CatalogException("Failed to query artifact(services,1) from sdc.") csar_id = "1" try: ServicePackage().on_distribute(csar_id) except Exception as e: - self.assertTrue(isinstance(e, GenericparserException)) + self.assertTrue(isinstance(e, CatalogException)) self.assertEqual("Failed to query artifact(services,1) from sdc.", e.args[0]) @mock.patch.object(sdc, 'get_asset') @@ -311,14 +311,14 @@ class TestServicePackage(TestCase): try: ServicePackage().on_distribute(csar_id) except Exception as e: - self.assertTrue(isinstance(e, GenericparserException)) + self.assertTrue(isinstance(e, CatalogException)) self.assertEqual("Resource (cd557883-ac4b-462d-aa01-421b5fa606b1) is not distributed.", e.args[0]) @mock.patch.object(sdc, 'get_asset') @mock.patch.object(sdc, 'download_artifacts') def test_service_pkg_distribute_when_fail_download_artifacts(self, mock_get_asset, mock_download_artifacts): mock_get_asset.return_value = self.asset_data - mock_download_artifacts.side_effect = GenericparserException("Failed to download 1 from sdc.") + mock_download_artifacts.side_effect = CatalogException("Failed to download 1 from sdc.") csar_id = "1" VnfPackageModel(vnfPackageId="cd557883-ac4b-462d-aa01-421b5fa606b1", vnfdId="cd557883-ac4b-462d-aa01-421b5fa606b1").save() @@ -327,12 +327,12 @@ class TestServicePackage(TestCase): try: ServicePackage().on_distribute(csar_id) except Exception as e: - self.assertTrue(isinstance(e, GenericparserException)) + self.assertTrue(isinstance(e, CatalogException)) self.assertEqual("Failed to download 1 from sdc.", e.args[0]) @mock.patch.object(sdc, 'get_asset') @mock.patch.object(sdc, 'download_artifacts') - @mock.patch.object(toscaparsers, 'parse_sd') + @mock.patch.object(toscaparser, 'parse_sd') def test_service_pkg_distribute(self, mock_parse_sd, mock_download_artifacts, mock_get_asset): mock_parse_sd.return_value = json.JSONEncoder().encode(self.sd_data) mock_download_artifacts.return_value = "/test.csar" @@ -454,7 +454,7 @@ class TestServicePackage(TestCase): ############################################################### - @mock.patch.object(toscaparsers, 'parse_sd') + @mock.patch.object(toscaparser, 'parse_sd') def test_service_pkg_parser(self, mock_parse_sd): ServicePackageModel(servicePackageId="8", servicedId="2").save() mock_parse_sd.return_value = json.JSONEncoder().encode({"a": "b"}) diff --git a/genericparser/packages/tests/test_vnf_package.py b/catalog/packages/tests/test_vnf_package.py index 9b8d7fe..b83268a 100644 --- a/genericparser/packages/tests/test_vnf_package.py +++ b/catalog/packages/tests/test_vnf_package.py @@ -22,12 +22,12 @@ from django.test import TestCase from rest_framework import status from rest_framework.test import APIClient -from genericparser.packages.biz.vnf_package import VnfPackage, VnfPkgUploadThread -from genericparser.packages.const import PKG_STATUS -from genericparser.packages.tests.const import vnfd_data -from genericparser.pub.config.config import GENERICPARSER_ROOT_PATH -from genericparser.pub.database.models import VnfPackageModel -from genericparser.pub.utils import toscaparsers +from catalog.packages.biz.vnf_package import VnfPackage, VnfPkgUploadThread +from catalog.packages.const import PKG_STATUS +from catalog.packages.tests.const import vnfd_data +from catalog.pub.config.config import CATALOG_ROOT_PATH +from catalog.pub.database.models import VnfPackageModel +from catalog.pub.utils import toscaparser class MockReq(): @@ -43,13 +43,13 @@ class TestVnfPackage(TestCase): self.client = APIClient() def tearDown(self): - file_path = os.path.join(GENERICPARSER_ROOT_PATH, "222") + file_path = os.path.join(CATALOG_ROOT_PATH, "222") if os.path.exists(file_path): shutil.rmtree(file_path) - @mock.patch.object(toscaparsers, 'parse_vnfd') + @mock.patch.object(toscaparser, 'parse_vnfd') def test_upload_vnf_pkg(self, mock_parse_vnfd): - data = {'file': open(os.path.join(GENERICPARSER_ROOT_PATH, "empty.txt"), "rt")} + data = {'file': open(os.path.join(CATALOG_ROOT_PATH, "empty.txt"), "rt")} VnfPackageModel.objects.create( vnfPackageId="222", onboardingState="CREATED" @@ -62,14 +62,14 @@ class TestVnfPackage(TestCase): self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) def test_upload_vnf_pkg_failed(self): - data = {'file': open(os.path.join(GENERICPARSER_ROOT_PATH, "empty.txt"), "rb")} + data = {'file': open(os.path.join(CATALOG_ROOT_PATH, "empty.txt"), "rb")} VnfPackageModel.objects.create( vnfPackageId="222", ) response = self.client.put("/api/vnfpkgm/v1/vnf_packages/222/package_content", data=data) self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) - @mock.patch.object(toscaparsers, 'parse_vnfd') + @mock.patch.object(toscaparser, 'parse_vnfd') @mock.patch.object(urllib.request, 'urlopen') def test_upload_nf_pkg_from_uri(self, mock_urlopen, mock_parse_vnfd): vnf_pkg = VnfPackageModel.objects.create( @@ -103,9 +103,7 @@ class TestVnfPackage(TestCase): "userDefinedData": {"a": "A"}, "_links": None # TODO } - # self.assertEqual(expect_resp_data, resp_data) - for key, value in expect_resp_data.items(): - self.assertEqual(resp_data[key], value) + self.assertEqual(expect_resp_data, resp_data) self.assertEqual(response.status_code, status.HTTP_201_CREATED) def test_query_single_vnf(self): @@ -138,9 +136,7 @@ class TestVnfPackage(TestCase): "userDefinedData": {"a": "A"}, "_links": None } - for key, value in expect_data.items(): - self.assertEqual(response.data[key], value) - # self.assertEqual(response.data, expect_data) + self.assertEqual(response.data, expect_data) self.assertEqual(response.status_code, status.HTTP_200_OK) def test_query_single_vnf_failed(self): @@ -207,12 +203,7 @@ class TestVnfPackage(TestCase): "_links": None } ] - # self.assertEqual(response.data, expect_data) - self.assertEqual(len(response.data), len(expect_data)) - for i in range(0, len(expect_data)): - for key, value in expect_data[i].items(): - self.assertEqual(response.data[i][key], value) - + self.assertEqual(response.data, expect_data) self.assertEqual(response.status_code, status.HTTP_200_OK) def test_delete_single_vnf_pkg(self): @@ -265,9 +256,9 @@ class TestVnfPackage(TestCase): response = self.client.get("/api/vnfpkgm/v1/vnf_packages/222/package_content", HTTP_RANGE="4-7") partial_file_content = '' for data in response.streaming_content: - partial_file_content = partial_file_content.encode() + data + partial_file_content = partial_file_content + data.decode() self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(b'BBB', partial_file_content) + self.assertEqual('BBB', partial_file_content) os.remove("vnfPackage.csar") def test_fetch_last_partical_vnf_pkg(self): @@ -281,9 +272,9 @@ class TestVnfPackage(TestCase): response = self.client.get("/api/vnfpkgm/v1/vnf_packages/222/package_content", HTTP_RANGE=" 4-") partial_file_content = '' for data in response.streaming_content: - partial_file_content = partial_file_content.encode() + data + partial_file_content = partial_file_content + data.decode() self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(b'BBBBCCCCDDDD', partial_file_content) + self.assertEqual('BBBBCCCCDDDD', partial_file_content) os.remove("vnfPackage.csar") def test_fetch_vnf_pkg_when_pkg_not_exist(self): @@ -326,9 +317,9 @@ class TestVnfPackage(TestCase): response = self.client.get("/api/vnfpkgm/v1/vnf_packages") self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) - @mock.patch.object(toscaparsers, 'parse_vnfd') + @mock.patch.object(toscaparser, 'parse_vnfd') def test_upload_when_catch_exception(self, mock_parse_vnfd): - data = {'file': open(os.path.join(GENERICPARSER_ROOT_PATH, "empty.txt"), "rb")} + data = {'file': open(os.path.join(CATALOG_ROOT_PATH, "empty.txt"), "rb")} VnfPackageModel.objects.create( vnfPackageId="222", onboardingState="CREATED" @@ -350,9 +341,9 @@ class TestVnfPackage(TestCase): response = self.client.get("/api/vnfpkgm/v1/vnf_packages/222/package_content") self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) - @mock.patch.object(toscaparsers, 'parse_vnfd') + @mock.patch.object(toscaparser, 'parse_vnfd') def test_fetch_vnf_artifact(self, mock_parse_vnfd): - data = {'file': open(os.path.join(GENERICPARSER_ROOT_PATH, "resource_test.csar"), "rb")} + data = {'file': open(os.path.join(CATALOG_ROOT_PATH, "resource_test.csar"), "rb")} VnfPackageModel.objects.create( vnfPackageId="222", onboardingState="CREATED" @@ -364,9 +355,9 @@ class TestVnfPackage(TestCase): self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.getvalue(), b"ubuntu_16.04\n") - @mock.patch.object(toscaparsers, 'parse_vnfd') + @mock.patch.object(toscaparser, 'parse_vnfd') def test_fetch_vnf_artifact_not_exists(self, mock_parse_vnfd): - data = {'file': open(os.path.join(GENERICPARSER_ROOT_PATH, "resource_test.csar"), "rb")} + data = {'file': open(os.path.join(CATALOG_ROOT_PATH, "resource_test.csar"), "rb")} VnfPackageModel.objects.create( vnfPackageId="222", onboardingState="CREATED" @@ -377,9 +368,9 @@ class TestVnfPackage(TestCase): response = self.client.get("/api/vnfpkgm/v1/vnf_packages/1451/artifacts/image") self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) - @mock.patch.object(toscaparsers, 'parse_vnfd') + @mock.patch.object(toscaparser, 'parse_vnfd') def test_fetch_vnf_artifact_vnf_not_exists(self, mock_parse_vnfd): - data = {'file': open(os.path.join(GENERICPARSER_ROOT_PATH, "resource_test.csar"), "rb")} + data = {'file': open(os.path.join(CATALOG_ROOT_PATH, "resource_test.csar"), "rb")} VnfPackageModel.objects.create( vnfPackageId="222", onboardingState="CREATED" diff --git a/genericparser/packages/tests/test_vnf_pkg_subscription.py b/catalog/packages/tests/test_vnf_pkg_subscription.py index e35f195..635b137 100644 --- a/genericparser/packages/tests/test_vnf_pkg_subscription.py +++ b/catalog/packages/tests/test_vnf_pkg_subscription.py @@ -18,7 +18,7 @@ import mock from rest_framework.test import APIClient from django.test import TestCase -from genericparser.pub.database.models import VnfPkgSubscriptionModel +from catalog.pub.database.models import VnfPkgSubscriptionModel from .const import vnf_subscription_data diff --git a/genericparser/packages/tests/test_vnfpackage.py b/catalog/packages/tests/test_vnfpackage.py index 70f7021..0d8cbad 100644 --- a/genericparser/packages/tests/test_vnfpackage.py +++ b/catalog/packages/tests/test_vnfpackage.py @@ -17,11 +17,11 @@ import mock from rest_framework.test import APIClient from django.test import TestCase from rest_framework import status -from genericparser.packages.biz.sdc_vnf_package import NfDistributeThread, NfPkgDeleteThread -from genericparser.pub.database.models import JobStatusModel, JobModel -from genericparser.pub.database.models import VnfPackageModel -from genericparser.pub.msapi import sdc -from genericparser.pub.utils import restcall, toscaparsers +from catalog.packages.biz.sdc_vnf_package import NfDistributeThread, NfPkgDeleteThread +from catalog.pub.database.models import JobStatusModel, JobModel +from catalog.pub.database.models import VnfPackageModel +from catalog.pub.msapi import sdc +from catalog.pub.utils import restcall, toscaparser from .const import vnfd_data @@ -46,7 +46,7 @@ class TestNfPackage(TestCase): @mock.patch.object(NfDistributeThread, 'run') def test_nf_pkg_distribute_normal(self, mock_run): resp = self.client.post( - "/api/parser/v1/vnfpackages", + "/api/catalog/v1/vnfpackages", { "csarId": "1", "vimIds": ["1"] @@ -70,7 +70,7 @@ class TestNfPackage(TestCase): @mock.patch.object(restcall, 'call_req') @mock.patch.object(sdc, 'download_artifacts') - @mock.patch.object(toscaparsers, 'parse_vnfd') + @mock.patch.object(toscaparser, 'parse_vnfd') def test_nf_pkg_distribute_when_vnfd_already_exist(self, mock_parse_vnfd, mock_download_artifacts, @@ -81,41 +81,52 @@ class TestNfPackage(TestCase): "uuid": "1", "toscaModelURL": "https://127.0.0.1:1234/sdc/v1/hss.csar" }]), '200'] - VnfPackageModel(vnfPackageId="2", - vnfdId="zte-hss-1.0").save() - NfDistributeThread(csar_id="1", - vim_ids=["1"], - lab_vim_id="", - job_id="2").run() + VnfPackageModel(vnfPackageId="2", vnfdId="zte-hss-1.0").save() + NfDistributeThread( + csar_id="1", + vim_ids=["1"], + lab_vim_id="", + job_id="2" + ).run() self.assert_job_result("2", 255, "VNF package(zte-hss-1.0) already exists.") @mock.patch.object(restcall, 'call_req') @mock.patch.object(sdc, 'download_artifacts') - @mock.patch.object(toscaparsers, 'parse_vnfd') + @mock.patch.object(toscaparser, 'parse_vnfd') def test_nf_pkg_distribute_successfully(self, - mock_parse_vnfd, mock_download_artifacts, mock_call_req): + mock_parse_vnfd, + mock_download_artifacts, + mock_call_req): mock_parse_vnfd.return_value = json.JSONEncoder().encode(self.vnfd_data) mock_download_artifacts.return_value = "/home/hss.csar" mock_call_req.return_value = [0, json.JSONEncoder().encode([{ "uuid": "1", "toscaModelURL": "https://127.0.0.1:1234/sdc/v1/hss.csar" }]), '200'] - NfDistributeThread(csar_id="1", - vim_ids=["1"], - lab_vim_id="", - job_id="4").run() + NfDistributeThread( + csar_id="1", + vim_ids=["1"], + lab_vim_id="", + job_id="4" + ).run() self.assert_job_result("4", 100, "CSAR(1) distribute successfully.") ############################################################################################################### @mock.patch.object(NfPkgDeleteThread, 'run') def test_nf_pkg_delete_normal(self, mock_run): - resp = self.client.delete("/api/parser/v1/vnfpackages/1") + resp = self.client.delete("/api/catalog/v1/vnfpackages/1") self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) def test_nf_pkg_normal_delete(self): - VnfPackageModel(vnfPackageId="2", vnfdId="vcpe_vfw_zte_1_0").save() - NfPkgDeleteThread(csar_id="2", job_id="2").run() + VnfPackageModel( + vnfPackageId="2", + vnfdId="vcpe_vfw_zte_1_0" + ).save() + NfPkgDeleteThread( + csar_id="2", + job_id="2" + ).run() self.assert_job_result("2", 100, "Delete CSAR(2) successfully.") def test_nf_pkg_get_all(self): @@ -137,7 +148,7 @@ class TestNfPackage(TestCase): vnfPackageUri='', vnfdModel='' ).save() - resp = self.client.get("/api/parser/v1/vnfpackages") + resp = self.client.get("/api/catalog/v1/vnfpackages") self.assertEqual(resp.status_code, status.HTTP_200_OK) expect_data = [ { @@ -148,7 +159,7 @@ class TestNfPackage(TestCase): "vnfdModel": "", "vnfdProvider": "3", "vnfdId": "3", - "downloadUrl": "http://127.0.0.1:8806/static/genericparser/3/", + "downloadUrl": "http://127.0.0.1:8806/static/catalog/3/", "vnfVersion": "", "vnfdVersion": "3", "vnfPackageId": "3" @@ -162,7 +173,7 @@ class TestNfPackage(TestCase): "vnfdModel": "", "vnfdProvider": "4", "vnfdId": "4", - "downloadUrl": "http://127.0.0.1:8806/static/genericparser/4/", + "downloadUrl": "http://127.0.0.1:8806/static/catalog/4/", "vnfVersion": "", "vnfdVersion": "4", "vnfPackageId": "4" @@ -182,7 +193,7 @@ class TestNfPackage(TestCase): vnfdModel='' ).save() - resp = self.client.get("/api/parser/v1/vnfpackages/4") + resp = self.client.get("/api/catalog/v1/vnfpackages/4") self.assertEqual(resp.status_code, status.HTTP_200_OK) expect_data = { "imageInfo": [], @@ -192,7 +203,7 @@ class TestNfPackage(TestCase): "vnfdModel": "", "vnfdProvider": "4", "vnfdId": "4", - "downloadUrl": "http://127.0.0.1:8806/static/genericparser/4/", + "downloadUrl": "http://127.0.0.1:8806/static/catalog/4/", "vnfVersion": "", "vnfdVersion": "4", "vnfPackageId": "4" @@ -201,31 +212,47 @@ class TestNfPackage(TestCase): self.assertEqual(expect_data, resp.data) def test_nf_pkg_get_one_failed(self): - VnfPackageModel(vnfPackageId="4", - vnfdId="4", - vnfVendor='4', - vnfdVersion='4', - vnfSoftwareVersion='', - vnfPackageUri='', - vnfdModel='').save() - - resp = self.client.get("/api/parser/v1/vnfpackages/2") + VnfPackageModel( + vnfPackageId="4", + vnfdId="4", + vnfVendor='4', + vnfdVersion='4', + vnfSoftwareVersion='', + vnfPackageUri='', + vnfdModel='' + ).save() + + resp = self.client.get("/api/catalog/v1/vnfpackages/2") self.assertEqual(resp.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) self.assertEqual({'error': 'Vnf package[2] not Found.'}, resp.data) ############################################################################################################### - @mock.patch.object(toscaparsers, 'parse_vnfd') + @mock.patch.object(toscaparser, 'parse_vnfd') def test_vnfd_parse_normal(self, mock_parse_vnfd): - VnfPackageModel(vnfPackageId="8", vnfdId="10").save() + VnfPackageModel( + vnfPackageId="8", + vnfdId="10" + ).save() mock_parse_vnfd.return_value = json.JSONEncoder().encode({"c": "d"}) - req_data = {"csarId": "8", "inputs": []} - resp = self.client.post("/api/parser/v1/parservnfd", req_data, format='json') + req_data = { + "csarId": "8", + "inputs": [] + } + resp = self.client.post( + "/api/catalog/v1/parservnfd", + req_data, + format='json' + ) self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED) self.assertEqual({"model": '{"c": "d"}'}, resp.data) def test_vnfd_parse_when_csar_not_exist(self): req_data = {"csarId": "1", "inputs": []} - resp = self.client.post("/api/parser/v1/parservnfd", req_data, format='json') + resp = self.client.post( + "/api/catalog/v1/parservnfd", + req_data, + format='json' + ) self.assertEqual(resp.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) self.assertEqual(resp.data, {"error": "VNF CSAR(1) does not exist."}) diff --git a/genericparser/packages/urls.py b/catalog/packages/urls.py index 49199ac..776e940 100644 --- a/genericparser/packages/urls.py +++ b/catalog/packages/urls.py @@ -14,21 +14,21 @@ from django.conf.urls import url -from genericparser.packages.views import vnf_package_views -from genericparser.packages.views.vnf_package_subscription_views import CreateQuerySubscriptionView,\ +from catalog.packages.views import vnf_package_views +from catalog.packages.views.vnf_package_subscription_views import CreateQuerySubscriptionView,\ QueryTerminateSubscriptionView -from genericparser.packages.views.vnf_package_artifact_views import FetchVnfPkgmArtifactsView -from genericparser.packages.views import catalog_views, ns_descriptor_views, pnf_descriptor_views, nsdm_subscription_views -from genericparser.packages.views.health_check_views import HealthCheckView +from catalog.packages.views.vnf_package_artifact_views import FetchVnfPkgmArtifactsView +from catalog.packages.views import catalog_views, ns_descriptor_views, pnf_descriptor_views, nsdm_subscription_views +from catalog.packages.views.health_check_views import HealthCheckView urlpatterns = [ # Sync package from SDC - url(r'^api/parser/v1/nspackages$', catalog_views.nspackages_rc, name='nspackages_rc'), - url(r'^api/parser/v1/nspackages/(?P<csarId>[0-9a-zA-Z\-\_]+)$', catalog_views.ns_rd_csar, name='nspackage_rd'), - url(r'^api/parser/v1/vnfpackages$', catalog_views.nfpackages_rc, name='nfpackages_rc'), - url(r'^api/parser/v1/vnfpackages/(?P<csarId>[0-9a-zA-Z\-\_]+)$', catalog_views.nf_rd_csar, name='nfpackage_rd'), + url(r'^api/catalog/v1/nspackages$', catalog_views.nspackages_rc, name='nspackages_rc'), + url(r'^api/catalog/v1/nspackages/(?P<csarId>[0-9a-zA-Z\-\_]+)$', catalog_views.ns_rd_csar, name='nspackage_rd'), + url(r'^api/catalog/v1/vnfpackages$', catalog_views.nfpackages_rc, name='nfpackages_rc'), + url(r'^api/catalog/v1/vnfpackages/(?P<csarId>[0-9a-zA-Z\-\_]+)$', catalog_views.nf_rd_csar, name='nfpackage_rd'), url(r'^api/parser/v1/service_packages$', catalog_views.servicepackages_rc, name='servicepackages_rc'), url(r'^api/parser/v1/service_packages/(?P<csarId>[0-9a-zA-Z\-\_]+)$', catalog_views.service_rd_csar, name='servicepackage_rd'), @@ -37,6 +37,9 @@ urlpatterns = [ url(r'^api/parser/v1/parsernsd$', catalog_views.ns_model_parser, name='nsmodelparser_rc'), url(r'^api/parser/v1/parservnfd$', catalog_views.vnf_model_parser, name='vnfmodelparser_rc'), url(r'^api/parser/v1/parserpnfd$', pnf_descriptor_views.pnf_model_parser, name='pnfmodelparser_rc'), + url(r'^api/catalog/v1/parsernsd$', catalog_views.ns_model_parser, name='nsmodelparser_rc'), + url(r'^api/catalog/v1/parservnfd$', catalog_views.vnf_model_parser, name='vnfmodelparser_rc'), + url(r'^api/catalog/v1/parserpnfd$', pnf_descriptor_views.pnf_model_parser, name='pnfmodelparser_rc'), # ETSI SOL005 NSD API url(r'^api/nsd/v1/ns_descriptors$', ns_descriptor_views.ns_descriptors_rc, name='ns_descriptors_rc'), @@ -68,5 +71,6 @@ urlpatterns = [ # health check url(r'^api/vnfpkgm/v1/health_check$', HealthCheckView.as_view()), url(r'^api/nsd/v1/health_check$', HealthCheckView.as_view()), + url(r'^api/catalog/v1/health_check$', HealthCheckView.as_view()), url(r'^api/parser/v1/health_check$', HealthCheckView.as_view()), ] diff --git a/genericparser/packages/views/__init__.py b/catalog/packages/views/__init__.py index 342c2a8..342c2a8 100644 --- a/genericparser/packages/views/__init__.py +++ b/catalog/packages/views/__init__.py diff --git a/genericparser/packages/views/catalog_views.py b/catalog/packages/views/catalog_views.py index df3dfca..6ed9fb9 100644 --- a/genericparser/packages/views/catalog_views.py +++ b/catalog/packages/views/catalog_views.py @@ -20,25 +20,25 @@ from drf_yasg.utils import no_body, swagger_auto_schema from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response -from genericparser.packages.biz import sdc_vnf_package, sdc_ns_package -from genericparser.packages.biz.pnf_descriptor import PnfDescriptor -from genericparser.packages.biz.sdc_service_package import ServicePackage -from genericparser.packages.serializers.genericparser_serializers import InternalErrorRequestSerializer, \ +from catalog.packages.biz import sdc_vnf_package, sdc_ns_package +from catalog.packages.biz.pnf_descriptor import PnfDescriptor +from catalog.packages.biz.sdc_service_package import ServicePackage +from catalog.packages.serializers.catalog_serializers import InternalErrorRequestSerializer, \ ServicePackageDistributeRequestSerializer, ServicePackagesSerializer, ServicePackageSerializer -from genericparser.packages.serializers.genericparser_serializers import NfPackageDistributeRequestSerializer -from genericparser.packages.serializers.genericparser_serializers import NfPackageSerializer -from genericparser.packages.serializers.genericparser_serializers import NfPackagesSerializer -from genericparser.packages.serializers.genericparser_serializers import NsPackageDistributeRequestSerializer -from genericparser.packages.serializers.genericparser_serializers import NsPackageDistributeResponseSerializer -from genericparser.packages.serializers.genericparser_serializers import NsPackageSerializer -from genericparser.packages.serializers.genericparser_serializers import NsPackagesSerializer -from genericparser.packages.serializers.genericparser_serializers import ParseModelRequestSerializer -from genericparser.packages.serializers.genericparser_serializers import ParseModelResponseSerializer -from genericparser.packages.serializers.genericparser_serializers import PostJobResponseSerializer -from genericparser.packages.views.common import fmt_error_rsp -from genericparser.pub.exceptions import PackageNotFoundException, PackageHasExistsException -from genericparser.pub.utils.syscomm import fun_name -from genericparser.pub.utils.values import ignore_case_get +from catalog.packages.serializers.catalog_serializers import NfPackageDistributeRequestSerializer +from catalog.packages.serializers.catalog_serializers import NfPackageSerializer +from catalog.packages.serializers.catalog_serializers import NfPackagesSerializer +from catalog.packages.serializers.catalog_serializers import NsPackageDistributeRequestSerializer +from catalog.packages.serializers.catalog_serializers import NsPackageDistributeResponseSerializer +from catalog.packages.serializers.catalog_serializers import NsPackageSerializer +from catalog.packages.serializers.catalog_serializers import NsPackagesSerializer +from catalog.packages.serializers.catalog_serializers import ParseModelRequestSerializer +from catalog.packages.serializers.catalog_serializers import ParseModelResponseSerializer +from catalog.packages.serializers.catalog_serializers import PostJobResponseSerializer +from catalog.packages.views.common import fmt_error_rsp +from catalog.pub.exceptions import PackageNotFoundException, PackageHasExistsException +from catalog.pub.utils.syscomm import fun_name +from catalog.pub.utils.values import ignore_case_get logger = logging.getLogger(__name__) diff --git a/genericparser/packages/views/common.py b/catalog/packages/views/common.py index efd045b..6285cb9 100644 --- a/genericparser/packages/views/common.py +++ b/catalog/packages/views/common.py @@ -18,15 +18,15 @@ import logging from rest_framework import status from rest_framework.response import Response -from genericparser.pub.exceptions import GenericparserException -from genericparser.pub.exceptions import BadRequestException -from genericparser.pub.exceptions import NsdmBadRequestException -from genericparser.pub.exceptions import PackageNotFoundException -from genericparser.pub.exceptions import ResourceNotFoundException -from genericparser.pub.exceptions import ArtifactNotFoundException -from genericparser.pub.exceptions import NsdmDuplicateSubscriptionException -from genericparser.pub.exceptions import VnfPkgDuplicateSubscriptionException -from genericparser.pub.exceptions import VnfPkgSubscriptionException +from catalog.pub.exceptions import CatalogException +from catalog.pub.exceptions import BadRequestException +from catalog.pub.exceptions import NsdmBadRequestException +from catalog.pub.exceptions import PackageNotFoundException +from catalog.pub.exceptions import ResourceNotFoundException +from catalog.pub.exceptions import ArtifactNotFoundException +from catalog.pub.exceptions import NsdmDuplicateSubscriptionException +from catalog.pub.exceptions import VnfPkgDuplicateSubscriptionException +from catalog.pub.exceptions import VnfPkgSubscriptionException logger = logging.getLogger(__name__) @@ -35,7 +35,7 @@ def validate_data(data, serializer): serialized_data = serializer(data=data) if not serialized_data.is_valid(): logger.error('Data validation failed.') - raise GenericparserException(serialized_data.errors) + raise CatalogException(serialized_data.errors) return serialized_data @@ -106,7 +106,7 @@ def view_safe_call_with_log(logger): detail=e.args[0], status=status.HTTP_500_INTERNAL_SERVER_ERROR ) - except GenericparserException as e: + except CatalogException as e: logger.error(e.args[0]) return make_error_resp( detail=e.args[0], diff --git a/genericparser/packages/views/health_check_views.py b/catalog/packages/views/health_check_views.py index cc1a379..cc1a379 100644 --- a/genericparser/packages/views/health_check_views.py +++ b/catalog/packages/views/health_check_views.py diff --git a/genericparser/packages/views/ns_descriptor_views.py b/catalog/packages/views/ns_descriptor_views.py index bbe51ea..3b8c1f9 100644 --- a/genericparser/packages/views/ns_descriptor_views.py +++ b/catalog/packages/views/ns_descriptor_views.py @@ -20,12 +20,12 @@ from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response -from genericparser.packages.biz.ns_descriptor import NsDescriptor -from genericparser.packages.serializers.create_nsd_info_request import CreateNsdInfoRequestSerializer -from genericparser.packages.serializers.nsd_info import NsdInfoSerializer -from genericparser.packages.serializers.nsd_infos import NsdInfosSerializer -from genericparser.packages.views.common import validate_data -from genericparser.pub.exceptions import GenericparserException +from catalog.packages.biz.ns_descriptor import NsDescriptor +from catalog.packages.serializers.create_nsd_info_request import CreateNsdInfoRequestSerializer +from catalog.packages.serializers.nsd_info import NsdInfoSerializer +from catalog.packages.serializers.nsd_infos import NsdInfosSerializer +from catalog.packages.views.common import validate_data +from catalog.pub.exceptions import CatalogException from .common import view_safe_call_with_log logger = logging.getLogger(__name__) @@ -87,14 +87,14 @@ def ns_descriptors_rc(request): if request.method == 'POST': create_nsd_info_request = validate_data(request.data, CreateNsdInfoRequestSerializer) data = NsDescriptor().create(create_nsd_info_request.data) - nsd_info = validate_data(data, NsdInfoSerializer) - return Response(data=nsd_info.data, status=status.HTTP_201_CREATED) + validate_data(data, NsdInfoSerializer) + return Response(data=data, status=status.HTTP_201_CREATED) if request.method == 'GET': nsdId = request.query_params.get("nsdId", None) data = NsDescriptor().query_multiple(nsdId) - nsd_infos = validate_data(data, NsdInfosSerializer) - return Response(data=nsd_infos.data, status=status.HTTP_200_OK) + validate_data(data, NsdInfosSerializer) + return Response(data=data, status=status.HTTP_200_OK) @swagger_auto_schema( @@ -126,7 +126,7 @@ def nsd_content_ru(request, **kwargs): local_file_name = NsDescriptor().upload(nsd_info_id, files[0]) NsDescriptor().parse_nsd_and_save(nsd_info_id, local_file_name) return Response(data=None, status=status.HTTP_204_NO_CONTENT) - except GenericparserException as e: + except CatalogException as e: NsDescriptor().handle_upload_failed(nsd_info_id) raise e except Exception as e: diff --git a/genericparser/packages/views/nsdm_subscription_views.py b/catalog/packages/views/nsdm_subscription_views.py index e0576c3..5e6394e 100644 --- a/genericparser/packages/views/nsdm_subscription_views.py +++ b/catalog/packages/views/nsdm_subscription_views.py @@ -19,16 +19,16 @@ from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response -from genericparser.packages.serializers.nsdm_filter_data import NsdmNotificationsFilter -from genericparser.packages.serializers.nsdm_subscription import NsdmSubscriptionsSerializer -from genericparser.packages.serializers.nsdm_subscription import NsdmSubscriptionIdSerializer -from genericparser.packages.serializers.nsdm_subscription import NsdmSubscriptionSerializer -from genericparser.packages.serializers.nsdm_subscription import NsdmSubscriptionRequestSerializer +from catalog.packages.serializers.nsdm_filter_data import NsdmNotificationsFilter +from catalog.packages.serializers.nsdm_subscription import NsdmSubscriptionsSerializer +from catalog.packages.serializers.nsdm_subscription import NsdmSubscriptionIdSerializer +from catalog.packages.serializers.nsdm_subscription import NsdmSubscriptionSerializer +from catalog.packages.serializers.nsdm_subscription import NsdmSubscriptionRequestSerializer +from catalog.packages.serializers.response import ProblemDetailsSerializer -from genericparser.packages.serializers.response import ProblemDetailsSerializer -from genericparser.pub.exceptions import NsdmBadRequestException +from catalog.pub.exceptions import NsdmBadRequestException +from catalog.packages.biz.nsdm_subscription import NsdmSubscription from .common import view_safe_call_with_log -from genericparser.packages.biz.nsdm_subscription import NsdmSubscription logger = logging.getLogger(__name__) diff --git a/genericparser/packages/views/pnf_descriptor_views.py b/catalog/packages/views/pnf_descriptor_views.py index 7abd8ad..9120980 100644 --- a/genericparser/packages/views/pnf_descriptor_views.py +++ b/catalog/packages/views/pnf_descriptor_views.py @@ -20,17 +20,17 @@ from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response -from genericparser.packages.biz.pnf_descriptor import PnfDescriptor -from genericparser.packages.serializers.create_pnfd_info_request import CreatePnfdInfoRequestSerializer -from genericparser.packages.serializers.pnfd_info import PnfdInfoSerializer -from genericparser.packages.serializers.pnfd_infos import PnfdInfosSerializer -from genericparser.packages.views.common import validate_data -from genericparser.packages.serializers.genericparser_serializers import ParseModelRequestSerializer -from genericparser.packages.serializers.genericparser_serializers import ParseModelResponseSerializer -from genericparser.packages.serializers.genericparser_serializers import InternalErrorRequestSerializer -from genericparser.packages.serializers.response import ProblemDetailsSerializer -from genericparser.pub.utils.syscomm import fun_name -from genericparser.pub.utils.values import ignore_case_get +from catalog.packages.biz.pnf_descriptor import PnfDescriptor +from catalog.packages.serializers.create_pnfd_info_request import CreatePnfdInfoRequestSerializer +from catalog.packages.serializers.pnfd_info import PnfdInfoSerializer +from catalog.packages.serializers.pnfd_infos import PnfdInfosSerializer +from catalog.packages.views.common import validate_data +from catalog.packages.serializers.catalog_serializers import ParseModelRequestSerializer +from catalog.packages.serializers.catalog_serializers import ParseModelResponseSerializer +from catalog.packages.serializers.catalog_serializers import InternalErrorRequestSerializer +from catalog.packages.serializers.response import ProblemDetailsSerializer +from catalog.pub.utils.syscomm import fun_name +from catalog.pub.utils.values import ignore_case_get from .common import view_safe_call_with_log logger = logging.getLogger(__name__) @@ -95,13 +95,13 @@ def pnf_descriptors_rc(request): if request.method == 'POST': create_pnfd_info_request = validate_data(request.data, CreatePnfdInfoRequestSerializer) data = PnfDescriptor().create(create_pnfd_info_request.data) - pnfd_info = validate_data(data, PnfdInfoSerializer) - return Response(data=pnfd_info.data, status=status.HTTP_201_CREATED) + validate_data(data, PnfdInfoSerializer) + return Response(data=data, status=status.HTTP_201_CREATED) if request.method == 'GET': data = PnfDescriptor().query_multiple(request) - pnfd_infos = validate_data(data, PnfdInfosSerializer) - return Response(data=pnfd_infos.data, status=status.HTTP_200_OK) + validate_data(data, PnfdInfosSerializer) + return Response(data=data, status=status.HTTP_200_OK) @swagger_auto_schema( diff --git a/genericparser/packages/views/vnf_package_artifact_views.py b/catalog/packages/views/vnf_package_artifact_views.py index 164db6c..0de9682 100644 --- a/genericparser/packages/views/vnf_package_artifact_views.py +++ b/catalog/packages/views/vnf_package_artifact_views.py @@ -19,8 +19,8 @@ from rest_framework import status from rest_framework.views import APIView from django.http import FileResponse -from genericparser.packages.serializers.response import ProblemDetailsSerializer -from genericparser.packages.biz.vnf_pkg_artifacts import FetchVnfPkgArtifact +from catalog.packages.serializers.response import ProblemDetailsSerializer +from catalog.packages.biz.vnf_pkg_artifacts import FetchVnfPkgArtifact from .common import view_safe_call_with_log logger = logging.getLogger(__name__) diff --git a/genericparser/packages/views/vnf_package_subscription_views.py b/catalog/packages/views/vnf_package_subscription_views.py index 135b625..32904e3 100644 --- a/genericparser/packages/views/vnf_package_subscription_views.py +++ b/catalog/packages/views/vnf_package_subscription_views.py @@ -19,17 +19,16 @@ from rest_framework import status from rest_framework.views import APIView from rest_framework.response import Response -from genericparser.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionRequestSerializer -from genericparser.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionSerializer -from genericparser.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionsSerializer -from genericparser.packages.serializers.response import ProblemDetailsSerializer -from genericparser.packages.biz.vnf_pkg_subscription import CreateSubscription -from genericparser.packages.biz.vnf_pkg_subscription import QuerySubscription -from genericparser.packages.biz.vnf_pkg_subscription import TerminateSubscription -from genericparser.packages.views.common import validate_data -from genericparser.pub.exceptions import VnfPkgSubscriptionException -from genericparser.pub.exceptions import BadRequestException - +from catalog.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionRequestSerializer +from catalog.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionSerializer +from catalog.packages.serializers.vnf_pkg_subscription import PkgmSubscriptionsSerializer +from catalog.packages.serializers.response import ProblemDetailsSerializer +from catalog.packages.biz.vnf_pkg_subscription import CreateSubscription +from catalog.packages.biz.vnf_pkg_subscription import QuerySubscription +from catalog.packages.biz.vnf_pkg_subscription import TerminateSubscription +from catalog.packages.views.common import validate_data +from catalog.pub.exceptions import VnfPkgSubscriptionException +from catalog.pub.exceptions import BadRequestException from .common import view_safe_call_with_log logger = logging.getLogger(__name__) diff --git a/genericparser/packages/views/vnf_package_views.py b/catalog/packages/views/vnf_package_views.py index bfb1224..9fc143b 100644 --- a/genericparser/packages/views/vnf_package_views.py +++ b/catalog/packages/views/vnf_package_views.py @@ -19,14 +19,15 @@ from drf_yasg.utils import swagger_auto_schema, no_body from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response -from genericparser.packages.serializers.upload_vnf_pkg_from_uri_req import UploadVnfPackageFromUriRequestSerializer -from genericparser.packages.serializers.create_vnf_pkg_info_req import CreateVnfPkgInfoRequestSerializer -from genericparser.packages.serializers.vnf_pkg_info import VnfPkgInfoSerializer -from genericparser.packages.serializers.vnf_pkg_infos import VnfPkgInfosSerializer -from genericparser.packages.biz.vnf_package import VnfPackage -from genericparser.packages.biz.vnf_package import VnfPkgUploadThread -from genericparser.packages.biz.vnf_package import parse_vnfd_and_save -from genericparser.packages.biz.vnf_package import handle_upload_failed + +from catalog.packages.serializers.upload_vnf_pkg_from_uri_req import UploadVnfPackageFromUriRequestSerializer +from catalog.packages.serializers.create_vnf_pkg_info_req import CreateVnfPkgInfoRequestSerializer +from catalog.packages.serializers.vnf_pkg_info import VnfPkgInfoSerializer +from catalog.packages.serializers.vnf_pkg_infos import VnfPkgInfosSerializer +from catalog.packages.biz.vnf_package import VnfPackage +from catalog.packages.biz.vnf_package import VnfPkgUploadThread +from catalog.packages.biz.vnf_package import parse_vnfd_and_save +from catalog.packages.biz.vnf_package import handle_upload_failed from .common import validate_data from .common import view_safe_call_with_log @@ -57,16 +58,16 @@ def vnf_packages_rc(request): if request.method == 'GET': logger.debug("Query VNF packages> %s" % request.data) data = VnfPackage().query_multiple() - vnf_pkg_infos = validate_data(data, VnfPkgInfosSerializer) - return Response(data=vnf_pkg_infos.data, status=status.HTTP_200_OK) + validate_data(data, VnfPkgInfosSerializer) + return Response(data=data, status=status.HTTP_200_OK) if request.method == 'POST': logger.debug("Create VNF package> %s" % request.data) create_vnf_pkg_info_request = validate_data(request.data, CreateVnfPkgInfoRequestSerializer) data = VnfPackage().create_vnf_pkg(create_vnf_pkg_info_request.data) - vnf_pkg_info = validate_data(data, VnfPkgInfoSerializer) - return Response(data=vnf_pkg_info.data, status=status.HTTP_201_CREATED) + validate_data(data, VnfPkgInfoSerializer) + return Response(data=data, status=status.HTTP_201_CREATED) @swagger_auto_schema( @@ -158,8 +159,8 @@ def vnf_package_rd(request, **kwargs): if request.method == 'GET': logger.debug("Query an individual VNF package> %s" % request.data) data = VnfPackage().query_single(vnf_pkg_id) - vnf_pkg_info = validate_data(data, VnfPkgInfoSerializer) - return Response(data=vnf_pkg_info.data, status=status.HTTP_200_OK) + validate_data(data, VnfPkgInfoSerializer) + return Response(data=data, status=status.HTTP_200_OK) if request.method == 'DELETE': logger.debug("Delete an individual VNF package> %s" % request.data) diff --git a/genericparser/pub/__init__.py b/catalog/pub/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/pub/__init__.py +++ b/catalog/pub/__init__.py diff --git a/genericparser/pub/config/__init__.py b/catalog/pub/config/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/pub/config/__init__.py +++ b/catalog/pub/config/__init__.py diff --git a/genericparser/pub/config/config.py b/catalog/pub/config/config.py index 24f4fca..b8a5141 100644 --- a/genericparser/pub/config/config.py +++ b/catalog/pub/config/config.py @@ -24,12 +24,12 @@ REDIS_PASSWD = '' # [mysql] DB_IP = "127.0.0.1" DB_PORT = 3306 -DB_NAME = "genericparser" -DB_USER = "genericparser" -DB_PASSWD = "genericparser" +DB_NAME = "nfvocatalog" +DB_USER = "nfvocatalog" +DB_PASSWD = "nfvocatalog" # [MDC] -SERVICE_NAME = "genericparser" +SERVICE_NAME = "catalog" FORWARDED_FOR_FIELDS = ["HTTP_X_FORWARDED_FOR", "HTTP_X_FORWARDED_HOST", "HTTP_X_FORWARDED_SERVER"] @@ -37,9 +37,9 @@ FORWARDED_FOR_FIELDS = ["HTTP_X_FORWARDED_FOR", "HTTP_X_FORWARDED_HOST", REG_TO_MSB_WHEN_START = True REG_TO_MSB_REG_URL = "/api/microservices/v1/services" REG_TO_MSB_REG_PARAM = [{ - "serviceName": "parser", + "serviceName": "catalog", "version": "v1", - "url": "/api/parser/v1", + "url": "/api/catalog/v1", "protocol": "REST", "visualRange": "1", "nodes": [{ @@ -70,12 +70,13 @@ REG_TO_MSB_REG_PARAM = [{ "ttl": 0 }] }] +MSB_SVC_CALALOG_URL = "/api/microservices/v1/services/catalog/version/v1" +MSB_SVC_NSD_URL = "/api/microservices/v1/services/nsd/version/v1" +MSB_SVC_VNFPKGM_URL = "/api/microservices/v1/services/vnfpkgm/version/v1" -# genericparser path(values is defined in settings.py) -# CATALOG_ROOT_PATH = None -# CATALOG_URL_PATH = None -GENERICPARSER_ROOT_PATH = None -GENERICPARSER_URL_PATH = None +# catalog path(values is defined in settings.py) +CATALOG_ROOT_PATH = None +CATALOG_URL_PATH = None # [sdc config] SDC_BASE_URL = "http://msb-iag/api" diff --git a/genericparser/pub/database/__init__.py b/catalog/pub/database/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/pub/database/__init__.py +++ b/catalog/pub/database/__init__.py diff --git a/genericparser/pub/database/admin.py b/catalog/pub/database/admin.py index ec7a92a..bff70cb 100644 --- a/genericparser/pub/database/admin.py +++ b/catalog/pub/database/admin.py @@ -14,15 +14,15 @@ from django.contrib import admin -from genericparser.pub.database.models import NSPackageModel -from genericparser.pub.database.models import ServicePackageModel -from genericparser.pub.database.models import VnfPackageModel -from genericparser.pub.database.models import PnfPackageModel -from genericparser.pub.database.models import SoftwareImageModel -from genericparser.pub.database.models import JobModel -from genericparser.pub.database.models import JobStatusModel -from genericparser.pub.database.models import NsdmSubscriptionModel -from genericparser.pub.database.models import VnfPkgSubscriptionModel +from catalog.pub.database.models import NSPackageModel +from catalog.pub.database.models import ServicePackageModel +from catalog.pub.database.models import VnfPackageModel +from catalog.pub.database.models import PnfPackageModel +from catalog.pub.database.models import SoftwareImageModel +from catalog.pub.database.models import JobModel +from catalog.pub.database.models import JobStatusModel +from catalog.pub.database.models import NsdmSubscriptionModel +from catalog.pub.database.models import VnfPkgSubscriptionModel @admin.register(NSPackageModel) diff --git a/genericparser/pub/database/migrations/0001_initial.py b/catalog/pub/database/migrations/0001_initial.py index 98ca84c..98ca84c 100644 --- a/genericparser/pub/database/migrations/0001_initial.py +++ b/catalog/pub/database/migrations/0001_initial.py diff --git a/genericparser/pub/database/migrations/__init__.py b/catalog/pub/database/migrations/__init__.py index 0c847b7..0c847b7 100644 --- a/genericparser/pub/database/migrations/__init__.py +++ b/catalog/pub/database/migrations/__init__.py diff --git a/genericparser/pub/database/models.py b/catalog/pub/database/models.py index ffbd6d0..9f0b498 100644 --- a/genericparser/pub/database/models.py +++ b/catalog/pub/database/models.py @@ -35,7 +35,7 @@ class NSPackageModel(models.Model): nsdModel = models.TextField(db_column='NSDMODEL', max_length=65535, null=True, blank=True) class Meta: - db_table = 'GENERICPARSER_NSPACKAGE' + db_table = 'CATALOG_NSPACKAGE' class ServicePackageModel(models.Model): @@ -58,7 +58,7 @@ class ServicePackageModel(models.Model): servicedModel = models.TextField(db_column='SERVICEDMODEL', max_length=65535, null=True, blank=True) class Meta: - db_table = 'GENERICPARSER_SERVICEPACKAGE' + db_table = 'CATALOG_SERVICEPACKAGE' class VnfPackageModel(models.Model): @@ -81,7 +81,7 @@ class VnfPackageModel(models.Model): vnfdModel = models.TextField(db_column='VNFDMODEL', max_length=65535, blank=True, null=True) # vnfd class Meta: - db_table = 'GENERICPARSER_VNFPACKAGE' + db_table = 'CATALOG_VNFPACKAGE' class PnfPackageModel(models.Model): @@ -104,7 +104,7 @@ class PnfPackageModel(models.Model): pnfdName = models.TextField(db_column='PNFDNAME', max_length=65535, blank=True, null=True) # pnfd_name class Meta: - db_table = 'GENERICPARSER_PNFPACKAGE' + db_table = 'CATALOG_PNFPACKAGE' class SoftwareImageModel(models.Model): @@ -124,7 +124,7 @@ class SoftwareImageModel(models.Model): # purpose = models.CharField(db_column='PURPOSE', max_length=1000) class Meta: - db_table = 'GENERICPARSER_SOFTWAREIMAGEMODEL' + db_table = 'CATALOG_SOFTWAREIMAGEMODEL' class JobModel(models.Model): @@ -141,7 +141,7 @@ class JobModel(models.Model): resname = models.CharField(db_column='RESNAME', max_length=255, null=True, blank=True) class Meta: - db_table = 'GENERICPARSER_JOB' + db_table = 'CATALOG_JOB' def toJSON(self): import json @@ -158,7 +158,7 @@ class JobStatusModel(models.Model): addtime = models.CharField(db_column='ADDTIME', max_length=255, null=True, blank=True) class Meta: - db_table = 'GENERICPARSER_JOB_STATUS' + db_table = 'CATALOG_JOB_STATUS' def toJSON(self): import json @@ -192,7 +192,7 @@ class NsdmSubscriptionModel(models.Model): links = models.TextField(db_column='LINKS') class Meta: - db_table = 'GENERICPARSER_NSDM_SUBSCRIPTION' + db_table = 'CATALOG_NSDM_SUBSCRIPTION' def toJSON(self): import json diff --git a/genericparser/pub/exceptions.py b/catalog/pub/exceptions.py index b3c797d..e0dac0e 100644 --- a/genericparser/pub/exceptions.py +++ b/catalog/pub/exceptions.py @@ -13,45 +13,45 @@ # limitations under the License. -class GenericparserException(Exception): +class CatalogException(Exception): pass -class ResourceNotFoundException(GenericparserException): +class BadRequestException(CatalogException): pass -class PackageNotFoundException(GenericparserException): +class ResourceNotFoundException(CatalogException): pass -class PackageHasExistsException(GenericparserException): +class PackageNotFoundException(CatalogException): pass -class VnfPkgSubscriptionException(GenericparserException): +class PackageHasExistsException(CatalogException): pass -class VnfPkgDuplicateSubscriptionException(GenericparserException): +class VnfPkgSubscriptionException(CatalogException): pass -class SubscriptionDoesNotExistsException(GenericparserException): +class VnfPkgDuplicateSubscriptionException(CatalogException): pass -class NsdmBadRequestException(GenericparserException): +class SubscriptionDoesNotExistsException(CatalogException): pass -class NsdmDuplicateSubscriptionException(GenericparserException): +class NsdmBadRequestException(CatalogException): pass -class BadRequestException(GenericparserException): +class NsdmDuplicateSubscriptionException(CatalogException): pass -class ArtifactNotFoundException(GenericparserException): +class ArtifactNotFoundException(CatalogException): pass diff --git a/genericparser/pub/msapi/__init__.py b/catalog/pub/msapi/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/pub/msapi/__init__.py +++ b/catalog/pub/msapi/__init__.py diff --git a/genericparser/pub/msapi/extsys.py b/catalog/pub/msapi/extsys.py index 639513f..e038f26 100644 --- a/genericparser/pub/msapi/extsys.py +++ b/catalog/pub/msapi/extsys.py @@ -16,17 +16,17 @@ import json import logging import uuid -from genericparser.pub.config.config import AAI_BASE_URL, AAI_USER, AAI_PASSWD -from genericparser.pub.exceptions import GenericparserException -from genericparser.pub.utils import restcall -from genericparser.pub.utils.values import ignore_case_get +from catalog.pub.config.config import AAI_BASE_URL, AAI_USER, AAI_PASSWD +from catalog.pub.exceptions import CatalogException +from catalog.pub.utils import restcall +from catalog.pub.utils.values import ignore_case_get logger = logging.getLogger(__name__) def call_aai(resource, method, content=''): additional_headers = { - 'X-FromAppId': 'MODEL-GENERICPARSER', + 'X-FromAppId': 'VFC-CATALOG', 'X-TransactionId': str(uuid.uuid1()) } return restcall.call_req(AAI_BASE_URL, @@ -43,7 +43,7 @@ def get_vims(): ret = call_aai("/cloud-infrastructure/cloud-regions?depth=all", "GET") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise GenericparserException("Failed to query vims from extsys.") + raise CatalogException("Failed to query vims from extsys.") # convert vim_info_aai to internal vim_info vims_aai = json.JSONDecoder().decode(ret[1]) vims_aai = ignore_case_get(vims_aai, "cloud-region") @@ -60,7 +60,7 @@ def get_vim_by_id(vim_id): % (cloud_owner, cloud_region), "GET") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise GenericparserException("Failed to query vim(%s) from extsys." % vim_id) + raise CatalogException("Failed to query vim(%s) from extsys." % vim_id) # convert vim_info_aai to internal vim_info vim_info_aai = json.JSONDecoder().decode(ret[1]) vim_info = convert_vim_info(vim_info_aai) @@ -99,7 +99,7 @@ def get_sdn_controller_by_id(sdn_ontroller_id): % sdn_ontroller_id, "GET") if ret[0] != 0: logger.error("Failed to query sdn ontroller(%s) from extsys. detail is %s.", sdn_ontroller_id, ret[1]) - raise GenericparserException("Failed to query sdn ontroller(%s) from extsys." % sdn_ontroller_id) + raise CatalogException("Failed to query sdn ontroller(%s) from extsys." % sdn_ontroller_id) # convert vim_info_aai to internal vim_info sdnc_info_aai = json.JSONDecoder().decode(ret[1]) sdnc_info = convert_sdnc_info(sdnc_info_aai) @@ -130,7 +130,7 @@ def get_vnfm_by_id(vnfm_inst_id): ret = call_aai(uri, "GET") if ret[0] > 0: logger.error('Send get VNFM information request to extsys failed.') - raise GenericparserException('Send get VNFM information request to extsys failed.') + raise CatalogException('Send get VNFM information request to extsys failed.') # convert vnfm_info_aai to internal vnfm_info vnfm_info_aai = json.JSONDecoder().decode(ret[1]) vnfm_info = convert_vnfm_info(vnfm_info_aai) @@ -161,7 +161,7 @@ def select_vnfm(vnfm_type, vim_id): ret = call_aai(uri, "GET") if ret[0] > 0: logger.error("Failed to call %s: %s", uri, ret[1]) - raise GenericparserException('Failed to get vnfms from extsys.') + raise CatalogException('Failed to get vnfms from extsys.') vnfms = json.JSONDecoder().decode(ret[1]) vnfms = ignore_case_get(vnfms, "esr-vnfm") for vnfm in vnfms: @@ -172,4 +172,4 @@ def select_vnfm(vnfm_type, vim_id): # convert vnfm_info_aai to internal vnfm_info vnfm = convert_vnfm_info(vnfm) return vnfm - raise GenericparserException('No vnfm found with %s in vim(%s)' % (vnfm_type, vim_id)) + raise CatalogException('No vnfm found with %s in vim(%s)' % (vnfm_type, vim_id)) diff --git a/genericparser/pub/msapi/sdc.py b/catalog/pub/msapi/sdc.py index 81715de..bb473cc 100644 --- a/genericparser/pub/msapi/sdc.py +++ b/catalog/pub/msapi/sdc.py @@ -16,10 +16,10 @@ import json import logging import os -from genericparser.pub.config.config import SDC_BASE_URL, SDC_USER, SDC_PASSWD -from genericparser.pub.exceptions import GenericparserException -from genericparser.pub.utils import fileutil -from genericparser.pub.utils import restcall +from catalog.pub.config.config import SDC_BASE_URL, SDC_USER, SDC_PASSWD +from catalog.pub.exceptions import CatalogException +from catalog.pub.utils import fileutil +from catalog.pub.utils import restcall logger = logging.getLogger(__name__) @@ -30,7 +30,7 @@ DISTRIBUTED = "DISTRIBUTED" def call_sdc(resource, method, content=''): additional_headers = { - 'X-ECOMP-InstanceID': 'Modeling', + 'X-ECOMP-InstanceID': 'VFC', } return restcall.call_req(base_url=SDC_BASE_URL, user=SDC_USER, @@ -67,7 +67,7 @@ def get_artifacts(asset_type): ret = call_sdc(resource, "GET") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise GenericparserException("Failed to query artifacts(%s) from sdc." % asset_type) + raise CatalogException("Failed to query artifacts(%s) from sdc." % asset_type) return json.JSONDecoder().decode(ret[1]) @@ -77,11 +77,10 @@ def get_artifact(asset_type, csar_id): if artifact["uuid"] == csar_id: if asset_type == ASSETTYPE_SERVICES and \ artifact.get("distributionStatus", None) != DISTRIBUTED: - raise GenericparserException( - "The artifact (%s,%s) is not distributed from sdc." % (asset_type, csar_id)) + raise CatalogException("The artifact (%s,%s) is not distributed from sdc." % (asset_type, csar_id)) else: return artifact - raise GenericparserException("Failed to query artifact(%s,%s) from sdc." % (asset_type, csar_id)) + raise CatalogException("Failed to query artifact(%s,%s) from sdc." % (asset_type, csar_id)) def get_asset(asset_type, uuid): @@ -89,10 +88,10 @@ def get_asset(asset_type, uuid): ret = call_sdc(resource, "GET") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise GenericparserException("Failed to get asset(%s, %s) from sdc." % (asset_type, uuid)) + raise CatalogException("Failed to get asset(%s, %s) from sdc." % (asset_type, uuid)) asset = json.JSONDecoder().decode(ret[1]) if asset.get("distributionStatus", None) != DISTRIBUTED: - raise GenericparserException("The asset (%s,%s) is not distributed from sdc." % (asset_type, uuid)) + raise CatalogException("The asset (%s,%s) is not distributed from sdc." % (asset_type, uuid)) else: return asset @@ -103,13 +102,13 @@ def delete_artifact(asset_type, asset_id, artifact_id): ret = call_sdc(resource, "DELETE") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise GenericparserException("Failed to delete artifacts(%s) from sdc." % 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': 'Modeling', + 'X-ECOMP-InstanceID': 'VFC', 'accept': 'application/octet-stream' } ret = restcall.call_req(base_url=SDC_BASE_URL, @@ -121,7 +120,7 @@ def download_artifacts(download_url, local_path, file_name): additional_headers=additional_headers) if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise GenericparserException("Failed to download %s from sdc." % download_url) + raise CatalogException("Failed to download %s from sdc." % download_url) fileutil.make_dirs(local_path) local_file_name = os.path.join(local_path, file_name) local_file = open(local_file_name, 'wb') diff --git a/genericparser/pub/redisco/__init__.py b/catalog/pub/redisco/__init__.py index 217a232..217a232 100644 --- a/genericparser/pub/redisco/__init__.py +++ b/catalog/pub/redisco/__init__.py diff --git a/genericparser/pub/redisco/containers.py b/catalog/pub/redisco/containers.py index d30c227..d30c227 100644 --- a/genericparser/pub/redisco/containers.py +++ b/catalog/pub/redisco/containers.py diff --git a/genericparser/pub/ssl/cert/foobar.crt b/catalog/pub/ssl/cert/foobar.crt index 7ab6dd3..7ab6dd3 100644 --- a/genericparser/pub/ssl/cert/foobar.crt +++ b/catalog/pub/ssl/cert/foobar.crt diff --git a/genericparser/pub/ssl/cert/foobar.csr b/catalog/pub/ssl/cert/foobar.csr index 30b381b..30b381b 100644 --- a/genericparser/pub/ssl/cert/foobar.csr +++ b/catalog/pub/ssl/cert/foobar.csr diff --git a/genericparser/pub/ssl/cert/foobar.key b/catalog/pub/ssl/cert/foobar.key index 266f502..266f502 100644 --- a/genericparser/pub/ssl/cert/foobar.key +++ b/catalog/pub/ssl/cert/foobar.key diff --git a/genericparser/pub/utils/__init__.py b/catalog/pub/utils/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/pub/utils/__init__.py +++ b/catalog/pub/utils/__init__.py diff --git a/genericparser/pub/utils/fileutil.py b/catalog/pub/utils/fileutil.py index 6ddfc72..6ddfc72 100644 --- a/genericparser/pub/utils/fileutil.py +++ b/catalog/pub/utils/fileutil.py diff --git a/genericparser/pub/utils/idutil.py b/catalog/pub/utils/idutil.py index 768416c..c2347c1 100644 --- a/genericparser/pub/utils/idutil.py +++ b/catalog/pub/utils/idutil.py @@ -11,7 +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 genericparser.pub.redisco import containers as cont +from catalog.pub.redisco import containers as cont def get_auto_id(id_type, id_group="auto_id_hash"): diff --git a/genericparser/pub/utils/jobutil.py b/catalog/pub/utils/jobutil.py index abe5227..3d79c7a 100644 --- a/genericparser/pub/utils/jobutil.py +++ b/catalog/pub/utils/jobutil.py @@ -17,8 +17,8 @@ import uuid import traceback from functools import reduce -from genericparser.pub.database.models import JobStatusModel, JobModel -from genericparser.pub.utils import idutil +from catalog.pub.database.models import JobStatusModel, JobModel +from catalog.pub.utils import idutil logger = logging.getLogger(__name__) diff --git a/genericparser/pub/utils/restcall.py b/catalog/pub/utils/restcall.py index 5efa0cb..8f03259 100644 --- a/genericparser/pub/utils/restcall.py +++ b/catalog/pub/utils/restcall.py @@ -20,7 +20,7 @@ import uuid import httplib2 import base64 -from genericparser.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT +from catalog.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2 HTTP_200_OK, HTTP_201_CREATED, HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED = '200', '201', '204', '202' diff --git a/genericparser/pub/utils/syscomm.py b/catalog/pub/utils/syscomm.py index 89219ec..89219ec 100644 --- a/genericparser/pub/utils/syscomm.py +++ b/catalog/pub/utils/syscomm.py diff --git a/genericparser/pub/utils/tests.py b/catalog/pub/utils/tests.py index 8390ce7..0f02467 100644 --- a/genericparser/pub/utils/tests.py +++ b/catalog/pub/utils/tests.py @@ -21,8 +21,8 @@ from . import syscomm from . import timeutil from . import values -from genericparser.pub.database.models import JobStatusModel, JobModel -from genericparser.pub.utils.jobutil import JobUtil +from catalog.pub.database.models import JobStatusModel, JobModel +from catalog.pub.utils.jobutil import JobUtil class MockReq(): diff --git a/genericparser/pub/utils/timeutil.py b/catalog/pub/utils/timeutil.py index 1d97e9d..1d97e9d 100644 --- a/genericparser/pub/utils/timeutil.py +++ b/catalog/pub/utils/timeutil.py diff --git a/genericparser/pub/utils/toscaparsers/__init__.py b/catalog/pub/utils/toscaparser/__init__.py index 4b73f48..62ead96 100644 --- a/genericparser/pub/utils/toscaparsers/__init__.py +++ b/catalog/pub/utils/toscaparser/__init__.py @@ -14,10 +14,10 @@ import json -from genericparser.pub.utils.toscaparsers.nsdmodel import NsdInfoModel -from genericparser.pub.utils.toscaparsers.pnfmodel import PnfdInfoModel -from genericparser.pub.utils.toscaparsers.sdmodel import SdInfoModel -from genericparser.pub.utils.toscaparsers.vnfdmodel import EtsiVnfdInfoModel +from catalog.pub.utils.toscaparser.nsdmodel import NsdInfoModel +from catalog.pub.utils.toscaparser.pnfmodel import PnfdInfoModel +from catalog.pub.utils.toscaparser.sdmodel import SdInfoModel +from catalog.pub.utils.toscaparser.vnfdmodel import EtsiVnfdInfoModel def parse_nsd(path, input_parameters=[]): diff --git a/genericparser/pub/utils/toscaparsers/basemodel.py b/catalog/pub/utils/toscaparser/basemodel.py index 643041d..6ed26aa 100644 --- a/genericparser/pub/utils/toscaparsers/basemodel.py +++ b/catalog/pub/utils/toscaparser/basemodel.py @@ -24,9 +24,9 @@ import urllib from toscaparser.tosca_template import ToscaTemplate from toscaparser.properties import Property from toscaparser.functions import Function, Concat, GetInput, get_function, function_mappings -from genericparser.pub.utils.toscaparsers.graph import Graph +from catalog.pub.utils.toscaparser.graph import Graph -from genericparser.pub.utils.toscaparsers.dataentityext import DataEntityExt +from catalog.pub.utils.toscaparser.dataentityext import DataEntityExt logger = logging.getLogger(__name__) @@ -517,15 +517,6 @@ class BaseInfoModel(object): if substitution_mappings: nodeType = substitution_mappings['node_type'] logger.debug("nodeType %s", nodeType) - if "node_types" in tosca.tpl: - node_types = tosca.tpl['node_types'].get(nodeType, None) - derivedFrom = node_types.get('derived_from', "") - node['type'] = derivedFrom - node['properties'] = node_types.get('properties', {}) - node['requirements'] = node_types.get('requirements', {}) - node['capabilities'] = node_types.get('capabilities', {}) - metadata = node_types.get('metadata', {}) - if "type" not in node or node['type'] == "": node['type'] = nodeType node['properties'] = substitution_mappings.get('properties', {}) @@ -533,5 +524,11 @@ class BaseInfoModel(object): node['capabilities'] = substitution_mappings.get('capabilities', {}) metadata = substitution_mappings.get('metadata', {}) + if "node_types" in tosca.tpl: + node_types = tosca.tpl['node_types'].get(nodeType, None) + derivedFrom = node_types.get('derived_from', "") + node['type'] = derivedFrom + node['properties'] = node_types.get('properties', {}) + node['metadata'] = metadata if metadata and metadata != {} else self.buildMetadata(tosca) return node diff --git a/genericparser/pub/utils/toscaparsers/const.py b/catalog/pub/utils/toscaparser/const.py index 9c61c48..9c61c48 100644 --- a/genericparser/pub/utils/toscaparsers/const.py +++ b/catalog/pub/utils/toscaparser/const.py diff --git a/genericparser/pub/utils/toscaparsers/dataentityext.py b/catalog/pub/utils/toscaparser/dataentityext.py index 825e93b..825e93b 100644 --- a/genericparser/pub/utils/toscaparsers/dataentityext.py +++ b/catalog/pub/utils/toscaparser/dataentityext.py diff --git a/genericparser/pub/utils/toscaparsers/graph.py b/catalog/pub/utils/toscaparser/graph.py index 0af2a14..0af2a14 100644 --- a/genericparser/pub/utils/toscaparsers/graph.py +++ b/catalog/pub/utils/toscaparser/graph.py diff --git a/genericparser/pub/utils/toscaparsers/nsdmodel.py b/catalog/pub/utils/toscaparser/nsdmodel.py index 9cc706f..f742640 100644 --- a/genericparser/pub/utils/toscaparsers/nsdmodel.py +++ b/catalog/pub/utils/toscaparser/nsdmodel.py @@ -14,9 +14,9 @@ import functools import logging -from genericparser.pub.utils.toscaparsers.basemodel import BaseInfoModel -from genericparser.pub.utils.toscaparsers.const import SDC_SERVICE_METADATA_SECTIONS -from genericparser.pub.utils.toscaparsers.servicemodel import SdcServiceModel +from catalog.pub.utils.toscaparser.basemodel import BaseInfoModel +from catalog.pub.utils.toscaparser.const import SDC_SERVICE_METADATA_SECTIONS +from catalog.pub.utils.toscaparser.servicemodel import SdcServiceModel logger = logging.getLogger(__name__) diff --git a/genericparser/pub/utils/toscaparsers/pnfmodel.py b/catalog/pub/utils/toscaparser/pnfmodel.py index 546861b..9ad8686 100644 --- a/genericparser/pub/utils/toscaparsers/pnfmodel.py +++ b/catalog/pub/utils/toscaparser/pnfmodel.py @@ -14,7 +14,7 @@ import functools import logging -from genericparser.pub.utils.toscaparsers.basemodel import BaseInfoModel +from catalog.pub.utils.toscaparser.basemodel import BaseInfoModel logger = logging.getLogger(__name__) diff --git a/genericparser/pub/utils/toscaparsers/sdmodel.py b/catalog/pub/utils/toscaparser/sdmodel.py index 7635ab3..05e0caf 100644 --- a/genericparser/pub/utils/toscaparsers/sdmodel.py +++ b/catalog/pub/utils/toscaparser/sdmodel.py @@ -13,8 +13,8 @@ # limitations under the License. import logging -from genericparser.pub.utils.toscaparsers.basemodel import BaseInfoModel -from genericparser.pub.utils.toscaparsers.servicemodel import SdcServiceModel +from catalog.pub.utils.toscaparser.basemodel import BaseInfoModel +from catalog.pub.utils.toscaparser.servicemodel import SdcServiceModel logger = logging.getLogger(__name__) diff --git a/genericparser/pub/utils/toscaparsers/servicemodel.py b/catalog/pub/utils/toscaparser/servicemodel.py index 6321e04..47d6630 100644 --- a/genericparser/pub/utils/toscaparsers/servicemodel.py +++ b/catalog/pub/utils/toscaparser/servicemodel.py @@ -14,8 +14,8 @@ import functools import logging -from genericparser.pub.utils.toscaparsers.const import NS_METADATA_SECTIONS, PNF_METADATA_SECTIONS, VNF_SECTIONS, PNF_SECTIONS, VL_SECTIONS -from genericparser.pub.utils.toscaparsers.basemodel import BaseInfoModel +from catalog.pub.utils.toscaparser.const import NS_METADATA_SECTIONS, PNF_METADATA_SECTIONS, VNF_SECTIONS, PNF_SECTIONS, VL_SECTIONS +from catalog.pub.utils.toscaparser.basemodel import BaseInfoModel logger = logging.getLogger(__name__) diff --git a/genericparser/pub/utils/toscaparsers/testdata/ns/ran.csar b/catalog/pub/utils/toscaparser/testdata/ns/ran.csar Binary files differindex 9ea868c..9ea868c 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/ns/ran.csar +++ b/catalog/pub/utils/toscaparser/testdata/ns/ran.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/ns/service-vIMS.csar b/catalog/pub/utils/toscaparser/testdata/ns/service-vIMS.csar Binary files differindex 0aeed58..0aeed58 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/ns/service-vIMS.csar +++ b/catalog/pub/utils/toscaparser/testdata/ns/service-vIMS.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/pnf/ran-du.csar b/catalog/pub/utils/toscaparser/testdata/pnf/ran-du.csar Binary files differindex 45168a9..45168a9 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/pnf/ran-du.csar +++ b/catalog/pub/utils/toscaparser/testdata/pnf/ran-du.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vSBC.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vSBC.csar Binary files differindex 921eafd..921eafd 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vSBC.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vSBC.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/infra.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/infra.csar Binary files differindex 5c9fbcf..5c9fbcf 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/infra.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/infra.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vbng.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbng.csar Binary files differindex b11a6ef..b11a6ef 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vbng.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbng.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vbrgemu.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbrgemu.csar Binary files differindex 730ea8d..730ea8d 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vbrgemu.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vbrgemu.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vgmux.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgmux.csar Binary files differindex b0f37a7..b0f37a7 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vgmux.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgmux.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vgw.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgw.csar Binary files differindex ca652bf..ca652bf 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpedpdk/vgw.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpedpdk/vgw.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/infra.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/infra.csar Binary files differindex c91c034..c91c034 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/infra.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/infra.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vbng.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbng.csar Binary files differindex 5011563..5011563 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vbng.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbng.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vbrgemu.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbrgemu.csar Binary files differindex 0f99199..0f99199 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vbrgemu.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vbrgemu.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vgmux.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgmux.csar Binary files differindex 3d2dbf7..3d2dbf7 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vgmux.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgmux.csar diff --git a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vgw.csar b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar Binary files differindex 79e0d20..79e0d20 100644 --- a/genericparser/pub/utils/toscaparsers/testdata/vnf/vcpesriov/vgw.csar +++ b/catalog/pub/utils/toscaparser/testdata/vnf/vcpesriov/vgw.csar diff --git a/genericparser/pub/utils/toscaparsers/tests.py b/catalog/pub/utils/toscaparser/tests.py index e28f712..285d970 100644 --- a/genericparser/pub/utils/toscaparsers/tests.py +++ b/catalog/pub/utils/toscaparser/tests.py @@ -19,8 +19,8 @@ import shutil from django.test import TestCase -from genericparser.pub.utils.toscaparsers import parse_vnfd, parse_pnfd, parse_nsd -from genericparser.pub.utils.toscaparsers.graph import Graph +from catalog.pub.utils.toscaparser import parse_vnfd, parse_pnfd, parse_nsd +from catalog.pub.utils.toscaparser.graph import Graph logger = logging.getLogger(__name__) @@ -45,8 +45,7 @@ class TestToscaparser(TestCase): logger.debug("sriov metadata:%s", metadata) self.assertEqual(("vCPE_%s" % vcpe_part), metadata.get("template_name", "")) if vcpe_part == "infra": - self.assertEqual("b1bb0ce7-1111-4fa7-95ed-4840d70a1177", - json.loads(vnfd_json)["vnf"]["properties"]["descriptor_id"]) + self.assertEqual("b1bb0ce7-1111-4fa7-95ed-4840d70a1177", json.loads(vnfd_json)["vnf"]["properties"]["descriptor_id"]) dpdk_path = os.path.dirname(os.path.abspath(__file__)) + "/testdata/vnf/vcpedpdk" csar_file = ("%s/%s.csar" % (dpdk_path, vcpe_part)) diff --git a/genericparser/pub/utils/toscaparsers/vnfdmodel.py b/catalog/pub/utils/toscaparser/vnfdmodel.py index 2e48b4d..1ed0659 100644 --- a/genericparser/pub/utils/toscaparsers/vnfdmodel.py +++ b/catalog/pub/utils/toscaparser/vnfdmodel.py @@ -14,9 +14,9 @@ import functools import logging -from genericparser.pub.config.config import VNFD_SCHEMA_VERSION_DEFAULT -from genericparser.pub.utils.toscaparsers.basemodel import BaseInfoModel -from genericparser.pub.utils.toscaparsers.vnfdparser import CreateVnfdSOLParser +from catalog.pub.config.config import VNFD_SCHEMA_VERSION_DEFAULT +from catalog.pub.utils.toscaparser.basemodel import BaseInfoModel +from catalog.pub.utils.toscaparser.vnfdparser import CreateVnfdSOLParser logger = logging.getLogger(__name__) diff --git a/genericparser/pub/utils/toscaparsers/vnfdparser/__init__.py b/catalog/pub/utils/toscaparser/vnfdparser/__init__.py index 179fb4c..911de2c 100644 --- a/genericparser/pub/utils/toscaparsers/vnfdparser/__init__.py +++ b/catalog/pub/utils/toscaparser/vnfdparser/__init__.py @@ -11,9 +11,8 @@ # 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 genericparser.pub.utils.toscaparsers.vnfdparser.vnfd_sol_base import VnfdSOLBase -from genericparser.pub.utils.toscaparsers.vnfdparser.vnfd_sol_251 import VnfdSOL251 +from catalog.pub.utils.toscaparser.vnfdparser.vnfd_sol_base import VnfdSOLBase +from catalog.pub.utils.toscaparser.vnfdparser.vnfd_sol_251 import VnfdSOL251 def CreateVnfdSOLParser(sol_version, etsi_vnfd_model): diff --git a/genericparser/pub/utils/toscaparsers/vnfdparser/vnfd_sol_251.py b/catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_251.py index e71623a..d1b0d14 100644 --- a/genericparser/pub/utils/toscaparsers/vnfdparser/vnfd_sol_251.py +++ b/catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_251.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import functools import logging import os import base64 @@ -90,6 +89,23 @@ class VnfdSOL251(): vl['vl_id'] = node['name'] vl['description'] = node['description'] vl['properties'] = node['properties'] + vlp = vl['properties'] + nodep = node['properties'] + vlp['connectivity_type']['layer_protocol'] = nodep['connectivity_type']['layer_protocols'][0] + vlp['vl_profile']['max_bit_rate_requirements'] = nodep['vl_profile']['max_bitrate_requirements'] + vlp['vl_profile']['min_bit_rate_requirements'] = nodep['vl_profile']['min_bitrate_requirements'] + if 'virtual_link_protocol_data' in nodep['vl_profile']: + protocol_data = nodep['vl_profile']['virtual_link_protocol_data'][0] + vlp['vl_profile']['associated_layer_protocol'] = protocol_data['associated_layer_protocol'] + if 'l3_protocol_data' in protocol_data: + l3 = protocol_data['l3_protocol_data'] + vlp['vl_profile']['networkName'] = l3.get("name", "") + vlp['vl_profile']['cidr'] = l3.get("cidr", "") + vlp['vl_profile']['dhcpEnabled'] = l3.get("dhcp_enabled", "") + vlp['vl_profile']['ip_version'] = l3.get("ip_version", "") + if 'l2_protocol_data' in protocol_data: + l2 = protocol_data['l2_protocol_data'] + vlp['vl_profile']['physicalNetwork'] = l2.get("physical_network", "") vls.append(vl) return vls @@ -101,7 +117,22 @@ class VnfdSOL251(): cp['cp_id'] = node['name'] cp['cpd_id'] = node['name'] cp['description'] = node['description'] - cp['properties'] = node['properties'] + cp['properties'] = {} + nodep = node['properties'] + cp['properties']['trunk_mode'] = nodep.get("trunk_mode", "") + cp['properties']['layer_protocol'] = nodep.get("layer_protocols", "") + if 'vnic_type' in nodep: + cp['properties']['vnic_type'] = nodep.get("vnic_type", "normal") + if 'virtual_network_interface_requirements' in nodep: + cp['properties']['virtual_network_interface_requirements'] = nodep.get("virtual_network_interface_requirements", "") + if "protocol" in nodep: + node_protocol = nodep['protocol'][0] + cp['properties']['protocol_data'] = nodep['protocol'] + cp_protocol = cp['properties']['protocol_data'][0] + cp_protocol['asscociated_layer_protocol'] = node_protocol['associated_layer_protocol'] + if "address_data" in node_protocol: + cp_protocol['address_data'] = node_protocol['address_data'][0] + cp['vl_id'] = self._get_node_vl_id(node) cp['vdu_id'] = self._get_node_vdu_id(node) vls = self._buil_cp_vls(node) @@ -134,6 +165,9 @@ class VnfdSOL251(): if 'description' in node: ret['description'] = node['description'] ret['properties'] = node['properties'] + if 'boot_data' in node['properties']: + ret['properties']['user_data'] = node['properties']['boot_data'] + del ret['properties']['boot_data'] if 'inject_files' in node['properties']: inject_files = node['properties']['inject_files'] if inject_files is not None: @@ -150,12 +184,14 @@ class VnfdSOL251(): source_data = f.read() source_data_base64 = base64.b64encode(source_data) inject_files["source_data_base64"] = source_data_base64.decode() - virtual_storages = self.model.getRequirementByName(node, 'virtual_storage') - ret['virtual_storages'] = list(map(functools.partial(self._trans_virtual_storage), virtual_storages)) ret['dependencies'] = [self.model.get_requirement_node_name(x) for x in self.model.getNodeDependencys(node)] virtual_compute = self.model.getCapabilityByName(node, 'virtual_compute') if virtual_compute is not None and 'properties' in virtual_compute: - ret['virtual_compute'] = virtual_compute['properties'] + vc = {} + vc['virtual_cpu'] = virtual_compute['properties']['virtual_cpu'] + vc['virtual_memory'] = virtual_compute['properties']['virtual_memory'] + vc['virtual_storages'] = virtual_compute['properties'].get("virtual_local_storage", {}) + ret['virtual_compute'] = vc ret['vls'] = self._get_linked_vl_ids(node, nodeTemplates) ret['cps'] = self._get_virtal_binding_cp_ids(node, nodeTemplates) ret['artifacts'] = self.model.build_artifacts(node) diff --git a/genericparser/pub/utils/toscaparsers/vnfdparser/vnfd_sol_base.py b/catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_base.py index 7b3a1a0..7b3a1a0 100644 --- a/genericparser/pub/utils/toscaparsers/vnfdparser/vnfd_sol_base.py +++ b/catalog/pub/utils/toscaparser/vnfdparser/vnfd_sol_base.py diff --git a/genericparser/pub/utils/values.py b/catalog/pub/utils/values.py index d02d544..d02d544 100644 --- a/genericparser/pub/utils/values.py +++ b/catalog/pub/utils/values.py diff --git a/genericparser/samples/__init__.py b/catalog/samples/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/samples/__init__.py +++ b/catalog/samples/__init__.py diff --git a/genericparser/samples/tests.py b/catalog/samples/tests.py index 53d7a10..2be964a 100644 --- a/genericparser/samples/tests.py +++ b/catalog/samples/tests.py @@ -41,5 +41,5 @@ class CallbackSampleTest(unittest.TestCase): pass def test_callback(self): - response = self.client.get("/api/parser/v1/callback_sample") + response = self.client.get("/api/catalog/v1/callback_sample") self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code, response.content) diff --git a/genericparser/samples/urls.py b/catalog/samples/urls.py index 853a124..8e3483c 100644 --- a/genericparser/samples/urls.py +++ b/catalog/samples/urls.py @@ -13,10 +13,10 @@ # limitations under the License. from django.conf.urls import url -from genericparser.samples import views +from catalog.samples import views urlpatterns = [ - url(r'^api/parser/v1/mandb/(?P<modelName>[a-zA-Z\-]+)$', views.TablesList.as_view()), - url(r'^api/parser/v1/callback_sample$', views.CallbackSample.as_view()), + url(r'^api/catalog/v1/mandb/(?P<modelName>[a-zA-Z\-]+)$', views.TablesList.as_view()), + url(r'^api/catalog/v1/callback_sample$', views.CallbackSample.as_view()), url(r'^samples/$', views.SampleList.as_view()) ] diff --git a/genericparser/samples/views.py b/catalog/samples/views.py index 006f0e5..006f0e5 100644 --- a/genericparser/samples/views.py +++ b/catalog/samples/views.py diff --git a/genericparser/settings.py b/catalog/settings.py index 6044c13..51c9a88 100644 --- a/genericparser/settings.py +++ b/catalog/settings.py @@ -16,14 +16,13 @@ import os import sys import platform -import genericparser.pub.redisco +import catalog.pub.redisco -from genericparser.pub.config.config import REDIS_HOST, REDIS_PORT, REDIS_PASSWD -from genericparser.pub.config.config import DB_NAME, DB_IP, DB_USER, DB_PASSWD, DB_PORT -from genericparser.pub.config import config as pub_config +from catalog.pub.config.config import REDIS_HOST, REDIS_PORT, REDIS_PASSWD +from catalog.pub.config.config import DB_NAME, DB_IP, DB_USER, DB_PASSWD, DB_PORT +from catalog.pub.config import config as pub_config from logging import config as log_config from onaplogging import monkey - monkey.patch_all() # Build paths inside the project like this: os.path.join(BASE_DIR, ...) @@ -50,9 +49,9 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'django.contrib.admin', 'rest_framework', - 'genericparser.pub.database', - 'genericparser.samples', - 'genericparser.swagger', + 'catalog.pub.database', + 'catalog.samples', + 'catalog.swagger', 'drf_yasg', ] @@ -60,7 +59,7 @@ INSTALLED_APPS = [ SWAGGER_SETTINGS = { 'LOGIN_URL': '/admin/login', 'LOGOUT_URL': '/admin/logout', - 'DEFAULT_INFO': 'genericparser.swagger.urls.swagger_info' + 'DEFAULT_INFO': 'catalog.swagger.urls.swagger_info' } TEMPLATES = [ @@ -88,12 +87,12 @@ MIDDLEWARE_CLASSES = [ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'genericparser.middleware.LogContextMiddleware', + 'catalog.middleware.LogContextMiddleware', ] -ROOT_URLCONF = 'genericparser.urls' +ROOT_URLCONF = 'catalog.urls' -WSGI_APPLICATION = 'genericparser.wsgi.application' +WSGI_APPLICATION = 'catalog.wsgi.application' REST_FRAMEWORK = { 'DEFAULT_RENDERER_CLASSES': ( @@ -117,7 +116,7 @@ DATABASES = { }, } -genericparser.pub.redisco.connection_setup(host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWD, db=0) +catalog.pub.redisco.connection_setup(host=REDIS_HOST, port=REDIS_PORT, password=REDIS_PASSWD, db=0) # CACHE_BACKEND = 'redis_cache.cache://%s@%s:%s' % (REDIS_PASSWD, REDIS_HOST, REDIS_PORT) TIME_ZONE = 'UTC' @@ -130,9 +129,9 @@ STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static") ] -# change -pub_config.GENERICPARSER_ROOT_PATH = os.path.join(STATICFILES_DIRS[0], "genericparser") -pub_config.GENERICPARSER_URL_PATH = "static/genericparser" + +pub_config.CATALOG_ROOT_PATH = os.path.join(STATICFILES_DIRS[0], "catalog") +pub_config.CATALOG_URL_PATH = "static/catalog" pub_config.SDC_BASE_URL = "http://%s:%s/api" % (pub_config.MSB_SERVICE_IP, pub_config.MSB_SERVICE_PORT) if platform.system() == 'Windows' or 'test' in sys.argv: @@ -146,12 +145,11 @@ if platform.system() == 'Windows' or 'test' in sys.argv: }, 'filters': { }, - # change 'handlers': { - 'genericparser_handler': { + 'catalog_handler': { 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', - 'filename': os.path.join(BASE_DIR, 'logs/runtime_genericparser.log'), + 'filename': os.path.join(BASE_DIR, 'logs/runtime_catalog.log'), 'formatter': 'standard', 'maxBytes': 1024 * 1024 * 50, 'backupCount': 5, @@ -159,14 +157,13 @@ if platform.system() == 'Windows' or 'test' in sys.argv: }, 'loggers': { - # change - 'genericparser': { - 'handlers': ['genericparser_handler'], + 'catalog': { + 'handlers': ['catalog_handler'], 'level': 'DEBUG', 'propagate': False }, 'tosca': { - 'handlers': ['genericparser_handler'], + 'handlers': ['catalog_handler'], 'level': 'DEBUG', 'propagate': False }, @@ -175,7 +172,7 @@ if platform.system() == 'Windows' or 'test' in sys.argv: else: LOGGING_CONFIG = None # yaml configuration of logging - LOGGING_FILE = os.path.join(BASE_DIR, 'genericparser/log.yml') + LOGGING_FILE = os.path.join(BASE_DIR, 'catalog/log.yml') log_config.yamlConfig(filepath=LOGGING_FILE, watchDog=True) if 'test' in sys.argv: @@ -195,7 +192,6 @@ if 'test' in sys.argv: TEST_OUTPUT_DIR = 'test-reports' import mock - from genericparser.pub.utils import idutil - + from catalog.pub.utils import idutil idutil.get_auto_id = mock.Mock() idutil.get_auto_id.return_value = 1 diff --git a/genericparser/swagger/__init__.py b/catalog/swagger/__init__.py index c7b6818..c7b6818 100644 --- a/genericparser/swagger/__init__.py +++ b/catalog/swagger/__init__.py diff --git a/genericparser/swagger/management/__init__.py b/catalog/swagger/management/__init__.py index 342c2a8..342c2a8 100644 --- a/genericparser/swagger/management/__init__.py +++ b/catalog/swagger/management/__init__.py diff --git a/genericparser/swagger/management/commands/__init__.py b/catalog/swagger/management/commands/__init__.py index 342c2a8..342c2a8 100644 --- a/genericparser/swagger/management/commands/__init__.py +++ b/catalog/swagger/management/commands/__init__.py diff --git a/genericparser/swagger/management/commands/export_swagger.py b/catalog/swagger/management/commands/export_swagger.py index d3c46b1..bc5fd1a 100644 --- a/genericparser/swagger/management/commands/export_swagger.py +++ b/catalog/swagger/management/commands/export_swagger.py @@ -30,7 +30,7 @@ class Command(BaseCommand): def handle(self, *args, **options): self.client = Client() - response = self.client.get("/api/parser/v1/swagger.json") + response = self.client.get("/api/catalog/v1/swagger.json") with open(options['name'], 'w') as swagger_file: swagger_file.write(json.dumps(response.data)) print("swagger api is written to %s" % options['name']) diff --git a/genericparser/swagger/tests.py b/catalog/swagger/tests.py index 43ea97c..fc51b62 100644 --- a/genericparser/swagger/tests.py +++ b/catalog/swagger/tests.py @@ -23,6 +23,6 @@ class SwaggerViewTest(unittest.TestCase): pass def test_swagger(self): - response = self.client.get("/api/parser/v1/swagger.json") + response = self.client.get("/api/catalog/v1/swagger.json") self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) self.assertEqual("2.0", response.data.get("swagger")) diff --git a/genericparser/swagger/urls.py b/catalog/swagger/urls.py index 2ace5ef..5437ee5 100644 --- a/genericparser/swagger/urls.py +++ b/catalog/swagger/urls.py @@ -19,14 +19,14 @@ from rest_framework import permissions # Add code for generating swagger automatically. swagger_info = openapi.Info( - title="MODELING GENERICPARSER API", + title="VFC Catalog API", default_version='v1', description=""" -The `swagger-ui` view can be found [here](/api/parser/v1/swagger). -The `ReDoc` view can be found [here](/api/parser/v1/redoc). -The swagger YAML document can be found [here](/api/parser/v1/swagger.yaml). -The swagger JSON document can be found [here](/api/parser/v1/swagger.json).""" +The `swagger-ui` view can be found [here](/api/catalog/v1/swagger). +The `ReDoc` view can be found [here](/api/catalog/v1/redoc). +The swagger YAML document can be found [here](/api/catalog/v1/swagger.yaml). +The swagger JSON document can be found [here](/api/catalog/v1/swagger.json).""" ) SchemaView = get_schema_view( @@ -36,8 +36,8 @@ SchemaView = get_schema_view( ) urlpatterns = [ - # url(r'^api/genericparser/v1/swagger.json$', SwaggerJsonView.as_view()), - url(r'^api/parser/v1/swagger(?P<format>.json|.yaml)$', SchemaView.without_ui(cache_timeout=0), name='schema-json'), - url(r'^api/parser/v1/swagger$', SchemaView.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), - url(r'^api/parser/v1/redoc$', SchemaView.with_ui('redoc', cache_timeout=0), name='schema-redoc'), + # url(r'^api/catalog/v1/swagger.json$', SwaggerJsonView.as_view()), + url(r'^api/catalog/v1/swagger(?P<format>.json|.yaml)$', SchemaView.without_ui(cache_timeout=0), name='schema-json'), + url(r'^api/catalog/v1/swagger$', SchemaView.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), + url(r'^api/catalog/v1/redoc$', SchemaView.with_ui('redoc', cache_timeout=0), name='schema-redoc'), ] diff --git a/catalog/swagger/vfc.catalog.swagger.json b/catalog/swagger/vfc.catalog.swagger.json new file mode 100644 index 0000000..1327462 --- /dev/null +++ b/catalog/swagger/vfc.catalog.swagger.json @@ -0,0 +1,793 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "ONAP VFC Catalog Rest API", + "description": "VFC Catalog Management API.", + "contact": { + "name": "ONAP VFC team", + "email": "onap-discuss@lists.onap.org", + "url": "https://gerrit.onap.org/r/#/admin/projects/vfc/nfvo/catalog" + } + }, + "basePath": "/api/catalog/v1", + "schemes": [ + "http", + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/nspackages": { + "get": { + "tags": [ + "nspackage" + ], + "summary": "query ns packages info", + "description": "query ns packages info", + "operationId": "query_ns_packages", + "parameters": [], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/NsPkgListInfo" + } + }, + "404": { + "description": "URL not found" + }, + "500": { + "description": "internal error" + } + } + }, + "post": { + "tags": [ + "nspackage" + ], + "summary": "ns package distribute", + "description": "ns package distribute", + "operationId": "ns_pkg_distribute", + "parameters": [ + { + "in": "body", + "name": "body", + "description": "distribute request param", + "required": true, + "schema": { + "$ref": "#/definitions/NsPkgDistributeRequest" + } + } + ], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/NsPkgDistributeResponse" + } + }, + "404": { + "description": "URL not found" + }, + "500": { + "description": "internal error" + } + } + } + }, + "/nspackages/{csarId}": { + "get": { + "tags": [ + "nspackage" + ], + "summary": "query ns package info", + "description": "query ns package info via ns package csarId", + "operationId": "query_ns_package", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "csarId", + "in": "path", + "description": "csar id of ns package", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/NsPkgDetailInfo" + } + }, + "404": { + "description": "URL not found" + }, + "500": { + "description": "internal error" + } + } + }, + "delete": { + "tags": [ + "nspackage" + ], + "summary": "delete ns pkg", + "description": "delete ns pkg", + "operationId": "delete_ns_pkg", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "csarId", + "in": "path", + "description": "csar id of ns package", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "Delete NS Package Response", + "schema": { + "$ref": "#/definitions/NsPkgDelResponse" + } + }, + "404": { + "description": "URL not found" + }, + "500": { + "description": "internal error" + } + } + } + }, + "/parsernsd": { + "post": { + "tags": [ + "model" + ], + "summary": "ns package model", + "description": "ns package model", + "operationId": "ms_model_parser", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "distribute request param", + "required": true, + "schema": { + "$ref": "#/definitions/modelParserRequest" + } + } + ], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/modelParserResponse" + } + }, + "404": { + "description": "URL not found" + }, + "500": { + "description": "internal error" + } + } + } + }, + "/vnfpackages": { + "get": { + "tags": [ + "vnfpackage" + ], + "summary": "query vnf packages info", + "description": "query vnf packages info", + "operationId": "query_vnf_packages", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VnfPkgListInfo" + } + }, + "404": { + "description": "URL not found" + }, + "500": { + "description": "internal error" + } + } + }, + "post": { + "tags": [ + "vnfpackage" + ], + "summary": "vnf package distribute", + "description": "vnf package distribute", + "operationId": "vnf_pkg_distribute", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "distribute request param", + "required": true, + "schema": { + "$ref": "#/definitions/VnfPkgDistributeRequest" + } + } + ], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/VnfPkgDistributeResponse" + } + }, + "404": { + "description": "URL not found" + }, + "500": { + "description": "internal error" + } + } + } + }, + "/vnfpackages/{csarId}": { + "get": { + "tags": [ + "vnfpackage" + ], + "summary": "query vnf package info", + "description": "query one vnf package info via vnf package csarId", + "operationId": "query_vnf_package", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "csarId", + "in": "path", + "description": "csar id of vnf package", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VnfPkgDetailInfo" + } + }, + "404": { + "description": "URL not found" + }, + "500": { + "description": "internal error" + } + } + }, + "delete": { + "tags": [ + "vnfpackage" + ], + "summary": "delete vnf package", + "description": "delete vnf package", + "operationId": "delete_vnf_package", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "csarId", + "in": "path", + "description": "csar id of vnf package", + "required": true, + "type": "string" + } + ], + "responses": { + "202": { + "description": "Delete VNF Pakcage Response", + "schema": { + "$ref": "#/definitions/VnfPkgDelResponse" + } + }, + "404": { + "description": "URL not found" + }, + "500": { + "description": "internal error" + } + } + } + }, + "/parservnfd": { + "post": { + "tags": [ + "model" + ], + "summary": "vnf package model", + "description": "vnf package model", + "operationId": "vnf_model_parser", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "distribute request param", + "required": true, + "schema": { + "$ref": "#/definitions/modelParserRequest" + } + } + ], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/modelParserResponse" + } + }, + "404": { + "description": "URL not found" + }, + "500": { + "description": "internal error" + } + } + } + }, + "/jobs/{jobId}": { + "get": { + "tags": [ + "job" + ], + "summary": "jobstatus", + "description": "Get Job Status", + "operationId": "get_jobstatus", + "parameters": [ + { + "required": true, + "type": "string", + "description": "job Id", + "name": "jobId", + "in": "path" + }, + { + "required": true, + "type": "string", + "description": "job response message id", + "name": "responseId", + "in": "query" + } + ], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/JobDetailInfo" + } + } + } + }, + "post": { + "tags": [ + "job" + ], + "summary": "Update Job Status", + "description": "Update Job Status", + "operationId": "post_jobstatus", + "parameters": [ + { + "required": true, + "type": "string", + "description": "job Id", + "name": "jobId", + "in": "path" + }, + { + "required": true, + "schema": { + "$ref": "#/definitions/PostJobRequest" + }, + "description": "job status", + "name": "responseId", + "in": "body" + } + ], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/JobDetailInfo" + } + } + } + } + } + }, + "definitions": { + "NsPkgDistributeRequest": { + "type": "object", + "properties": { + "csarId": { + "type": "string", + "description": "network service package id, UUID" + } + } + }, + "NsPkgDistributeResponse": { + "type": "object", + "properties": { + "status": { + "type": "string", + "description": "Operation status. value is success or failed" + }, + "statusDescription": { + "type": "string", + "description": "description about the operation result" + }, + "errorCode": { + "type": "string", + "description": "If the status is failed, the errorcode will be returned" + } + } + }, + "NsPkgDelResponse": { + "type": "object", + "properties": { + "status": { + "type": "string", + "description": "Operation status. value is success or failed" + }, + "statusDescription": { + "type": "string", + "description": "description about the operation result" + }, + "errorCode": { + "type": "string", + "description": "If the status is failed, the errorcode will be returned" + } + } + }, + "NsPkgListInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/NsPkgDetailInfo" + } + }, + "NsPkgDetailInfo": { + "type": "object", + "properties": { + "csarId": { + "type": "string" + }, + "packageInfo": { + "$ref": "#/definitions/NsPkgInfo" + } + } + }, + "NsPkgInfo": { + "type": "object", + "properties": { + "nsPackageId": { + "type": "string", + "description": "network service package id, UUID, csarId" + }, + "nsdId": { + "type": "string", + "description": "network service descriptor ID" + }, + "nsdProvider": { + "type": "string", + "description": "network service designer name" + }, + "nsdVersion": { + "type": "string", + "description": "network service descriptor version" + }, + "csarName": { + "type": "string", + "description": "network service package name" + }, + "nsdModel": { + "type": "string", + "description": "ns JSON string parsed and transformed by parser" + }, + "downloadUrl": { + "type": "string", + "description": "download url of network service package" + } + } + }, + "NsInstListInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/NsInstInfo" + } + }, + "NsInstInfo": { + "type": "object", + "properties": { + "nsInstanceId": { + "type": "string", + "description": "network service instance ID" + }, + "nsInstanceName": { + "type": "string", + "description": "network service instance name" + } + } + }, + "VnfPkgDistributeRequest": { + "type": "object", + "properties": { + "csarId": { + "type": "string", + "description": "vnf package id, UUID" + } + } + }, + "VnfPkgDistributeResponse": { + "type": "object", + "properties": { + "jobId": { + "type": "string", + "description": "VNF package distribute job ID" + } + } + }, + "VnfPkgDelResponse": { + "type": "object", + "properties": { + "status": { + "type": "string", + "description": "Operation status. value is success or failed" + }, + "statusDescription": { + "type": "string", + "description": "description about the operation result" + }, + "errorCode": { + "type": "string", + "description": "If the status is failed, the errorcode will be returned" + } + } + }, + "VnfPkgListInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/VnfPkgDetailInfo" + } + }, + "VnfPkgDetailInfo": { + "type": "object", + "properties": { + "csarId": { + "type": "string", + "description": "vnf package id, UUID" + }, + "packageInfo": { + "$ref": "#/definitions/VnfPkgInfo" + }, + "imageInfo": { + "$ref": "#/definitions/VnfPkgImgListInfo" + } + } + }, + "VnfPkgInfo": { + "type": "object", + "description": "vnf package infomation", + "properties": { + "vnfPackageId": { + "type": "string", + "description": "vnf package id (csarId)" + }, + "csarName": { + "type": "string", + "description": "The name of the csar" + }, + "vnfdId": { + "type": "string", + "description": "VNF descriptor ID" + }, + "vnfdProvider": { + "type": "string", + "description": "VNF descriptor vendor ID" + }, + "vnfdModel": { + "type": "string", + "description": "The model of the VNF (JSON) encoded to string" + }, + "vnfdVersion": { + "type": "string", + "description": "VNF descriptor version" + }, + "vnfVersion": { + "type": "string", + "description": "VNF Software version" + }, + "downloadUrl":{ + "type": "string", + "description": "The URL from which the VNF package can be downloaded" + } + } + }, + "VnfInstListInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/VnfInstInfo" + } + }, + "VnfInstInfo": { + "type": "object", + "properties": { + "vnfInstanceId": { + "type": "string", + "description": "VNF instance ID" + }, + "vnfInstanceName": { + "type": "string", + "description": "VNF instance name" + } + } + }, + "VnfPkgImgListInfo": { + "type": "array", + "items": { + "$ref": "#/definitions/VnfPkgImgInfo" + } + }, + "VnfPkgImgInfo": { + "type": "object", + "properties": { + "fileName": { + "type": "string", + "description": "image file name" + }, + "imageUrl": { + "type": "string", + "description": "image file path in the csar or image url in external repository" + } + } + }, + "modelParserRequest":{ + "type": "object", + "properties": { + "csarId": { + "type": "string", + "description": "csar Package Id" + }, + "inputs": { + "type": "object", + "description": "csar package json inputs" + } + } + }, + "modelParserResponse":{ + "type": "object", + "properties": { + "model": { + "type": "object", + "description": "csar model json data" + } + } + }, + "jobResponseInfo": { + "type": "object", + "properties": { + "status": { + "type": "string" + }, + "progress":{ + "type": "string" + }, + "statusDescription": { + "type": "string" + }, + "errorCode": { + "type": "string" + }, + "responseId": { + "type": "string" + } + } + }, + "PostJobRequest": { + "type": "object", + "properties": { + "progress": { + "type": "string" + }, + "desc": { + "type": "string" + }, + "errcode": { + "type": "string" + } + } + }, + "JobDetailInfo":{ + "type": "object", + "properties": { + "jobId": { + "type": "string" + }, + "responseDescriptor": + { + "type":"object", + "properties": { + "status": { + "type": "string" + }, + "progress":{ + "type": "string" + }, + "statusDescription": { + "type": "string" + }, + "errorCode": { + "type": "string" + }, + "responseId": { + "type": "string" + }, + "responseHistoryList": { + "type": "array", + "items": { + "$ref": "#/definitions/jobResponseInfo" + } + } + } + } + } + } + } +}
\ No newline at end of file diff --git a/genericparser/swagger/views.py b/catalog/swagger/views.py index e99262b..33d0edb 100644 --- a/genericparser/swagger/views.py +++ b/catalog/swagger/views.py @@ -21,7 +21,7 @@ from rest_framework.views import APIView class SwaggerJsonView(APIView): def get(self, request): - json_file = os.path.join(os.path.dirname(__file__), 'modeling.genericparser.swagger.json') + 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() diff --git a/genericparser/urls.py b/catalog/urls.py index 4cf58c8..76c972b 100644 --- a/genericparser/urls.py +++ b/catalog/urls.py @@ -15,20 +15,23 @@ from django.conf.urls import include, url from django.contrib import admin - -from genericparser.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM +from catalog.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM, \ + MSB_SVC_CALALOG_URL, MSB_SVC_NSD_URL, MSB_SVC_VNFPKGM_URL urlpatterns = [ - url(r'^api/parser/v1/admin', admin.site.urls), - url(r'^', include('genericparser.samples.urls')), - url(r'^', include('genericparser.packages.urls')), - url(r'^', include('genericparser.jobs.urls')), - url(r'^', include('genericparser.swagger.urls')), + url(r'^api/catalog/v1/admin', admin.site.urls), + url(r'^', include('catalog.samples.urls')), + url(r'^', include('catalog.packages.urls')), + url(r'^', include('catalog.jobs.urls')), + url(r'^', include('catalog.swagger.urls')), ] # regist to MSB when startup if REG_TO_MSB_WHEN_START: import json - from genericparser.pub.utils.restcall import req_by_msb + from catalog.pub.utils.restcall import req_by_msb + req_by_msb(MSB_SVC_CALALOG_URL, "DELETE") + req_by_msb(MSB_SVC_NSD_URL, "DELETE") + req_by_msb(MSB_SVC_VNFPKGM_URL, "DELETE") for reg_param in REG_TO_MSB_REG_PARAM: req_by_msb(REG_TO_MSB_REG_URL, "POST", json.JSONEncoder().encode(reg_param)) diff --git a/genericparser/wsgi.py b/catalog/wsgi.py index ed4bd0f..a0b4d5d 100644 --- a/genericparser/wsgi.py +++ b/catalog/wsgi.py @@ -16,6 +16,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "genericparser.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "catalog.settings") application = get_wsgi_application() diff --git a/docker/Dockerfile b/docker/Dockerfile index 03a9ffb..b76da98 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -15,4 +15,4 @@ EXPOSE 8806 USER onap WORKDIR /service -ENTRYPOINT modeling/genericparser/docker/docker-entrypoint.sh +ENTRYPOINT modeling/etsicatalog/docker/docker-entrypoint.sh diff --git a/docker/build_image.sh b/docker/build_image.sh index c0164fd..98550cd 100755 --- a/docker/build_image.sh +++ b/docker/build_image.sh @@ -8,7 +8,7 @@ BUILD_ARGS="--no-cache" ORG="onap" VERSION="1.0.3" PROJECT="modeling" -IMAGE="genericparser" +IMAGE="etsicatalog" DOCKER_REPOSITORY="nexus3.onap.org:10003" IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}" TIMESTAMP=$(date +"%Y%m%dT%H%M%S") diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 1e2e16a..8666f69 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -35,12 +35,12 @@ for i in {1..5}; do done # Configure service based on docker environment variables -modeling/genericparser/docker/instance_config.sh +modeling/etsicatalog/docker/instance_config.sh # microservice-specific one-time initialization -modeling/genericparser/docker/instance_init.sh +modeling/etsicatalog/docker/instance_init.sh date > init.log # Start the microservice -modeling/genericparser/docker/instance_run.sh +modeling/etsicatalog/docker/instance_run.sh diff --git a/docker/docker-env-conf.sh b/docker/docker-env-conf.sh index 953867e..aa79088 100755 --- a/docker/docker-env-conf.sh +++ b/docker/docker-env-conf.sh @@ -6,13 +6,13 @@ install_sf(){ apk --no-cache add bash curl gcc wget mysql-client openssl-dev apk --no-cache add python36-dev libffi-dev musl-dev py3-virtualenv - # get binary zip from nexus - vfc-nfvo-genericparser + # get binary zip from nexus - modeling-etsicatalog - wget -q -O modeling-genericparser.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.modeling.genericparser&a=modeling-genericparser&e=zip&v=${pkg_version}-SNAPSHOT&e=zip" && \ - unzip modeling-genericparser.zip && \ - rm -rf modeling-genericparser.zip && \ + wget -q -O modeling-etsicatalog.zip "https://nexus.onap.org/service/local/artifact/maven/redirect?r=snapshots&g=org.onap.modeling.genericparser&a=modeling-genericparser&e=zip&v=${pkg_version}-SNAPSHOT&e=zip" && \ + unzip modeling-etsicatalog.zip && \ + rm -rf modeling-etsicatalog.zip && \ pip install --upgrade setuptools pip && \ - pip install --no-cache-dir --pre -r /service/modeling/genericparser/requirements.txt + pip install --no-cache-dir --pre -r /service/modeling/etsicatalog/requirements.txt } add_user(){ diff --git a/docker/instance_config.sh b/docker/instance_config.sh index 80a278f..ebc785a 100755 --- a/docker/instance_config.sh +++ b/docker/instance_config.sh @@ -2,18 +2,18 @@ MSB_IP=`echo $MSB_ADDR | cut -d: -f 1` MSB_PORT=`echo $MSB_ADDR | cut -d: -f 2` -# modeling/genericparser +# modeling/etsicatalog if [ $MSB_IP ]; then - sed -i "s|MSB_SERVICE_IP.*|MSB_SERVICE_IP = '$MSB_IP'|" modeling/genericparser/genericparser/pub/config/config.py + sed -i "s|MSB_SERVICE_IP.*|MSB_SERVICE_IP = '$MSB_IP'|" modeling/etsicatalog/catalog/pub/config/config.py fi if [ $MSB_PORT ]; then - sed -i "s|MSB_SERVICE_PORT.*|MSB_SERVICE_PORT = '$MSB_PORT'|" modeling/genericparser/genericparser/pub/config/config.py + sed -i "s|MSB_SERVICE_PORT.*|MSB_SERVICE_PORT = '$MSB_PORT'|" modeling/etsicatalog/catalog/pub/config/config.py fi if [ $SERVICE_IP ]; then - sed -i "s|\"ip\": \".*\"|\"ip\": \"$SERVICE_IP\"|" modeling/genericparser/genericparser/pub/config/config.py + sed -i "s|\"ip\": \".*\"|\"ip\": \"$SERVICE_IP\"|" modeling/etsicatalog/catalog/pub/config/config.py fi MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1` @@ -27,8 +27,8 @@ else fi -sed -i "s|DB_IP.*|DB_IP = '$MYSQL_IP'|" modeling/genericparser/genericparser/pub/config/config.py -sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" modeling/genericparser/genericparser/pub/config/config.py -sed -i "s|REDIS_HOST.*|REDIS_HOST = '$REDIS_IP'|"modeling/genericparser/genericparser/pub/config/config.py +sed -i "s|DB_IP.*|DB_IP = '$MYSQL_IP'|" modeling/etsicatalog/catalog/pub/config/config.py +sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" modeling/etsicatalog/catalog/pub/config/config.py +sed -i "s|REDIS_HOST.*|REDIS_HOST = '$REDIS_IP'|"modeling/etsicatalog/catalog/pub/config/config.py -cat modeling/genericparser/genericparser/pub/config/config.py +cat modeling/etsicatalog/catalog/pub/config/config.py diff --git a/docker/instance_init.sh b/docker/instance_init.sh index 0c25203..3b6ca8c 100755 --- a/docker/instance_init.sh +++ b/docker/instance_init.sh @@ -13,13 +13,13 @@ fi function create_database { - cd /service/modeling/genericparser/resources/bin + cd /service/modeling/catalog/resources/bin bash initDB.sh $MYSQL_ROOT_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP } function migrate_database { - cd /service/modeling/genericparser + cd /service/modeling/catalog python manage.py migrate } diff --git a/docker/instance_run.sh b/docker/instance_run.sh index c451190..ad20163 100755 --- a/docker/instance_run.sh +++ b/docker/instance_run.sh @@ -1,10 +1,10 @@ #!/bin/bash -cd /service/modeling/genericparser +cd /service/modeling/etsicatalog ./run.sh -while [ ! -f logs/runtime_genericparser.log ]; do +while [ ! -f logs/runtime_etsicatalog.log ]; do sleep 1 done -tail -F logs/runtime_genericparser.log +tail -F logs/runtime_etsicatalog.log diff --git a/genericparser/pub/database/migrations/0002_auto_20190422_1442.py b/genericparser/pub/database/migrations/0002_auto_20190422_1442.py deleted file mode 100644 index da23582..0000000 --- a/genericparser/pub/database/migrations/0002_auto_20190422_1442.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.9 on 2019-04-22 14:42 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('database', '0001_initial'), - ] - - operations = [ - migrations.AlterModelTable( - name='jobmodel', - table='GENERICPARSER_JOB', - ), - migrations.AlterModelTable( - name='jobstatusmodel', - table='GENERICPARSER_JOB_STATUS', - ), - migrations.AlterModelTable( - name='nsdmsubscriptionmodel', - table='GENERICPARSER_NSDM_SUBSCRIPTION', - ), - migrations.AlterModelTable( - name='nspackagemodel', - table='GENERICPARSER_NSPACKAGE', - ), - migrations.AlterModelTable( - name='pnfpackagemodel', - table='GENERICPARSER_PNFPACKAGE', - ), - migrations.AlterModelTable( - name='servicepackagemodel', - table='GENERICPARSER_SERVICEPACKAGE', - ), - migrations.AlterModelTable( - name='softwareimagemodel', - table='GENERICPARSER_SOFTWAREIMAGEMODEL', - ), - migrations.AlterModelTable( - name='vnfpackagemodel', - table='GENERICPARSER_VNFPACKAGE', - ), - ] @@ -15,7 +15,7 @@ import os import sys -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "genericparser.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "catalog.settings") if __name__ == "__main__": from django.core.management import execute_from_command_line @@ -21,12 +21,12 @@ <version>2.0.0</version> </parent> <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.modeling.genericparser</groupId> - <artifactId>modeling-genericparser</artifactId> + <groupId>org.onap.modeling.etsicatalog</groupId> + <artifactId>modeling-etsicatalog</artifactId> <version>1.0.3-SNAPSHOT</version> <packaging>pom</packaging> - <name>modeling-genericparser</name> - <description>modeling genericparser</description> + <name>modeling-etsicatalog</name> + <description>modeling etsicatalog</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <sonar.sources>.</sonar.sources> diff --git a/resources/bin/initDB.sh b/resources/bin/initDB.sh index 7d87e5d..85b61d9 100755 --- a/resources/bin/initDB.sh +++ b/resources/bin/initDB.sh @@ -20,15 +20,15 @@ MYSQL_USER=$1 MYSQL_PASSWORD=$2 MYSQL_PORT=$3 MYSQL_IP=$4 -echo "start create gengricparser db" +echo "start create etsicatalog db" sql_path=$HOME/../ -mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -P$MYSQL_PORT -h$MYSQL_IP <$sql_path/dbscripts/mysql/modeling-gengricparser-createdb.sql +mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -P$MYSQL_PORT -h$MYSQL_IP <$sql_path/dbscripts/mysql/modeling-etsicatalog-createdb.sql sql_result=$? if [ $sql_result -ne 0 ] ; then - echo "Failed to create gengricparser database" + echo "Failed to create etsicatalog database" exit 1 else - echo "Create gengricparser database successfully" + echo "Create etsicatalog database successfully" exit 0 fi diff --git a/resources/dbscripts/mysql/modeling-gengricparser-createdb.sql b/resources/dbscripts/mysql/modeling-etsicatalog-createdb.sql index d868899..e3fc2ba 100644 --- a/resources/dbscripts/mysql/modeling-gengricparser-createdb.sql +++ b/resources/dbscripts/mysql/modeling-etsicatalog-createdb.sql @@ -20,9 +20,9 @@ use mysql; create database if not exists genericparser CHARACTER SET utf8; -GRANT ALL PRIVILEGES ON genericparser.* TO 'genericparser'@'%' IDENTIFIED BY 'genericparser' WITH GRANT OPTION; -GRANT ALL PRIVILEGES ON mysql.* TO 'genericparser'@'%' IDENTIFIED BY 'genericparser' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON etsicatalog.* TO 'etsicatalog'@'%' IDENTIFIED BY 'etsicatalog' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON mysql.* TO 'etsicatalog'@'%' IDENTIFIED BY 'etsicatalog' WITH GRANT OPTION; -GRANT ALL PRIVILEGES ON genericparser.* TO 'genericparser'@'localhost' IDENTIFIED BY 'genericparser' WITH GRANT OPTION; -GRANT ALL PRIVILEGES ON mysql.* TO 'genericparser'@'localhost' IDENTIFIED BY 'genericparser' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON etsicatalog.* TO 'etsicatalog'@'localhost' IDENTIFIED BY 'etsicatalog' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON mysql.* TO 'etsicatalog'@'localhost' IDENTIFIED BY 'etsicatalog' WITH GRANT OPTION; FLUSH PRIVILEGES; @@ -13,17 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -logDir="/var/log/onap/modeling/genericparser/" +logDir="/var/log/onap/modeling/etsicatalog/" if [ ! -x $logDir ]; then mkdir -p $logDir fi nohup python manage.py runserver 0.0.0.0:8806 > /dev/null & -# nohup uwsgi --http :8806 -t 120 --module genericparser.wsgi --master --processes 4 & +# nohup uwsgi --http :8806 -t 120 --module catalog.wsgi --master --processes 4 & # if [ "${SSL_ENABLED}" = "true" ]; then -# nohup uwsgi --https :8806,genericparser/pub/ssl/cert/foobar.crt,genericparser/pub/ssl/cert/foobar.key, -t 120 --module genericparser.wsgi --master --processes 4 & +# nohup uwsgi --https :8806,catalog/pub/ssl/cert/foobar.crt,catalog/pub/ssl/cert/foobar.key, -t 120 --enable-threads --module catalog.wsgi --master --processes 4 & # else -# nohup uwsgi --http :8806 -t 120 --module genericparser.wsgi --master --processes 4 & +# nohup uwsgi --http :8806 -t 120 --enable-threads --module catalog.wsgi --master --processes 4 & # fi diff --git a/static/genericparser/empty.txt b/static/catalog/empty.txt index e69de29..e69de29 100644 --- a/static/genericparser/empty.txt +++ b/static/catalog/empty.txt diff --git a/static/genericparser/resource_test.csar b/static/catalog/resource_test.csar Binary files differindex 1cf038d..1cf038d 100644 --- a/static/genericparser/resource_test.csar +++ b/static/catalog/resource_test.csar @@ -11,7 +11,7 @@ exclude = ./venv-tox,./.tox [testenv] deps = -r{toxinidir}/requirements.txt -commands = coverage run --branch manage.py test genericparser +commands = coverage run --branch manage.py test catalog [testenv:pep8] deps = flake8 |