From: Fu Jinhua Date: Thu, 4 Apr 2019 02:58:41 +0000 (+0000) Subject: Merge "Fix NS update serializers error" X-Git-Tag: 1.3.0~59 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=93c9c026a20214473ee04967f1e5d101c98ba5e7;hp=6d6bbbd6df701ebbebdc0c46068d0663dc0db3e4;p=vfc%2Fnfvo%2Flcm.git Merge "Fix NS update serializers error" --- diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 814d1798..e116c33b 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -1,5 +1,7 @@ #!/bin/bash +find /service -name '*.sh'|xargs chmod a+x + if [ -z "$SERVICE_IP" ]; then export SERVICE_IP=`hostname -i` fi diff --git a/docker/instance_config.sh b/docker/instance_config.sh index 185194cd..524d4e7f 100755 --- a/docker/instance_config.sh +++ b/docker/instance_config.sh @@ -29,14 +29,16 @@ fi # Configure MYSQL MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1` MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2` -MYSQL_USER=`echo $MYSQL_AUTH | cut -d: -f 1` -MYSQL_ROOT_PASSWORD=`echo $MYSQL_AUTH | cut -d: -f 2 - echo "MYSQL_ADDR=$MYSQL_ADDR" + +if [ $REDIS_ADDR ]; then + REDIS_IP=`echo $REDIS_ADDR | cut -d: -f 1` +else + REDIS_IP="$MYSQL_ADDR" +fi + sed -i "s|DB_IP.*|DB_IP = '$MYSQL_IP'|" vfc/nfvo/lcm/lcm/pub/config/config.py sed -i "s|DB_PORT.*|DB_PORT = $MYSQL_PORT|" vfc/nfvo/lcm/lcm/pub/config/config.py sed -i "s|REDIS_HOST.*|REDIS_HOST = '$MYSQL_IP'|" vfc/nfvo/lcm/lcm/pub/config/config.py -sed -i "s|DB_USER.*|DB_USER = '$MYSQL_USER'|" vfc/nfvo/lcm/lcm/pub/config/config.py -sed -i "s|DB_PASSWD.*|DB_PASSWD = '$MYSQL_ROOT_PASSWORD'|" vfc/nfvo/lcm/lcm/pub/config/config.py cat vfc/nfvo/lcm/lcm/pub/config/config.py diff --git a/docker/instance_init.sh b/docker/instance_init.sh index 70e83016..7e5fcf31 100755 --- a/docker/instance_init.sh +++ b/docker/instance_init.sh @@ -1,52 +1,34 @@ #/bin/bash -mkdir -p /service/vfc/nfvo/lcm/resources/bin/logs -mkdir -p /var/log/onap/vfc/nslcm/ -if [ ! -f /service/vfc/nfvo/lcm/resources/bin/logs/django.log ]; then - touch /service/vfc/nfvo/lcm/resources/bin/logs/django.log -else - echo >/service/vfc/nfvo/lcm/resources/bin/logs/django.log -fi -if [ ! -f /var/log/onap/vfc/nslcm/runtime_nslcm.log ]; then - touch /var/log/onap/vfc/nslcm/runtime_nslcm.log +MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1` +MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2` + +if [ $MYSQL_AUTH ]; then + MYSQL_ROOT_USER=`echo $MYSQL_AUTH | cut -d: -f 1` + MYSQL_ROOT_PASSWORD=`echo $MYSQL_AUTH | cut -d: -f 2` else - echo >/var/log/onap/vfc/nslcm/runtime_nslcm.log + MYSQL_ROOT_USER="root" + MYSQL_ROOT_PASSWORD="root" fi -MYSQL_IP=`echo $MYSQL_ADDR | cut -d: -f 1` -MYSQL_PORT=`echo $MYSQL_ADDR | cut -d: -f 2` -MYSQL_USER=`echo $MYSQL_AUTH | cut -d: -f 1` -MYSQL_ROOT_PASSWORD=`echo $MYSQL_AUTH | cut -d: -f 2` function create_database { cd /service/vfc/nfvo/lcm/resources/bin - bash initDB.sh $MYSQL_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP - man_path=/service/vfc/nfvo/lcm - tab=`mysql -u${MYSQL_USER} -p${MYSQL_ROOT_PASSWORD} -P${MYSQL_PORT} -h${MYSQL_IP} -e "SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='vfcnfvolcm';"` - tab1=`echo $tab |awk '{print $2}'` - - if [ $tab1 -eq 0 ] ; then - - echo "TABLE NOT EXISTS, START MIGRATE" - python $man_path/manage.py makemigrations database && python $man_path/manage.py migrate database & - wait - tab2=`mysql -u${MYSQL_USER} -p${MYSQL_ROOT_PASSWORD} -P${MYSQL_PORT} -h${MYSQL_IP} -e "SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='vfcnfvolcm';"` - tab3=`echo $tab2|awk '{print $2}'` - if [ $tab3 -gt 0 ] ; then - echo "TABLE CREATE uUCCESSFUL" - fi -else - echo "table already existed" - exit 1 -fi + bash initDB.sh $MYSQL_ROOT_USER $MYSQL_ROOT_PASSWORD $MYSQL_PORT $MYSQL_IP + } +function migrate_database { + cd /service/vfc/nfvo/lcm + python manage.py makemigrations database + python manage.py migrate +} -if [ ! -f /service/vfc/nfvo/lcm/docker/db.txt ]; then - echo 1 > /service/vfc/nfvo/lcm/docker/db.txt +GET_NSLCM_DB="show databases like 'vfcnfvolcm';" +NSLCM_DB=`mysql -u$MYSQL_ROOT_USER -p$MYSQL_ROOT_PASSWORD -P$MYSQL_PORT -h$MYSQL_IP -e "GET_NSLCM_DB"` +if [[ "$NSLCM_DB" == "" ]]; then create_database -else - echo "database already existed" + migrate_database fi diff --git a/docs/platform/APIs/CATALOG_API/CATALOG_API_Specification_v0.1.json b/docs/platform/APIs/CATALOG_API/CATALOG_API_Specification_v0.1.json new file mode 100644 index 00000000..df013d19 --- /dev/null +++ b/docs/platform/APIs/CATALOG_API/CATALOG_API_Specification_v0.1.json @@ -0,0 +1,1787 @@ +{ + "swagger": "2.0", + "info": { + "title": "VFC Catalog API", + "description": "\n\nThe `swagger-ui` view can be found [here](/api/catalog/v1/swagger).\nThe `ReDoc` view can be found [here](/api/catalog/v1/redoc).\nThe swagger YAML document can be found [here](/api/catalog/v1/swagger.yaml).\nThe swagger JSON document can be found [here](/api/catalog/v1/swagger.json).", + "version": "v1" + }, + "host": "127.0.0.1:8000", + "schemes": ["http"], + "basePath": "/", + "paths": { + "/api/catalog/v1/jobs/{job_id}": { + "get": { + "operationId": "api_catalog_v1_jobs_read", + "description": "Get job status", + "parameters": [{ + "name": "job_id", + "in": "query", + "description": "job id", + "type": "string" + }, { + "name": "responseId", + "in": "query", + "description": "response id", + "type": "string" + }], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/GetJobResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/PostJobResponseResult" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "post": { + "operationId": "api_catalog_v1_jobs_create", + "description": "Update job status", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/PostJobRequest" + } + }, { + "name": "job_id", + "in": "query", + "description": "job id", + "type": "string" + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/PostJobResponseResult" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/PostJobResponseResult" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "job_id", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/catalog/v1/mandb/{modelName}": { + "get": { + "operationId": "api_catalog_v1_mandb_read", + "description": "", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "delete": { + "operationId": "api_catalog_v1_mandb_delete", + "description": "", + "parameters": [], + "responses": { + "204": { + "description": "" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "modelName", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/catalog/v1/nspackages": { + "get": { + "operationId": "api_catalog_v1_nspackages_list", + "description": "Query NS packages", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/NsPackage" + } + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "post": { + "operationId": "api_catalog_v1_nspackages_create", + "description": "On distribute NS package", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/NsPackageDistributeRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/NsPackageDistributeResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [] + }, + "/api/catalog/v1/nspackages/{csarId}": { + "get": { + "operationId": "api_catalog_v1_nspackages_read", + "description": "Query one NS package", + "parameters": [{ + "name": "csarId", + "in": "query", + "description": "csarId", + "type": "string" + }], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/NsPackage" + } + }, + "500": { + "description": "error message", + "schema": { + "type": "string" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "delete": { + "operationId": "api_catalog_v1_nspackages_delete", + "description": "Delete one NS package", + "parameters": [{ + "name": "csarId", + "in": "query", + "description": "csarId", + "type": "string" + }], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/NsPackageDistributeResponse" + } + }, + "500": { + "description": "error message", + "schema": { + "type": "string" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "csarId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/catalog/v1/parsernsd": { + "post": { + "operationId": "api_catalog_v1_parsernsd_create", + "description": "Parse NS model", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ParseModelRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/ParseModelResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [] + }, + "/api/catalog/v1/parserpnfd": { + "post": { + "operationId": "api_catalog_v1_parserpnfd_create", + "description": "Parse PNF model", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ParseModelRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/ParseModelResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [] + }, + "/api/catalog/v1/parservnfd": { + "post": { + "operationId": "api_catalog_v1_parservnfd_create", + "description": "Parse NF model", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ParseModelRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/ParseModelResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [] + }, + "/api/catalog/v1/vnfpackages": { + "get": { + "operationId": "api_catalog_v1_vnfpackages_list", + "description": "Query Nf packages", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/NfPackage" + } + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "post": { + "operationId": "api_catalog_v1_vnfpackages_create", + "description": "On distribute Nf package", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/NfPackageDistributeRequest" + } + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/PostJobResponse" + } + }, + "500": { + "description": "", + "schema": { + "$ref": "#/definitions/InternalErrorRequest" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [] + }, + "/api/catalog/v1/vnfpackages/{csarId}": { + "get": { + "operationId": "api_catalog_v1_vnfpackages_read", + "description": "Query one Nf package", + "parameters": [{ + "name": "csarId", + "in": "query", + "description": "csarId", + "type": "string" + }], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/NfPackage" + } + }, + "500": { + "description": "error message", + "schema": { + "type": "string" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "delete": { + "operationId": "api_catalog_v1_vnfpackages_delete", + "description": "Delete one Nf package", + "parameters": [{ + "name": "csarId", + "in": "query", + "description": "csarId", + "type": "string" + }], + "responses": { + "202": { + "description": "", + "schema": { + "$ref": "#/definitions/PostJobResponse" + } + }, + "500": { + "description": "error message", + "schema": { + "type": "string" + } + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "csarId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/nsd/v1/ns_descriptors": { + "get": { + "operationId": "api_nsd_v1_ns_descriptors_list", + "description": "Query multiple NSDs", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/NsdInfo" + } + } + }, + "500": { + "description": "Internal error" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "post": { + "operationId": "api_nsd_v1_ns_descriptors_create", + "description": "Create a NSD", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateNsdInfoRequest" + } + }], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/NsdInfo" + } + }, + "500": { + "description": "Internal error" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [] + }, + "/api/nsd/v1/ns_descriptors/{nsdInfoId}": { + "get": { + "operationId": "api_nsd_v1_ns_descriptors_read", + "description": "Query a NSD", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/NsdInfo" + } + }, + "500": { + "description": "Internal error" + }, + "404": { + "description": "NSDs do not exist" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "delete": { + "operationId": "api_nsd_v1_ns_descriptors_delete", + "description": "Delete a NSD", + "parameters": [], + "responses": { + "500": { + "description": "Internal error" + }, + "204": { + "description": "No content" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "nsdInfoId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/nsd/v1/ns_descriptors/{nsdInfoId}/nsd_content": { + "get": { + "operationId": "api_nsd_v1_ns_descriptors_nsd_content_list", + "description": "Download NSD content", + "parameters": [], + "responses": { + "404": { + "description": "NSD does not exist." + }, + "204": { + "description": "No content" + }, + "500": { + "description": "Internal error" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "put": { + "operationId": "api_nsd_v1_ns_descriptors_nsd_content_update", + "description": "Upload NSD content", + "parameters": [], + "responses": { + "500": { + "description": "Internal error" + }, + "204": { + "description": "PNFD file" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "nsdInfoId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/nsd/v1/pnf_descriptors": { + "get": { + "operationId": "api_nsd_v1_pnf_descriptors_list", + "description": "Query multiple PNFDs", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/PnfdInfo" + } + } + }, + "500": { + "description": "Internal error" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "post": { + "operationId": "api_nsd_v1_pnf_descriptors_create", + "description": "Create a PNFD", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreatePnfdInfoRequest" + } + }], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/PnfdInfo" + } + }, + "500": { + "description": "Internal error" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [] + }, + "/api/nsd/v1/pnf_descriptors/{pnfdInfoId}": { + "get": { + "operationId": "api_nsd_v1_pnf_descriptors_read", + "description": "Query a PNFD", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/PnfdInfo" + } + }, + "500": { + "description": "Internal error" + }, + "404": { + "description": "PNFD does not exist" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "delete": { + "operationId": "api_nsd_v1_pnf_descriptors_delete", + "description": "Delete a PNFD", + "parameters": [], + "responses": { + "500": { + "description": "Internal error" + }, + "204": { + "description": "No content" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "pnfdInfoId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/nsd/v1/pnf_descriptors/{pnfdInfoId}/pnfd_content": { + "get": { + "operationId": "api_nsd_v1_pnf_descriptors_pnfd_content_list", + "description": "Fetch PNFD content", + "parameters": [], + "responses": { + "404": { + "description": "PNFD does not exist" + }, + "204": { + "description": "PNFD file" + }, + "500": { + "description": "Internal error" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "put": { + "operationId": "api_nsd_v1_pnf_descriptors_pnfd_content_update", + "description": "Upload PNFD content", + "parameters": [], + "responses": { + "500": { + "description": "Internal error" + }, + "204": { + "description": "No content" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "pnfdInfoId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/vnfpkgm/v1/vnf_packages": { + "get": { + "operationId": "api_vnfpkgm_v1_vnf_packages_list", + "description": "Query multiple VNF package resource", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/VnfPkgInfo" + } + } + }, + "500": { + "description": "Internal error" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "post": { + "operationId": "api_vnfpkgm_v1_vnf_packages_create", + "description": "Create an individual VNF package resource", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/CreateVnfPkgInfoRequest" + } + }], + "responses": { + "201": { + "description": "", + "schema": { + "$ref": "#/definitions/VnfPkgInfo" + } + }, + "500": { + "description": "Internal error" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [] + }, + "/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}": { + "get": { + "operationId": "api_vnfpkgm_v1_vnf_packages_read", + "description": "Query an individual VNF package resource", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "$ref": "#/definitions/VnfPkgInfo" + } + }, + "500": { + "description": "Internal error" + }, + "404": { + "description": "VNF package does not exist" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "delete": { + "operationId": "api_vnfpkgm_v1_vnf_packages_delete", + "description": "Delete an individual VNF package resource", + "parameters": [], + "responses": { + "500": { + "description": "Internal error" + }, + "204": { + "description": "No content" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "vnfPkgId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}/package_content": { + "get": { + "operationId": "api_vnfpkgm_v1_vnf_packages_package_content_list", + "description": "Fetch VNF package content", + "parameters": [], + "responses": { + "200": { + "description": "", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/VnfPkgInfo" + } + } + }, + "500": { + "description": "Internal error" + }, + "404": { + "description": "VNF package does not exist" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "put": { + "operationId": "api_vnfpkgm_v1_vnf_packages_package_content_update", + "description": "Upload VNF package content", + "parameters": [], + "responses": { + "202": { + "description": "Successfully" + }, + "500": { + "description": "Internal error" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "vnfPkgId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/api/vnfpkgm/v1/vnf_packages/{vnfPkgId}/package_content/upload_from_uri": { + "post": { + "operationId": "api_vnfpkgm_v1_vnf_packages_package_content_upload_from_uri_create", + "description": "Upload VNF package content from uri", + "parameters": [{ + "name": "data", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UploadVnfPackageFromUriRequest" + } + }], + "responses": { + "202": { + "description": "Successfully" + }, + "500": { + "description": "Internal error" + } + }, + "consumes": ["application/json"], + "tags": ["api"] + }, + "parameters": [{ + "name": "vnfPkgId", + "in": "path", + "required": true, + "type": "string" + }] + }, + "/samples/": { + "get": { + "operationId": "samples_list", + "description": "List all samples.", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "consumes": ["application/json"], + "tags": ["samples"] + }, + "parameters": [] + } + }, + "definitions": { + "JobResponseHistoryList": { + "description": "Response History List", + "type": "object", + "properties": { + "status": { + "title": "Status", + "description": "Status", + "type": "string" + }, + "progress": { + "title": "Progress", + "description": "Job Progress", + "type": "string" + }, + "statusDescription": { + "title": "Statusdescription", + "description": "Status Description", + "type": "string" + }, + "errorCode": { + "title": "Errorcode", + "description": "Error Code", + "type": "string" + }, + "responseId": { + "title": "Responseid", + "description": "Response Id", + "type": "string" + } + } + }, + "JobResponseDescriptor": { + "title": "Responsedescriptor", + "description": "Job Response Descriptor", + "type": "object", + "properties": { + "status": { + "title": "Status", + "description": "Status", + "type": "string" + }, + "progress": { + "title": "Progress", + "description": "Job Progress", + "type": "string" + }, + "statusDescription": { + "title": "Statusdescription", + "description": "Status Description", + "type": "string" + }, + "errorCode": { + "title": "Errorcode", + "description": "Error Code", + "type": "string" + }, + "responseId": { + "title": "Responseid", + "description": "Response Id", + "type": "string" + }, + "responseHistoryList": { + "title": "Responsehistorylist", + "description": "Response History List", + "type": "array", + "items": { + "$ref": "#/definitions/JobResponseHistoryList" + } + } + } + }, + "GetJobResponse": { + "type": "object", + "properties": { + "jobId": { + "title": "Jobid", + "description": "Job Id", + "type": "string" + }, + "responseDescriptor": { + "$ref": "#/definitions/JobResponseDescriptor" + } + } + }, + "PostJobResponseResult": { + "required": ["result"], + "type": "object", + "properties": { + "result": { + "title": "Result", + "description": "Result", + "type": "string" + }, + "msg": { + "title": "Msg", + "description": "Message", + "type": "string" + } + } + }, + "PostJobRequest": { + "type": "object", + "properties": { + "progress": { + "title": "Progress", + "description": "Job Progress", + "type": "string" + }, + "desc": { + "title": "Desc", + "description": "Description", + "type": "string" + }, + "errcode": { + "title": "Errcode", + "description": "Error Code", + "type": "string" + } + } + }, + "NsPackageInfo": { + "title": "Packageinfo", + "description": "NS Package Info", + "type": "object", + "properties": { + "nsdId": { + "title": "Nsdid", + "description": "NSD ID", + "type": "string" + }, + "nsPackageId": { + "title": "Nspackageid", + "description": "NS Package ID", + "type": "string" + }, + "nsdProvider": { + "title": "Nsdprovider", + "description": "NSD Provider", + "type": "string" + }, + "nsdVersion": { + "title": "Nsdversion", + "description": "NSD Version", + "type": "string" + }, + "csarName": { + "title": "Csarname", + "description": "CSAR name", + "type": "string" + }, + "nsdModel": { + "title": "Nsdmodel", + "description": "NSD Model", + "type": "string" + }, + "downloadUrl": { + "title": "Downloadurl", + "description": "URL to download NSD Model", + "type": "string" + } + } + }, + "NsPackage": { + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "CSAR ID", + "type": "string" + }, + "packageInfo": { + "$ref": "#/definitions/NsPackageInfo" + } + } + }, + "InternalErrorRequest": { + "required": ["error"], + "type": "object", + "properties": { + "error": { + "title": "Error", + "description": "Error", + "type": "string" + }, + "errorMessage": { + "title": "Errormessage", + "description": "Error Message", + "type": "string" + } + } + }, + "NsPackageDistributeRequest": { + "required": ["csarId"], + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "csarId", + "type": "string" + } + } + }, + "NsPackageDistributeResponse": { + "required": ["status", "statusDescription", "errorCode"], + "type": "object", + "properties": { + "status": { + "title": "Status", + "description": "status", + "type": "string" + }, + "statusDescription": { + "title": "Statusdescription", + "description": "statusDescription", + "type": "string" + }, + "errorCode": { + "title": "Errorcode", + "description": "errorCode", + "type": "string" + } + } + }, + "ParseModelRequest": { + "required": ["csarId"], + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "CSAR ID", + "type": "string" + }, + "inputs": { + "title": "Inputs", + "description": "Inputs", + "type": "string" + } + } + }, + "ParseModelResponse": { + "required": ["model"], + "type": "object", + "properties": { + "model": { + "title": "Model", + "description": "Model", + "type": "string" + } + } + }, + "NfPackageInfo": { + "title": "Packageinfo", + "description": "VNF Package Info", + "required": ["vnfPackageId"], + "type": "object", + "properties": { + "vnfdId": { + "title": "Vnfdid", + "description": "VNFD ID", + "type": "string" + }, + "vnfPackageId": { + "title": "Vnfpackageid", + "description": "VNF Package ID", + "type": "string" + }, + "vnfdProvider": { + "title": "Vnfdprovider", + "description": "VNFD Provider", + "type": "string" + }, + "vnfdVersion": { + "title": "Vnfdversion", + "description": "VNFD Version", + "type": "string" + }, + "vnfVersion": { + "title": "Vnfversion", + "description": "VNF Version", + "type": "string" + }, + "csarName": { + "title": "Csarname", + "description": "CSAR Name", + "type": "string" + }, + "vnfdModel": { + "title": "Vnfdmodel", + "description": "VNFD Model", + "type": "string" + }, + "downloadUrl": { + "title": "Downloadurl", + "description": "URL to download VNFD Model", + "type": "string" + } + } + }, + "NfImageInfo": { + "description": "Image Info", + "required": ["index", "fileName", "imageId", "vimId", "vimUser", "tenant", "status"], + "type": "object", + "properties": { + "index": { + "title": "Index", + "description": "Index of VNF Image", + "type": "string" + }, + "fileName": { + "title": "Filename", + "description": "Image file name", + "type": "string" + }, + "imageId": { + "title": "Imageid", + "description": "Image ID", + "type": "string" + }, + "vimId": { + "title": "Vimid", + "description": "VIM ID", + "type": "string" + }, + "vimUser": { + "title": "Vimuser", + "description": "User of VIM", + "type": "string" + }, + "tenant": { + "title": "Tenant", + "description": "Tenant", + "type": "string" + }, + "status": { + "title": "Status", + "description": "Status", + "type": "string" + } + } + }, + "NfPackage": { + "required": ["csarId", "packageInfo"], + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "CSAR ID", + "type": "string" + }, + "packageInfo": { + "$ref": "#/definitions/NfPackageInfo" + }, + "imageInfo": { + "title": "Imageinfo", + "description": "Image Info", + "type": "array", + "items": { + "$ref": "#/definitions/NfImageInfo" + } + } + } + }, + "NfPackageDistributeRequest": { + "required": ["csarId"], + "type": "object", + "properties": { + "csarId": { + "title": "Csarid", + "description": "CSAR ID", + "type": "string" + }, + "vimIds": { + "title": "Vimids", + "description": "A string for vimIds", + "type": "array", + "items": { + "type": "string" + } + }, + "labVimId": { + "title": "Labvimid", + "description": "A list of VIM IDs.", + "type": "string" + } + } + }, + "PostJobResponse": { + "required": ["jobId"], + "type": "object", + "properties": { + "jobId": { + "title": "Jobid", + "description": "jobId", + "type": "string" + } + } + }, + "ProblemDetails": { + "title": "Onboardingfailuredetails", + "description": "Failure details of current onboarding procedure. It shall be present when the \"nsdOnboardingState\" attribute is CREATED and the uploading or processing fails in NFVO.", + "required": ["title", "detail"], + "type": "object", + "properties": { + "type": { + "title": "Type", + "description": "A URI reference according to IETF RFC 3986 [10] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".", + "type": "string" + }, + "title": { + "title": "Title", + "description": "The HTTP status code for this occurrence of the problem.", + "type": "integer" + }, + "detail": { + "title": "Detail", + "description": "A human-readable explanation specific to this occurrence of the problem.", + "type": "string" + }, + "instance": { + "title": "Instance", + "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.", + "type": "string" + }, + "additional_attributes": { + "title": "Additional attributes", + "description": "Any number of additional attributes, as defined in a specification or by an implementation.", + "type": "object", + "additionalProperties": { + "description": "Additional attribute", + "type": "string" + } + } + } + }, + "Link": { + "title": "Self", + "description": "URI of this resource.", + "required": ["href"], + "type": "object", + "properties": { + "href": { + "title": "Href", + "description": "URI of the referenced resource", + "type": "string" + } + } + }, + "_Link": { + "title": " links", + "description": "Links to resources related to this resource.", + "required": ["self", "nsd_content"], + "type": "object", + "properties": { + "self": { + "$ref": "#/definitions/Link" + }, + "nsd_content": { + "$ref": "#/definitions/Link" + } + } + }, + "NsdInfo": { + "required": ["id", "nsdOnboardingState", "nsdOperationalState", "nsdUsageState", "_links"], + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "Identifier of the onboarded individual NS descriptor resource. This identifier is allocated by the NFVO.", + "type": "string" + }, + "nsdId": { + "title": "Nsdid", + "description": "This identifier, which is allocated by the NSD designer, identifies the NSD in a globally unique way. It is copied from the NSD content and shall be present after the NSD content is on-boarded.", + "type": "string" + }, + "nsdName": { + "title": "Nsdname", + "description": "Name of the onboarded NSD. This information is copied from the NSD content and shall be present after the NSD content is on-boarded.", + "type": "string" + }, + "nsdVersion": { + "title": "Nsdversion", + "description": "Version of the on-boarded NSD. This information is copied from the NSD content and shall be present after the NSD content is on-boarded.", + "type": "string" + }, + "nsdDesigner": { + "title": "Nsddesigner", + "description": "Designer of the on-boarded NSD. This information is copied from the NSD content and shall be present after the NSD content is on-boarded.", + "type": "string" + }, + "nsdInvariantId": { + "title": "Nsdinvariantid", + "description": "This identifier, which is allocated by the NSD designer, identifies an NSD in a version independent manner. This information is copied from the NSD content and shall be present after the NSD content is on-boarded.", + "type": "string" + }, + "vnfPkgIds": { + "title": "Vnfpkgids", + "description": "Identifies the VNF package for the VNFD referenced by the on-boarded NS descriptor resource.", + "type": "array", + "items": { + "description": "Identifier of the VNF package", + "type": "string" + } + }, + "pnfdInfoIds": { + "title": "Pnfdinfoids", + "description": "Identifies the PnfdInfo element for the PNFD referenced by the on-boarded NS descriptor resource.", + "type": "array", + "items": { + "description": "Identifier of the PnfdInfo element", + "type": "string" + } + }, + "nestedNsdInfoIds": { + "title": "Nestednsdinfoids", + "description": "Identifies the NsdInfo element for the nested NSD referenced by the on-boarded NS descriptor resource.", + "type": "array", + "items": { + "description": "Identifier of the NsdInfo element", + "type": "string" + } + }, + "nsdOnboardingState": { + "title": "Nsdonboardingstate", + "description": "Onboarding state of the individual NS descriptor resource.", + "type": "string", + "enum": ["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"] + }, + "onboardingFailureDetails": { + "$ref": "#/definitions/ProblemDetails" + }, + "nsdOperationalState": { + "title": "Nsdoperationalstate", + "description": "Operational state of the individual NS descriptor resource. This attribute can be modified with the PATCH method.", + "type": "string", + "enum": ["ENABLED", "DISABLED"] + }, + "nsdUsageState": { + "title": "Nsdusagestate", + "description": "Usage state of the individual NS descriptor resource.", + "type": "string", + "enum": ["IN_USE", "NOT_IN_USE"] + }, + "userDefinedData": { + "title": "Userdefineddata", + "description": "User defined data for the individual NS descriptor resource. This attribute can be modified with the PATCH method.", + "type": "object", + "additionalProperties": { + "description": "Key Value Pairs", + "type": "string" + } + }, + "_links": { + "$ref": "#/definitions/_Link" + } + } + }, + "CreateNsdInfoRequest": { + "type": "object", + "properties": { + "userDefinedData": { + "title": "Userdefineddata", + "description": "User-defined data for the NS descriptor resource to be created. It shall be present when the user defined data is set for the individual NS descriptor resource to be created.", + "type": "object", + "additionalProperties": { + "description": "Key Value Pairs", + "type": "string" + } + } + } + }, + "PnfdInfo": { + "required": ["id", "pnfdOnboardingState", "pnfdUsageState", "_links"], + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "Identifier of the onboarded individual PNF descriptor resource. This identifier is allocated by the NFVO.", + "type": "string" + }, + "pnfdId": { + "title": "Pnfdid", + "description": "This identifier, which is allocated by the PNFD designer, identifies the PNFD in a globally unique way. It is copied from the PNFD content and shall be present after the PNFD content is on-boarded.", + "type": "string" + }, + "pnfdName": { + "title": "Pnfdname", + "description": "Name of the onboarded PNFD. This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.", + "type": "string" + }, + "pnfdVersion": { + "title": "Pnfdversion", + "description": "Version of the on-boarded PNFD. This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.", + "type": "string" + }, + "pnfdProvider": { + "title": "Pnfdprovider", + "description": "Provider of the on-boarded PNFD. This information is copied from the PNFD content and shall be present after the PNFD content is on-boarded.", + "type": "string" + }, + "pnfdInvariantId": { + "title": "Pnfdinvariantid", + "description": "Identifies a PNFD in a version independent manner. This attribute is invariant across versions of PNFD.", + "type": "string" + }, + "pnfdOnboardingState": { + "title": "Pnfdonboardingstate", + "description": "Onboarding state of the individual PNF descriptor resource.", + "type": "string", + "enum": ["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"] + }, + "onboardingFailureDetails": { + "$ref": "#/definitions/ProblemDetails" + }, + "pnfdUsageState": { + "title": "Pnfdusagestate", + "description": "Usage state of the individual PNF descriptor resource.", + "type": "string", + "enum": ["IN_USE", "NOT_IN_USE"] + }, + "userDefinedData": { + "title": "Userdefineddata", + "description": "User defined data for the individual PNF descriptor resource. This attribute can be modified with the PATCH method.", + "type": "object", + "additionalProperties": { + "description": "Key Value Pairs", + "type": "string" + } + }, + "_links": { + "$ref": "#/definitions/_Link" + } + } + }, + "CreatePnfdInfoRequest": { + "type": "object", + "properties": { + "userDefinedData": { + "title": "Userdefineddata", + "description": "User-defined data for the PNF descriptor resource to be created. It shall be present when the user defined data is set for the individual PNF descriptor resource to be created.", + "type": "object", + "additionalProperties": { + "description": "Key Value Pairs", + "type": "string" + } + } + } + }, + "Checksum": { + "title": "Checksum", + "description": "Checksum of the on-boarded VNF package.", + "required": ["algorithm", "hash"], + "type": "object", + "properties": { + "algorithm": { + "title": "Algorithm", + "description": "Name of the algorithm used to generate the checksum.", + "type": "string" + }, + "hash": { + "title": "Hash", + "description": "The hexadecimal value of the checksum.", + "type": "string" + } + } + }, + "VnfPackageSoftwareImageInfo": { + "description": "Information about VNF package artifacts that are software images.", + "required": ["id", "name", "provider", "version", "checksum", "containerFormat", "diskFormat", "createdAt", "minDisk", "minRam", "size", "imagePath"], + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "Identifier of the software image.", + "type": "string" + }, + "name": { + "title": "Name", + "description": "Name of the software image.", + "type": "string" + }, + "provider": { + "title": "Provider", + "description": "Provider of the software image.", + "type": "string" + }, + "version": { + "title": "Version", + "description": "Version of the software image.", + "type": "string" + }, + "checksum": { + "$ref": "#/definitions/Checksum" + }, + "containerFormat": { + "title": "Containerformat", + "description": "terminationType: Indicates whether forceful or graceful termination is requested.", + "type": "string", + "enum": ["AKI", "AMI", "ARI", "BARE", "DOCKER", "OVA", "OVF"] + }, + "diskFormat": { + "title": "Diskformat", + "description": "Disk format of a software image is the format of the underlying disk image.", + "type": "string", + "enum": ["AKI", "AMI", "ARI", "ISO", "QCOW2", "RAW", "VDI", "VHD", "VHDX", "VMDK"] + }, + "createdAt": { + "title": "Createdat", + "description": "Time when this software image was created.", + "type": "string", + "format": "date-time" + }, + "minDisk": { + "title": "Mindisk", + "description": "The minimal disk for this software image in bytes.", + "type": "integer" + }, + "minRam": { + "title": "Minram", + "description": "The minimal RAM for this software image in bytes.", + "type": "integer" + }, + "size": { + "title": "Size", + "description": "Size of this software image in bytes.", + "type": "integer" + }, + "userMetadata": { + "title": "Usermetadata", + "description": "User-defined data.", + "type": "object", + "additionalProperties": { + "description": "KeyValue Pairs", + "type": "string" + } + }, + "imagePath": { + "title": "Imagepath", + "description": "Path in the VNF package.", + "type": "string" + } + } + }, + "VnfPackageArtifactInfo": { + "description": "Information about VNF package artifacts contained in the VNF package that are not software images.", + "required": ["artifactPath", "checksum"], + "type": "object", + "properties": { + "artifactPath": { + "title": "Artifactpath", + "description": "Path in the VNF package.", + "type": "string" + }, + "checksum": { + "$ref": "#/definitions/Checksum" + }, + "metadata": { + "title": "Metadata", + "description": "The metadata of the artifact that are available in the VNF package", + "type": "object", + "additionalProperties": { + "description": "KeyValue Pairs", + "type": "string" + } + } + } + }, + "VnfPkgInfo": { + "required": ["id", "onboardingState", "operationalState", "usageState", "_links"], + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "Identifier of the on-boarded VNF package.", + "type": "string" + }, + "vnfdId": { + "title": "Vnfdid", + "description": "This identifier, which is managed by the VNF provider, identifies the VNF package and the VNFD in a globally unique way.", + "type": "string" + }, + "vnfProvider": { + "title": "Vnfprovider", + "description": "Provider of the VNF package and the VNFD.", + "type": "string" + }, + "vnfProductName": { + "title": "Vnfproductname", + "description": "Name to identify the VNF product.", + "type": "string" + }, + "vnfSoftwareVersion": { + "title": "Vnfsoftwareversion", + "description": "Software version of the VNF.", + "type": "string" + }, + "vnfdVersion": { + "title": "Vnfdversion", + "description": "The version of the VNvFD.", + "type": "string" + }, + "checksum": { + "$ref": "#/definitions/Checksum" + }, + "softwareImages": { + "title": "Softwareimages", + "description": "Information about VNF package artifacts that are software images.", + "type": "array", + "items": { + "$ref": "#/definitions/VnfPackageSoftwareImageInfo" + } + }, + "additionalArtifacts": { + "title": "Additionalartifacts", + "description": "Information about VNF package artifacts contained in the VNF package that are not software images.", + "type": "array", + "items": { + "$ref": "#/definitions/VnfPackageArtifactInfo" + } + }, + "onboardingState": { + "title": "Onboardingstate", + "description": "On-boarding state of the VNF package.", + "type": "string", + "enum": ["CREATED", "UPLOADING", "PROCESSING", "ONBOARDED"] + }, + "operationalState": { + "title": "Operationalstate", + "description": "Operational state of the VNF package.", + "type": "string", + "enum": ["ENABLED", "DISABLED"] + }, + "usageState": { + "title": "Usagestate", + "description": "Usage state of the VNF package.", + "type": "string", + "enum": ["IN_USE", "NOT_IN_USE"] + }, + "userDefinedData": { + "title": "Userdefineddata", + "description": "User defined data for the VNF package.", + "type": "object", + "additionalProperties": { + "description": "KeyValue Pairs", + "type": "string" + } + }, + "_links": { + "$ref": "#/definitions/_Link" + } + } + }, + "CreateVnfPkgInfoRequest": { + "type": "object", + "properties": { + "userDefinedData": { + "title": "Userdefineddata", + "description": "User defined data for the VNF package.", + "type": "object", + "additionalProperties": { + "description": "KeyValue Pairs", + "type": "string" + } + } + } + }, + "UploadVnfPackageFromUriRequest": { + "required": ["addressInformation"], + "type": "object", + "properties": { + "addressInformation": { + "title": "Addressinformation", + "description": "Address information of the VNF package content.", + "type": "string" + }, + "userName": { + "title": "Username", + "description": "User name to be used for authentication.", + "type": "string" + }, + "password": { + "title": "Password", + "description": "Password to be used for authentication.", + "type": "string" + } + } + } + }, + "securityDefinitions": { + "basic": { + "type": "basic" + } + } +} \ No newline at end of file diff --git a/docs/platform/APIs/CATALOG_API/index.rst b/docs/platform/APIs/CATALOG_API/index.rst new file mode 100644 index 00000000..2932389d --- /dev/null +++ b/docs/platform/APIs/CATALOG_API/index.rst @@ -0,0 +1,6 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 +.. International License. http://creativecommons.org/licenses/by/4.0 + +CATALOG API +------------ +.. swaggerv2doc:: CATALOG_API_Specification_v0.1.json \ No newline at end of file diff --git a/docs/platform/APIs/index.rst b/docs/platform/APIs/index.rst index 816bad25..f0a88a4a 100644 --- a/docs/platform/APIs/index.rst +++ b/docs/platform/APIs/index.rst @@ -41,3 +41,14 @@ GVNFM Northbound & Southbound APIs for VNF Integration VNFLCM_API/index + +CATALOG APIs +------------- + +CATALOG APIs for VNF Integration + +.. toctree:: + :maxdepth: 1 + + CATALOG_API/index + diff --git a/lcm/ns/tests/test_sol_health_check.py b/lcm/ns/tests/test_sol_health_check.py new file mode 100644 index 00000000..ccdd29cd --- /dev/null +++ b/lcm/ns/tests/test_sol_health_check.py @@ -0,0 +1,31 @@ +# Copyright 2019 ZTE Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import json + +from django.test import TestCase, Client +from rest_framework import status + + +class TestSolHealthCheck(TestCase): + def setUp(self): + self.client = Client() + + def tearDown(self): + pass + + def test_health_check(self): + response = self.client.get("/api/nslcm/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) diff --git a/lcm/ns/tests/test_sol_ns_heal_api.py b/lcm/ns/tests/test_sol_ns_heal_api.py index 8ff4ced5..ebd8ba0d 100644 --- a/lcm/ns/tests/test_sol_ns_heal_api.py +++ b/lcm/ns/tests/test_sol_ns_heal_api.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import uuid import mock from django.test import Client @@ -28,7 +29,8 @@ from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE class TestHealNsApi(TestCase): def setUp(self): self.url = "/api/nslcm/v1/ns_instances/%s/heal" - self.ns_inst_id = '1' + # self.ns_inst_id = '1' + self.ns_inst_id = str(uuid.uuid4()) self.nf_inst_id = '1' self.nf_uuid = '1-1-1' @@ -93,6 +95,8 @@ class TestHealNsApi(TestCase): self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.data) self.assertIsNotNone(response.data) self.assertIsNotNone(response['Location']) + response = self.client.get(response['Location'], format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) # add healNsData @@ -117,6 +121,8 @@ class TestHealNsApi(TestCase): response = self.client.post(self.url % self.ns_inst_id, data=data) self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code, response.data) self.assertIsNotNone(response['Location']) + response = self.client.get(response['Location'], format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) @mock.patch.object(NSHealService, "start") def test_heal_vnf_non_existing_ns(self, mock_start): diff --git a/lcm/ns/tests/test_sol_ns_scale_api.py b/lcm/ns/tests/test_sol_ns_scale_api.py index 50e7bc4a..d11570a5 100644 --- a/lcm/ns/tests/test_sol_ns_scale_api.py +++ b/lcm/ns/tests/test_sol_ns_scale_api.py @@ -198,6 +198,8 @@ class TestScaleNsApi(TestCase): response = self.client.post(self.url % self.ns_inst_id, data=data) self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code) self.assertIsNotNone(response['Location']) + response = self.client.get(response['Location'], format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) @mock.patch.object(NSManualScaleService, 'start') def test_ns_manual_scale_empty_data(self, mock_start): diff --git a/lcm/ns/tests/test_sol_ns_terminate_api.py b/lcm/ns/tests/test_sol_ns_terminate_api.py index 44de00e7..5aec52e9 100644 --- a/lcm/ns/tests/test_sol_ns_terminate_api.py +++ b/lcm/ns/tests/test_sol_ns_terminate_api.py @@ -25,7 +25,8 @@ class TestTerminateNsApi(TestCase): def setUp(self): self.client = Client() self.url = "/api/nslcm/v1/ns_instances/%s/terminate" - self.ns_inst_id = '1' + # self.ns_inst_id = '1' + self.ns_inst_id = str(uuid.uuid4()) self.nf_inst_id = '1' self.vnffg_id = str(uuid.uuid4()) self.vim_id = str(uuid.uuid4()) @@ -62,6 +63,8 @@ class TestTerminateNsApi(TestCase): response = self.client.post(self.url % self.ns_inst_id, data=req_data) self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code) self.assertIsNotNone(response['Location']) + response = self.client.get(response['Location'], format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) def test_method_not_allowed(self): response = self.client.put(self.url % '1', data={}, format='json') diff --git a/lcm/ns/urls.py b/lcm/ns/urls.py index fd826fab..1e859d3d 100644 --- a/lcm/ns/urls.py +++ b/lcm/ns/urls.py @@ -34,6 +34,7 @@ from lcm.ns.views.sol.subscriptions_view import SubscriptionsView from lcm.ns.views.sol.update_ns_view import UpdateNSView from lcm.ns.views.sol.scale_ns_views import ScaleNSView from lcm.ns.views.sol.heal_ns_view import HealNSView +from lcm.ns.views.sol.health_check import HealthCheckView urlpatterns = [ # API will be deprecated in the future release @@ -56,7 +57,10 @@ urlpatterns = [ url(r'^api/nslcm/v1/ns_instances/(?P[0-9a-zA-Z_-]+)/terminate$', TerminateNsView.as_view()), url(r'^api/nslcm/v1/ns_lcm_op_occs/(?P[0-9a-zA-Z_-]+)$', QuerySingleNsLcmOpOcc.as_view()), url(r'^api/nslcm/v1/subscriptions$', SubscriptionsView.as_view()), - url(r'^api/nslcm/v1/ns_lcm_op_occs$', QueryMultiNsLcmOpOccs.as_view()) + url(r'^api/nslcm/v1/ns_lcm_op_occs$', QueryMultiNsLcmOpOccs.as_view()), + + # health check + url(r'^api/nslcm/v1/health_check$', HealthCheckView.as_view()) ] diff --git a/lcm/ns/views/sol/health_check.py b/lcm/ns/views/sol/health_check.py new file mode 100644 index 00000000..87b99834 --- /dev/null +++ b/lcm/ns/views/sol/health_check.py @@ -0,0 +1,31 @@ +# Copyright (c) 2018, CMCC Technologies Co., Ltd. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +from drf_yasg.utils import swagger_auto_schema +from rest_framework import status +from rest_framework.response import Response +from rest_framework.views import APIView + +logger = logging.getLogger(__name__) + + +class HealthCheckView(APIView): + @swagger_auto_schema( + responses={ + status.HTTP_200_OK: 'Active'}) + def get(self, request, format=None): + logger.debug("Health check.") + return Response({"status": "active"}) diff --git a/lcm/swagger/tests.py b/lcm/swagger/tests.py index bc0c0409..deb11a0a 100644 --- a/lcm/swagger/tests.py +++ b/lcm/swagger/tests.py @@ -1,29 +1,31 @@ -# Copyright 2016-2017 ZTE Corporation. +# Copyright (C) 2019 ZTE. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# http://www.apache.org/licenses/LICENSE-2.0 +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# import json -from django.test import TestCase +# See the License for the specific language governing permissions and +# limitations under the License. -from rest_framework.test import APIClient -# from rest_framework import status +from django.test import TestCase +from django.test import Client +from rest_framework import status -class SwaggerViewTest(TestCase): +class TestSwagger(TestCase): def setUp(self): - self.client = APIClient() + self.client = Client() def tearDown(self): pass - # def test_swagger(self): - # response = self.client.get("/api/nslcm/v1/swagger.json") - # self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) - # with open('vfc.json', 'w') as swagger_file: - # swagger_file.write(json.dumps(response.data)) + def test_swagger_json(self): + url = "/api/nslcm/v1/swagger.json" + response = self.client.get(url, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual("2.0", response.data.get("swagger")) diff --git a/resources/bin/initDB.sh b/resources/bin/initDB.sh index 01bb1561..7c0fa02a 100644 --- a/resources/bin/initDB.sh +++ b/resources/bin/initDB.sh @@ -26,10 +26,10 @@ sql_path=$HOME/../ mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -P$MYSQL_PORT -h$MYSQL_IP <$sql_path/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql sql_result=$? if [ $sql_result -ne 0 ] ; then - echo "failed to create vfcnfvolcm database" + echo "Failed to create vfcnfvolcm database" exit 1 -elif [ $sql_result -eq 0 ]; then - echo "create vfcnfvolcm database successfully" +else + echo "Create vfcnfvolcm database successfully" exit 0 fi diff --git a/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql b/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql index 94e630b5..bd90a1fa 100644 --- a/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql +++ b/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql @@ -14,14 +14,10 @@ -- limitations under the License. -- -/******************drop old database and user***************************/ +/******************create database and user***************************/ use mysql; -drop database IF EXISTS vfcnfvolcm; -delete from user where User='vfcnfvolcm'; -FLUSH PRIVILEGES; +create database if not exists vfcnfvolcm CHARACTER SET utf8; -/******************create new database and user***************************/ -create database vfcnfvolcm CHARACTER SET utf8; GRANT ALL PRIVILEGES ON vfcnfvolcm.* TO 'vfcnfvolcm'@'%' IDENTIFIED BY 'vfcnfvolcm' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON mysql.* TO 'vfcnfvolcm'@'%' IDENTIFIED BY 'vfcnfvolcm' WITH GRANT OPTION;