diff options
Diffstat (limited to 'lcm')
-rw-r--r-- | lcm/lcm/nf/vnfs/tests/test_vnf_create.py | 4 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/urls.py | 3 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/views.py | 11 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py | 4 | ||||
-rw-r--r-- | lcm/lcm/samples/urls.py | 2 | ||||
-rw-r--r-- | lcm/lcm/settings.py | 3 | ||||
-rw-r--r-- | lcm/lcm/swagger/__init__.py | 13 | ||||
-rw-r--r-- | lcm/lcm/swagger/swagger.json (renamed from lcm/lcm/nf/vnfs/swagger.json) | 6 | ||||
-rw-r--r-- | lcm/lcm/swagger/tests.py | 30 | ||||
-rw-r--r-- | lcm/lcm/swagger/urls.py | 20 | ||||
-rw-r--r-- | lcm/lcm/swagger/views.py | 26 | ||||
-rw-r--r-- | lcm/lcm/urls.py | 1 |
12 files changed, 99 insertions, 24 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py index 3260c2db..537171e3 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py @@ -43,10 +43,6 @@ class TestNFInstantiate(TestCase): descp=job_detail) self.assertEqual(1, len(jobs)) - def test_swagger_ok(self): - response = self.client.get("/api/vnflcm/v1/swagger.json", format='json') - self.assertEqual(response.status_code, status.HTTP_200_OK) - @mock.patch.object(restcall, 'call_req') def test_create_vnf_identifier(self, mock_call_req): r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode( diff --git a/lcm/lcm/nf/vnfs/urls.py b/lcm/lcm/nf/vnfs/urls.py index 5be0073e..7e88f30a 100644 --- a/lcm/lcm/nf/vnfs/urls.py +++ b/lcm/lcm/nf/vnfs/urls.py @@ -15,7 +15,7 @@ from django.conf.urls import patterns, url from rest_framework.urlpatterns import format_suffix_patterns -from lcm.nf.vnfs.views import InstantiateVnf, TerminateVnf, SwaggerJsonView, DeleteVnfAndQueryVnf, CreateVnfAndQueryVnfs +from lcm.nf.vnfs.views import InstantiateVnf, TerminateVnf, DeleteVnfAndQueryVnf, CreateVnfAndQueryVnfs urlpatterns = patterns('', url(r'^api/vnflcm/v1/vnf_instances$', CreateVnfAndQueryVnfs.as_view()), @@ -25,7 +25,6 @@ urlpatterns = patterns('', DeleteVnfAndQueryVnf.as_view()), url(r'^api/vnflcm/v1/vnf_instances/(?P<instanceid>[0-9a-zA-Z_-]+)/terminate$', TerminateVnf.as_view()), - url(r'^api/vnflcm/v1/swagger.json$', SwaggerJsonView.as_view()) ) urlpatterns = format_suffix_patterns(urlpatterns) diff --git a/lcm/lcm/nf/vnfs/views.py b/lcm/lcm/nf/vnfs/views.py index 1062d3a1..2330fa2c 100644 --- a/lcm/lcm/nf/vnfs/views.py +++ b/lcm/lcm/nf/vnfs/views.py @@ -12,9 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import json import logging -import os import traceback from rest_framework import status @@ -119,12 +117,3 @@ class TerminateVnf(APIView): return Response(data={'error': 'unexpected exception'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) rsp = {"jobId": job_id} return Response(data=rsp, status=status.HTTP_202_ACCEPTED) - - -class SwaggerJsonView(APIView): - def get(self, request): - 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) diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py index 50948ca5..9b6babb2 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py @@ -211,8 +211,8 @@ class InstVnf(Thread): {'vsInstanceId': port.portid, 'cpdid': port.nodeId, 'changeType': 'added', - 'storageResource': {'vimId': port.vimid, 'resourceId': port.resouceid, - 'resourceName': port.name, 'resourceType': 'port'}}) + 'portResource': {'vimId': port.vimid, 'resourceId': port.resouceid, + 'resourceName': port.name, 'resourceType': 'port'}}) affected_vs = [] vss = StorageInstModel.objects.filter(instid=self.nf_inst_id) for vs in vss: diff --git a/lcm/lcm/samples/urls.py b/lcm/lcm/samples/urls.py index 2e163274..0756d137 100644 --- a/lcm/lcm/samples/urls.py +++ b/lcm/lcm/samples/urls.py @@ -16,5 +16,5 @@ from django.conf.urls import url from lcm.samples import views urlpatterns = [ - url(r'^api/vnflcm/v1/resources/(?P<action_type>[inst|term]+)$', views.ResourceList.as_view()), + url(r'^api/vnflcm/v1/resources/(?P<action_type>(inst|term)+)$', views.ResourceList.as_view()), url(r'^samples/$', views.SampleList.as_view()), ] diff --git a/lcm/lcm/settings.py b/lcm/lcm/settings.py index 5583c4cd..f4b7826b 100644 --- a/lcm/lcm/settings.py +++ b/lcm/lcm/settings.py @@ -44,7 +44,8 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'rest_framework', 'lcm.pub.database', - 'lcm.samples' + 'lcm.samples', + 'lcm.swagger' ] MIDDLEWARE_CLASSES = [ diff --git a/lcm/lcm/swagger/__init__.py b/lcm/lcm/swagger/__init__.py new file mode 100644 index 00000000..c7b6818e --- /dev/null +++ b/lcm/lcm/swagger/__init__.py @@ -0,0 +1,13 @@ +# 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. diff --git a/lcm/lcm/nf/vnfs/swagger.json b/lcm/lcm/swagger/swagger.json index 4c9c8dd2..f098d282 100644 --- a/lcm/lcm/nf/vnfs/swagger.json +++ b/lcm/lcm/swagger/swagger.json @@ -4,7 +4,7 @@ "version": "1.0.0", "title": "VNF Manager LCM Service rest API" }, - "basePath": "/gvnfmapi/lcm/v1", + "basePath": "/api/vnflcm/v1", "tags": [ { "name": "lcm Resource" @@ -283,7 +283,7 @@ } } }, - "/vnf_lc_ops/{vnfLcOpId}&responseId={responseId}": { + "/vnf_lc_ops/{vnfLcOpId}": { "get": { "tags": [ "lcm Resource" @@ -307,7 +307,7 @@ }, { "name": "responseId", - "in": "path", + "in": "query", "description": "Response Identifier", "required": true, "type": "string" diff --git a/lcm/lcm/swagger/tests.py b/lcm/lcm/swagger/tests.py new file mode 100644 index 00000000..f65f6990 --- /dev/null +++ b/lcm/lcm/swagger/tests.py @@ -0,0 +1,30 @@ +# 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 new file mode 100644 index 00000000..6764a1d4 --- /dev/null +++ b/lcm/lcm/swagger/urls.py @@ -0,0 +1,20 @@ +# 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. + +from django.conf.urls import url +from lcm.swagger import views + +urlpatterns = [ + url(r'^api/vnflcm/v1/swagger.json$', views.SwaggerView.as_view()) +] diff --git a/lcm/lcm/swagger/views.py b/lcm/lcm/swagger/views.py new file mode 100644 index 00000000..400d6dd1 --- /dev/null +++ b/lcm/lcm/swagger/views.py @@ -0,0 +1,26 @@ +# 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) diff --git a/lcm/lcm/urls.py b/lcm/lcm/urls.py index e60108b8..a4ebda98 100644 --- a/lcm/lcm/urls.py +++ b/lcm/lcm/urls.py @@ -19,6 +19,7 @@ urlpatterns = [ url(r'^', include('lcm.samples.urls')), url(r'^', include('lcm.nf.vnfs.urls')), url(r'^', include('lcm.jobs.urls')), + url(r'^', include('lcm.swagger.urls')), ] # regist to MSB when startup |