summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/biz/create_vnf.py6
-rw-r--r--lcm/lcm/nf/serializers/terminate_vnf_req.py27
-rw-r--r--lcm/lcm/nf/tests/test_create_vnf.py12
-rw-r--r--lcm/lcm/nf/views/curd_vnf_views.py13
-rw-r--r--lcm/lcm/swagger/swagger.json1067
-rw-r--r--lcm/lcm/swagger/tests.py30
-rw-r--r--lcm/lcm/swagger/urls.py1
-rw-r--r--lcm/lcm/swagger/views.py26
8 files changed, 45 insertions, 1137 deletions
diff --git a/lcm/lcm/nf/biz/create_vnf.py b/lcm/lcm/nf/biz/create_vnf.py
index cf5435ad..de857b61 100644
--- a/lcm/lcm/nf/biz/create_vnf.py
+++ b/lcm/lcm/nf/biz/create_vnf.py
@@ -47,15 +47,15 @@ class CreateVnf:
def save_db(self):
metadata = ignore_case_get(self.vnfd_info, "metadata")
- version = ignore_case_get(metadata, "vnfdVersion")
- vendor = ignore_case_get(metadata, "vendor")
+ version = ignore_case_get(metadata, "csarVersion")
+ provider = ignore_case_get(metadata, "csarProvider")
netype = ignore_case_get(metadata, "type")
vnfsoftwareversion = ignore_case_get(metadata, "version")
NfInstModel.objects.create(nfinstid=self.nf_inst_id,
nf_name=self.vnf_instance_mame,
package_id=self.csar_id,
version=version,
- vendor=vendor,
+ vendor=provider,
netype=netype,
vnfd_model=self.vnfd_info,
status='NOT_INSTANTIATED',
diff --git a/lcm/lcm/nf/serializers/terminate_vnf_req.py b/lcm/lcm/nf/serializers/terminate_vnf_req.py
new file mode 100644
index 00000000..805ef6b3
--- /dev/null
+++ b/lcm/lcm/nf/serializers/terminate_vnf_req.py
@@ -0,0 +1,27 @@
+# Copyright 2018 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.
+
+from rest_framework import serializers
+
+
+class TerminateVnfRequestSerializer(serializers.Serializer):
+ terminationType = serializers.ChoiceField(
+ help_text="terminationType: Indicates whether forceful or graceful termination is requested.",
+ choices=["FORCEFUL", "GRACEFUL"],
+ required=True,
+ allow_null=True)
+ gracefulTerminationTimeout = serializers.IntegerField(
+ help_text="This attribute is only applicable in case of graceful termination",
+ default=120,
+ required=False)
diff --git a/lcm/lcm/nf/tests/test_create_vnf.py b/lcm/lcm/nf/tests/test_create_vnf.py
index 368b22f7..afeedb31 100644
--- a/lcm/lcm/nf/tests/test_create_vnf.py
+++ b/lcm/lcm/nf/tests/test_create_vnf.py
@@ -22,6 +22,7 @@ from lcm.nf.const import vnfpackage_info
from lcm.pub.database.models import NfInstModel, JobStatusModel
from lcm.pub.utils import restcall
from lcm.pub.utils.timeutil import now_time
+import uuid
class TestNFInstantiate(TestCase):
@@ -64,15 +65,16 @@ class TestNFInstantiate(TestCase):
self.assertEqual({'error': 'VNF is already exist.'}, context)
@mock.patch.object(restcall, 'call_req')
- def test_create_vnf_identifier(self, mock_call_req):
+ @mock.patch.object(uuid, 'uuid4')
+ def test_create_vnf_identifier(self, mock_uuid4, mock_call_req):
r2_get_vnfpackage_from_catalog = [0, json.JSONEncoder().encode(vnfpackage_info), '200']
- mock_call_req.side_effect = [r2_get_vnfpackage_from_catalog]
+ mock_call_req.return_value = r2_get_vnfpackage_from_catalog
+ mock_uuid4.return_value = "1"
data = {
"vnfdId": "111",
"vnfInstanceName": "vFW_01",
"vnfInstanceDescription": "vFW in Nanjing TIC Edge"
}
response = self.client.post("/api/vnflcm/v1/vnf_instances", data=data, format='json')
- self.failUnlessEqual(status.HTTP_201_CREATED, response.status_code)
- context = json.loads(response.content)
- self.assertTrue(NfInstModel.objects.filter(nfinstid=context['vnfInstanceId']).exists())
+ expect_data = {"id": "1", "vnfProvider": "huawei", "vnfdVersion": "1.0", "vnfPkgId": "111"}
+ self.assertEqual(expect_data, response.data)
diff --git a/lcm/lcm/nf/views/curd_vnf_views.py b/lcm/lcm/nf/views/curd_vnf_views.py
index 7419e69f..078053a8 100644
--- a/lcm/lcm/nf/views/curd_vnf_views.py
+++ b/lcm/lcm/nf/views/curd_vnf_views.py
@@ -23,7 +23,7 @@ from rest_framework.views import APIView
from lcm.nf.biz.create_vnf import CreateVnf
from lcm.nf.biz.query_vnf import QueryVnf
-from lcm.nf.serializers.serializers import CreateVnfReqSerializer, CreateVnfRespSerializer
+from lcm.nf.serializers.create_vnf_req import CreateVnfReqSerializer
from lcm.nf.serializers.vnf_instance import VnfInstanceSerializer
from lcm.nf.serializers.vnf_instances import VnfInstancesSerializer
from lcm.pub.exceptions import NFLCMException
@@ -57,9 +57,9 @@ class CreateVnfAndQueryVnfs(APIView):
return Response(data={'error': 'Failed to get Vnfs'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@swagger_auto_schema(
- request_body=CreateVnfReqSerializer(),
+ request_body=VnfInstanceSerializer(),
responses={
- status.HTTP_201_CREATED: CreateVnfRespSerializer(),
+ status.HTTP_201_CREATED: VnfInstanceSerializer(),
status.HTTP_500_INTERNAL_SERVER_ERROR: "Internal error"
}
)
@@ -70,8 +70,11 @@ class CreateVnfAndQueryVnfs(APIView):
if not req_serializer.is_valid():
raise NFLCMException(req_serializer.errors)
- nf_inst_id = CreateVnf(req_serializer.data).do_biz().nfinstid
- create_vnf_resp_serializer = CreateVnfRespSerializer(data={"vnfInstanceId": nf_inst_id})
+ nf_inst = CreateVnf(req_serializer.data).do_biz()
+ create_vnf_resp_serializer = VnfInstanceSerializer(data={"id": nf_inst.nfinstid,
+ "vnfProvider": nf_inst.vendor,
+ "vnfdVersion": nf_inst.version,
+ "vnfPkgId": nf_inst.package_id})
if not create_vnf_resp_serializer.is_valid():
raise NFLCMException(create_vnf_resp_serializer.errors)
return Response(data=create_vnf_resp_serializer.data, status=status.HTTP_201_CREATED)
diff --git a/lcm/lcm/swagger/swagger.json b/lcm/lcm/swagger/swagger.json
deleted file mode 100644
index f098d282..00000000
--- a/lcm/lcm/swagger/swagger.json
+++ /dev/null
@@ -1,1067 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "version": "1.0.0",
- "title": "VNF Manager LCM Service rest API"
- },
- "basePath": "/api/vnflcm/v1",
- "tags": [
- {
- "name": "lcm Resource"
- }
- ],
- "paths": {
- "/vnf_instances": {
- "post": {
- "tags": [
- "lcm Resource"
- ],
- "summary": "Create a VNF instance resource",
- "description": "Create a VNF instance resource",
- "operationId": "CreateVnf",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "in": "body",
- "name": "body",
- "description": "The request params to create a VNF instance",
- "required": true,
- "schema": {
- "$ref": "#/definitions/CreateVnfRequest"
- }
- }
- ],
- "responses": {
- "201": {
- "description": "A VNF Instance identifier was created successfully.",
- "schema": {
- "$ref": "#/definitions/CreateVnfResponse"
- }
- },
- "401": {
- "description": "Unauthorized."
- },
- "500": {
- "description": "Failed to process the request",
- "schema": {
- "$ref": "#/definitions/Error"
- }
- }
- }
- },
- "get": {
- "tags": [
- "lcm Resource"
- ],
- "summary": "Query multiple VNF instances",
- "description": "Query multiple VNF instances",
- "operationId": "QueryMultipleVnf",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [],
- "responses": {
- "200": {
- "description": "The request has succeeded.",
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/VnfInstanceInfo"
- }
- }
- },
- "401": {
- "description": "Unauthorized."
- },
- "500": {
- "description": "Failed to process the request",
- "schema": {
- "$ref": "#/definitions/Error"
- }
- }
- }
- }
- },
- "/vnf_instances/{vnfInstanceId}": {
- "delete": {
- "tags": [
- "lcm Resource"
- ],
- "summary": "Delete a VNF instance resource",
- "description": "Delete a VNF instance resource",
- "operationId": "DeleteVnf",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "in": "path",
- "name": "vnfInstanceId",
- "description": "Identifier of the VNF instance.",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "204": {
- "description": "The VNF instance resource and the associated VNF identifier were deleted successfully."
- },
- "401": {
- "description": "Unauthorized."
- },
- "404": {
- "description": "The VNF instance resource does not exist."
- },
- "500": {
- "description": "Failed to process the request",
- "schema": {
- "$ref": "#/definitions/Error"
- }
- }
- }
- },
- "get": {
- "tags": [
- "lcm Resource"
- ],
- "summary": "Query a VNF instance",
- "description": "Query a VNF instance",
- "operationId": "QuerySingleVnfs",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "in": "path",
- "name": "vnfInstanceId",
- "description": "Identifier of the VNF instance.",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "The request has succeeded.",
- "schema": {
- "$ref": "#/definitions/VnfInstanceInfo"
- }
- },
- "401": {
- "description": "Unauthorized."
- },
- "404": {
- "description": "The VNF instance resource does not exist."
- },
- "500": {
- "description": "Failed to process the request",
- "schema": {
- "$ref": "#/definitions/Error"
- }
- }
- }
- }
- },
- "/vnf_instances/{vnfInstanceId}/instantiate": {
- "post": {
- "tags": [
- "lcm Resource"
- ],
- "summary": "Instantiate a VNF",
- "description": "Instantiate a VNF",
- "operationId": "InstantiateVnf",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "in": "path",
- "name": "vnfInstanceId",
- "description": "Identifier of the VNF instance.",
- "required": true,
- "type": "string"
- },
- {
- "in": "body",
- "name": "body",
- "description": "The request params to instantiate a VNF",
- "required": true,
- "schema": {
- "$ref": "#/definitions/InstantiateVnfRequest"
- }
- }
- ],
- "responses": {
- "202": {
- "description": "The request is accepted for processing, but the processing has not been completed.",
- "schema": {
- "$ref": "#/definitions/VnfLcOpIdResponse"
- }
- },
- "401": {
- "description": "Unauthorized."
- },
- "404": {
- "description": "The VNF instance resource does not exist."
- },
- "500": {
- "description": "Failed to process the request",
- "schema": {
- "$ref": "#/definitions/Error"
- }
- }
- }
- }
- },
- "/vnf_instances/{vnfInstanceId}/terminate": {
- "post": {
- "tags": [
- "lcm Resource"
- ],
- "summary": "Terminate a VNF",
- "description": "Terminate a VNF",
- "operationId": "TerminateVnf",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "in": "path",
- "name": "vnfInstanceId",
- "description": "Identifier of the VNF instance.",
- "required": true,
- "type": "string"
- },
- {
- "in": "body",
- "name": "body",
- "description": "The request params to terminate a VNF",
- "required": true,
- "schema": {
- "$ref": "#/definitions/TerminateVnfRequest"
- }
- }
- ],
- "responses": {
- "202": {
- "description": "The request is accepted for processing, but the processing has not been completed.",
- "schema": {
- "$ref": "#/definitions/VnfLcOpIdResponse"
- }
- },
- "401": {
- "description": "Unauthorized."
- },
- "404": {
- "description": "The VNF instance resource does not exist."
- },
- "500": {
- "description": "Failed to process the request",
- "schema": {
- "$ref": "#/definitions/Error"
- }
- }
- }
- }
- },
- "/vnf_lc_ops/{vnfLcOpId}": {
- "get": {
- "tags": [
- "lcm Resource"
- ],
- "summary": "Get VNF operational status",
- "description": "VNF operational status",
- "operationId": "QuerySingleVnfLcOp",
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "parameters": [
- {
- "name": "vnfLcOpId",
- "in": "path",
- "description": "Identifier of a VNF lifecycle operation occurrence",
- "required": true,
- "type": "string"
- },
- {
- "name": "responseId",
- "in": "query",
- "description": "Response Identifier",
- "required": true,
- "type": "string"
- }
- ],
- "responses": {
- "200": {
- "description": "The request has succeeded.",
- "schema": {
- "$ref": "#/definitions/VnfLcOpOcc"
- }
- },
- "401": {
- "description": "Unauthorized."
- },
- "404": {
- "description": "The VNF lifecycle operation occurrence does not exist."
- },
- "500": {
- "description": "Failed to process the request",
- "schema": {
- "$ref": "#/definitions/Error"
- }
- }
- }
- }
- }
- },
- "definitions": {
- "CreateVnfRequest": {
- "type": "object",
- "required": [
- "vnfdId",
- "vnfInstanceName"
- ],
- "properties": {
- "vnfdId": {
- "type": "string",
- "description": "Identifier that identifies the VNFD which defines the VNF instance to be created."
- },
- "vnfInstanceName": {
- "type": "string",
- "description": "Human-readable name of the VNF instance to be created."
- },
- "vnfInstanceDescription": {
- "type": "string",
- "description": "Human-readable description of the VNF instance to be created."
- }
- }
- },
- "CreateVnfResponse": {
- "type": "object",
- "required": [
- "vnfInstanceId"
- ],
- "properties": {
- "vnfInstanceId": {
- "type": "string",
- "description": "VNF instance identifier just created."
- }
- }
- },
- "InstantiateVnfRequest": {
- "type": "object",
- "required": [
- "flavourId"
- ],
- "properties": {
- "flavourId": {
- "type": "string",
- "description": "Identifier of the VNF deployment flavour to be instantiated."
- },
- "instantiationLevelId": {
- "type": "string",
- "description": "Identifier of the instantiation level of the deployment flavour to be instantiated. If not present, the default instantiation level as declared in the VNFD is instantiated."
- },
- "extVirtualLinks": {
- "items": {
- "$ref": "#/definitions/ExtVirtualLinkData"
- },
- "description": "Information about external VLs to connect the VNF to."
- },
- "localizationLanguage": {
- "type": "string",
- "description": "Localization language of the VNF to be instantiated can be declared in the VNFD. The value shall comply with the format defined in IETF RFC 5646 [6]. "
- },
- "additionalParams": {
- "type": "object",
- "description": "Additional input parameters for the instantiation process, specific to the VNF being instantiated."
- }
- }
- },
- "TerminateVnfRequest": {
- "type": "object",
- "required": [
- "terminationType"
- ],
- "properties": {
- "terminationType": {
- "type": "string",
- "description": "Indicates whether forceful or graceful termination is requested.",
- "enum": [
- "FORCEFUL",
- "GRACEFUL"
- ]
- },
- "gracefulTerminationTimeout": {
- "type": "integer",
- "format": "int32",
- "minimum": "1",
- "description": "This attribute is only applicable in case of graceful termination. It defines the time to wait for the VNF to be taken out of service before shutting down the VNF and releasing the resources. The unit is seconds. If not given and the \"terminationType\" attribute is set to \"GRACEFUL\", it is expected that the VNFM waits for the successful taking out of service of the VNF, no matter how long it takes, before shutting down the VNF and releasing the resources."
- }
- }
- },
- "VnfLcOpIdResponse": {
- "type": "object",
- "description": "VNF lifecycle operation occurrence identifier response",
- "required": [
- "vnfLcOpId"
- ],
- "properties": {
- "vnfLcOpId": {
- "type": "string",
- "description": "Identifier of a VNF lifecycle operation occurrence"
- }
- }
- },
- "ExtVirtualLinkData": {
- "type": "object",
- "required": [
- "resourceId",
- "extCps"
- ],
- "properties": {
- "extVirtualLinkId": {
- "type": "string",
- "description": "Identifier of the VL instance."
- },
- "vim": {
- "$ref": "#/definitions/VimInfo",
- "description": "Information about the VIM that manages this resource. This attribute shall be supported and present if VNF-related resource management in direct mode is applicable."
- },
- "resourceId": {
- "type": "string",
- "description": "The network UUID of VIM"
- },
- "extCps": {
- "type": "array",
- "description": "External CPs of the VNF to be connected to this external VL.",
- "items": {
- "$ref": "#/definitions/VnfExtCpData"
- }
- }
- }
- },
- "VimInfo": {
- "type": "object",
- "required": [
- "vimInfoId",
- "vimId",
- "interfaceInfo",
- "accessInfo",
- "interfaceEndpoint"
- ],
- "properties": {
- "vimInfoId": {
- "type": "string",
- "description": "The identifier of this VimInfo instance, for the purpose of referencing it from other information elements."
- },
- "vimId": {
- "type": "string",
- "description": "The identifier of the VIM."
- },
- "interfaceInfo": {
- "$ref": "#/definitions/InterfaceInfo",
- "description": "Information about the interface to the VIM, including VIM provider type, API version, and protocol type."
- },
- "accessInfo": {
- "$ref": "#/definitions/AccessInfo",
- "description": "Authentication credentials for accessing the VIM. Examples may include those to support different authentication schemes, e.g., OAuth, Token, etc. "
- },
- "interfaceEndpoint": {
- "type": "string",
- "description": "Information about the interface endpoint. An example is a URL."
- }
- }
- },
- "InterfaceInfo": {
- "type": "object",
- "required": [
- "vimType",
- "apiVersion",
- "protocolType"
- ],
- "properties": {
- "vimType": {
- "type": "string",
- "description": "The type of the VIM."
- },
- "apiVersion": {
- "type": "string",
- "description": "The Version of the api of the VIM."
- },
- "protocolType": {
- "type": "string",
- "enum": [
- "http",
- "https"
- ]
- }
- }
- },
- "AccessInfo": {
- "type": "object",
- "required": [
- "tenant",
- "username",
- "password"
- ],
- "properties": {
- "tenant": {
- "type": "string",
- "description": "Tenant Name of tenant"
- },
- "username": {
- "type": "string",
- "description": "Username for login"
- },
- "password": {
- "type": "string",
- "description": "Password of login user"
- }
- }
- },
- "VnfExtCpData": {
- "type": "object",
- "required": [
- "cpdId"
- ],
- "properties": {
- "cpdId": {
- "type": "string",
- "description": "The identifier of the CPD in the VNFD."
- },
- "addresses": {
- "type": "array",
- "description": "List of (fixed) network addresses that need to be configured on the CP. This attribute shall be present if fixed addresses need to be configured.",
- "items": {
- "$ref": "#/definitions/NetworkAddress"
- }
- },
- "numDynamicAddresses": {
- "type": "integer",
- "format": "int32",
- "description": "Number of network addresses to be assigned dynamically. This attribute shall be present if dynamic addresses need to be configured."
- }
- }
- },
- "NetworkAddress": {
- "type": "object",
- "required": [
- "addressType"
- ],
- "properties": {
- "addressType": {
- "type": "string",
- "description": "Describes the type of the address to be assigned to the CP instantiated from the parent CPD.",
- "enum": [
- "MAC",
- "IP"
- ]
- },
- "l2AddressData": {
- "type": "string",
- "description": "Provides the information on the MAC addresses to be assigned to the CP(s) instantiated from the parent CPD. Shall be present when the addressType is MAC address."
- },
- "l3AddressData": {
- "$ref": "#/definitions/L3AddressData",
- "description": "Provides the information on the IP addresses to be assigned to the CP instantiated from the parent CPD. Shall be present when the addressType is IP address."
- }
- }
- },
- "L3AddressData": {
- "type": "object",
- "required": [
- "iPAddressType",
- "iPAddress"
- ],
- "properties": {
- "iPAddressType": {
- "type": "string",
- "description": "IP address type",
- "enum": [
- "IPv4",
- "IPv6"
- ]
- },
- "iPAddress": {
- "type": "string",
- "description": "IP address"
- }
- }
- },
- "VnfInstanceInfo": {
- "type": "object",
- "required": [
- "vnfInstanceId",
- "vnfInstanceName",
- "vnfInstanceDescription",
- "onboardedVnfPkgInfoId",
- "vnfdId",
- "vnfdVersion",
- "vnfSoftwareVersion",
- "vnfProvider",
- "vnfProductName",
- "instantiationState"
- ],
- "properties": {
- "vnfInstanceId": {
- "type": "string",
- "description": "VNF instance identifier."
- },
- "vnfInstanceName": {
- "type": "string",
- "description": "VNF instance name."
- },
- "vnfInstanceDescription": {
- "type": "string",
- "description": "Human-readable description of the VNF instance."
- },
- "onboardedVnfPkgInfoId": {
- "type": "string",
- "description": "Identifier of information held by the NFVO about the specific VNF Package on which the VNF is based. This identifier was allocated by the NFVO."
- },
- "vnfdId": {
- "type": "string",
- "description": "Identifier of the VNFD on which the VNF instance is based."
- },
- "vnfdVersion": {
- "type": "string",
- "description": "Identifies the version of the VNFD. The value is copied from the VNFD."
- },
- "vnfSoftwareVersion": {
- "type": "string",
- "description": "Software version of the VNF. The value is copied from the VNFD."
- },
- "vnfProvider": {
- "type": "string",
- "description": "Name of the person or company providing the VNF. The value is copied from the VNFD."
- },
- "vnfProductName": {
- "type": "string",
- "description": "Name to identify the VNF Product. Such as VNF Application Type. The value is copied from the VNFD."
- },
- "instantiationState": {
- "type": "string",
- "description": "The instantiation state of the VNF.",
- "enum": [
- "NOT_INSTANTIATED",
- "INSTANTIATED"
- ]
- },
- "vnfConfigurableProperties": {
- "type": "object",
- "description": "Current values of the configurable properties of the VNF instance. Configurable properties as declared in the VNFD."
- },
- "metadata": {
- "type": "object",
- "description": "Additional metadata describing the VNF instance. This attribute can be modified with the Modify VNF information operation."
- },
- "extensions": {
- "type": "object",
- "description": "VNF-specific attributes. This attribute can be modified with the Modify VNF information operation."
- },
- "instantiatedVnfInfo": {
- "$ref": "#/definitions/InstantiatedVnfInfo",
- "description": "Information specific to an instantiated VNF instance. This attribute shall be present if the instantiateState attribute value is INSTANTIATED."
- }
- }
- },
- "InstantiatedVnfInfo": {
- "type": "object",
- "required": [
- "flavourId",
- "vnfState"
- ],
- "properties": {
- "flavourId": {
- "type": "string",
- "description": "Identifier of the VNF deployment flavour to be instantiated."
- },
- "vnfState": {
- "type": "string",
- "description": "State of the VNF instance",
- "enum": [
- "STARTED",
- "STOPPED"
- ]
- },
- "scaleStatus": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/ScaleInfo"
- },
- "description": "Scale status of the VNF, one entry per aspect. Represents for every scaling aspect how \"big\" the VNF has been scaled w.r.t. that aspect. This attribute shall be present if the VNF supports scaling."
- },
- "extCpInfo": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/CpInfo"
- },
- "description": "Information about the external CPs exposed by the VNF instance."
- },
- "extVirtualLink": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/ExtVirtualLinkInfo"
- },
- "description": "Information about the external VLs the VNF instance is connected to."
- },
- "monitoringParameters": {
- "type": "object",
- "description": "Active monitoring parameters."
- },
- "localizationLanguage": {
- "type": "string",
- "description": "Localization language of the VNF to be instantiated."
- },
- "vimInfo": {
- "type": "array",
- "description": "Information about VIM(s) managing resources for the VNF instance. This attribute shall be supported and present if VNF-related resource management in direct mode is applicable.",
- "items": {
- "$ref": "#/definitions/VimInfo"
- }
- },
- "vnfcResourceInfo": {
- "type": "array",
- "description": "Information about the virtualised compute and storage resource(s) used by the VNFCs of the VNF instance. This attribute shall be supported and present if VNF-related resource management in direct mode is applicable.",
- "items": {
- "$ref": "#/definitions/VnfcResourceInfo"
- }
- },
- "virtualLinkResourceInfo": {
- "type": "array",
- "description": "Information about the virtualised network resource(s) used by the VLs of the VNF instance. This attribute shall be supported and present if VNF-related resource management in direct mode is applicable. ",
- "items": {
- "$ref": "#/definitions/VirtualLinkResourceInfo"
- }
- },
- "virtualStorageResourceInfo": {
- "type": "array",
- "description": "Information about the virtualised storage resource(s) used as storage for the VNF instance. This attribute shall be supported and present if VNF-related resource management in direct mode is applicable.",
- "items": {
- "$ref": "#/definitions/VirtualStorageResourceInfo"
- }
- }
- }
- },
- "ScaleInfo": {
- "type": "object",
- "required": [
- "aspectId",
- "scaleLevel"
- ],
- "properties": {
- "aspectId": {
- "type": "string",
- "description": "Identifier of the scaling aspect."
- },
- "scaleLevel": {
- "type": "integer",
- "format": "int32",
- "description": "Indicates the scale level. The minimum value shall be 0 and the maximum value shall be <= maxScaleLevel as described in the VNFD."
- }
- }
- },
- "CpInfo": {
- "type": "object",
- "required": [
- "cpInstanceId",
- "cpdId"
- ],
- "properties": {
- "cpInstanceId": {
- "type": "string",
- "description": "Identifier of the CP instance."
- },
- "cpdId": {
- "type": "string",
- "description": "Identifier of the CPD, in the VNFD."
- },
- "addresses": {
- "type": "array",
- "description": "List of network addresses that have been configured on the CP.",
- "items": {
- "$ref": "#/definitions/NetworkAddress"
- }
- }
- }
- },
- "ExtVirtualLinkInfo": {
- "type": "object",
- "required": [
- "extVirtualLinkId",
- "resourceHandle"
- ],
- "properties": {
- "extVirtualLinkId": {
- "type": "string",
- "description": "Identifier of the external VL."
- },
- "resourceHandle": {
- "$ref": "#/definitions/ResourceHandle",
- "description": "Identifier of the resource realizing this VL."
- },
- "linkPorts": {
- "type": "array",
- "description": "Link ports of this VL.",
- "items": {
- "$ref": "#/definitions/VnfLinkPort"
- }
- }
- }
- },
- "ResourceHandle": {
- "type": "object",
- "required": [
- "resourceId"
- ],
- "properties": {
- "vimId": {
- "type": "string",
- "description": "Identifier of the VimInfo information element defining the VIM who manages the resource. This attribute shall be present if VNF-related resource management in direct mode is applicable. The value refers to a vimInfo item in the VnfInstance."
- },
- "resourceProviderId": {
- "type": "string",
- "description": "Identifier of the entity responsible for the management of the resource. This attribute shall be present when VNF-related resource management in indirect mode is applicable. "
- },
- "resourceId": {
- "type": "string",
- "description": "Identifier of the resource in the scope of the VIM or the resource provider."
- }
- }
- },
- "VnfcResourceInfo": {
- "type": "object",
- "required": [
- "vnfcInstanceId",
- "vduId",
- "computeResource",
- "storageResourceIds"
- ],
- "properties": {
- "vnfcInstanceId": {
- "type": "string",
- "description": "Identifier of this VNFC instance."
- },
- "vduId": {
- "type": "string",
- "description": "Reference to the applicable VDU information element in the VNFD."
- },
- "computeResource": {
- "$ref": "#/definitions/ResourceHandle",
- "description": "Reference to the VirtualCompute resource."
- },
- "storageResourceIds": {
- "type": "array",
- "description": "Reference(s) to the VirtualStorage resource(s).",
- "items": {
- "type": "string"
- }
- }
- }
- },
- "VirtualStorageResourceInfo": {
- "type": "object",
- "required": [
- "virtualStorageInstanceId",
- "virtualStorageDescId",
- "storageResource"
- ],
- "properties": {
- "virtualStorageInstanceId": {
- "type": "string",
- "description": "Identifier of this virtual storage resource instance."
- },
- "virtualStorageDescId": {
- "type": "string",
- "description": "Identifier of the VirtualStorageDesc in the VNFD."
- },
- "storageResource": {
- "$ref": "#/definitions/ResourceHandle",
- "description": "Reference to the VirtualStorage resource."
- }
- }
- },
- "VirtualLinkResourceInfo": {
- "type": "object",
- "required": [
- "virtualLinkInstanceId",
- "virtualLinkDescId",
- "networkResource"
- ],
- "properties": {
- "virtualLinkInstanceId": {
- "type": "string",
- "description": "Identifier of this VL instance."
- },
- "virtualLinkDescId": {
- "type": "string",
- "description": "Identifier of the Virtual Link Descriptor (VLD) in the VNFD."
- },
- "networkResource": {
- "$ref": "#/definitions/ResourceHandle",
- "description": "Reference to the VirtualNetwork resource."
- }
- }
- },
- "VnfLcOpOcc": {
- "type": "object",
- "description": "VNF lifecycle operation response",
- "required": [
- "vnfLcOpId",
- "vnfInstanceId",
- "lcmOperationType",
- "startTime",
- "responseDescriptor"
- ],
- "properties": {
- "vnfLcOpId": {
- "type": "string",
- "description": "Identifier of a VNF lifecycle operation occurrence"
- },
- "vnfInstanceId": {
- "type": "string",
- "description": "Identifier of the VNF instance to which the operation applies"
- },
- "lcmOperationType": {
- "type": "string",
- "description": "Type of the actual LCM operation represented by this lcm operation occurrence.",
- "enum": [
- "INSTANTIATE",
- "SCALE",
- "SCALE_TO_LEVEL",
- "CHANGE_FLAVOUR",
- "TERMINATE",
- "HEAL",
- "OPERATE"
- ]
- },
- "startTime": {
- "type": "string",
- "description": "Date-time of the start of the operation. Representation: String formatted according to RFC 3339 [13]."
- },
- "responseDescriptor": {
- "type": "#/definitions/VnfLcOpResponseDescriptor",
- "description": "Including:responseId,progress,statusstatusDescription,errorCode,responseHistoryList"
- }
- }
- },
- "VnfLcOpResponseDescriptor": {
- "type": "object",
- "description": "VNF lifecycle operation response",
- "required": [
- "responseId",
- "progress",
- "lcmOperationStatus",
- "statusDescription",
- "responseHistoryList"
- ],
- "properties": {
- "responseId": {
- "type": "integer",
- "description": "Response Identifier."
- },
- "progress": {
- "type": "integer",
- "description": "progress (1-100)."
- },
- "lcmOperationStatus": {
- "type": "string",
- "description": "Vnf lifecycle operation Status.",
- "enum": [
- "STARTING",
- "PROCESSING",
- "COMPLETED",
- "FAILED"
- ]
- },
- "statusDescription": {
- "type": "string",
- "description": "Status Description of a VNF lifecycle operation occurrence"
- },
- "errorCode": {
- "type": "integer",
- "description": "Error code."
- },
- "responseHistoryList": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/VnfLcOpDetail"
- }
- }
- }
- },
- "VnfLcOpDetail": {
- "type": "object",
- "description": "The Detail of VNF lifecycle operation",
- "required": [
- "responseId",
- "progress",
- "lcmOperationStatus",
- "statusDescription"
- ],
- "properties": {
- "responseId": {
- "type": "integer",
- "description": "Response Identifier."
- },
- "progress": {
- "type": "integer",
- "description": "progress (1-100)."
- },
- "lcmOperationStatus": {
- "type": "string",
- "description": "Vnf lifecycle operation Status.",
- "enum": [
- "STARTING",
- "PROCESSING",
- "COMPLETED",
- "FAILED"
- ]
- },
- "statusDescription": {
- "type": "string",
- "description": "Status Description of a VNF lifecycle operation occurrence"
- },
- "errorCode": {
- "type": "integer",
- "description": "Error code."
- }
- }
- },
- "Error": {
- "type": "object",
- "properties": {
- "code": {
- "type": "integer",
- "format": "int32"
- },
- "message": {
- "type": "string"
- }
- }
- }
- }
-}
diff --git a/lcm/lcm/swagger/tests.py b/lcm/lcm/swagger/tests.py
deleted file mode 100644
index f65f6990..00000000
--- a/lcm/lcm/swagger/tests.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2017 ZTE Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import unittest
-
-from django.test import Client
-from rest_framework import status
-
-
-class SwaggerViewTest(unittest.TestCase):
- def setUp(self):
- self.client = Client()
-
- def tearDown(self):
- pass
-
- def test_swagger(self):
- response = self.client.get("/api/vnflcm/v1/swagger.json")
- self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
diff --git a/lcm/lcm/swagger/urls.py b/lcm/lcm/swagger/urls.py
index b521a334..14ebc194 100644
--- a/lcm/lcm/swagger/urls.py
+++ b/lcm/lcm/swagger/urls.py
@@ -35,7 +35,6 @@ SchemaView = get_schema_view(
)
urlpatterns = [
- # url(r'^api/vnflcm/v1/swagger.json$', views.SwaggerView.as_view()),
url(r'^api/vnflcm/v1/swagger(?P<format>.json|.yaml)$', SchemaView.without_ui(cache_timeout=0), name='schema-json'),
url(r'^api/vnflcm/v1/swagger$', SchemaView.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
url(r'^api/vnflcm/v1/redoc$', SchemaView.with_ui('redoc', cache_timeout=0), name='schema-redoc')
diff --git a/lcm/lcm/swagger/views.py b/lcm/lcm/swagger/views.py
deleted file mode 100644
index 400d6dd1..00000000
--- a/lcm/lcm/swagger/views.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2017 ZTE Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-import os
-import json
-from rest_framework.views import APIView
-from rest_framework.response import Response
-
-
-class SwaggerView(APIView):
- def get(self, request, format=None):
- json_file = os.path.join(os.path.dirname(__file__), 'swagger.json')
- f = open(json_file)
- json_data = json.JSONDecoder().decode(f.read())
- f.close()
- return Response(json_data)