Merge "Bump minor version"
authorFu Jinhua <fu.jinhua@zte.com.cn>
Wed, 29 Nov 2017 06:27:02 +0000 (06:27 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 29 Nov 2017 06:27:02 +0000 (06:27 +0000)
12 files changed:
lcm/lcm/nf/vnfs/tests/test_vnf_create.py
lcm/lcm/nf/vnfs/urls.py
lcm/lcm/nf/vnfs/views.py
lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
lcm/lcm/samples/urls.py
lcm/lcm/settings.py
lcm/lcm/swagger/__init__.py [new file with mode: 0644]
lcm/lcm/swagger/swagger.json [moved from lcm/lcm/nf/vnfs/swagger.json with 99% similarity]
lcm/lcm/swagger/tests.py [new file with mode: 0644]
lcm/lcm/swagger/urls.py [new file with mode: 0644]
lcm/lcm/swagger/views.py [new file with mode: 0644]
lcm/lcm/urls.py

index 3260c2d..537171e 100644 (file)
@@ -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(
index 5be0073..7e88f30 100644 (file)
@@ -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)
index 1062d3a..2330fa2 100644 (file)
@@ -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)
index 50948ca..9b6babb 100644 (file)
@@ -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:
index 2e16327..0756d13 100644 (file)
@@ -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()), ]
index 5583c4c..f4b7826 100644 (file)
@@ -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 (file)
index 0000000..c7b6818
--- /dev/null
@@ -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.
similarity index 99%
rename from lcm/lcm/nf/vnfs/swagger.json
rename to lcm/lcm/swagger/swagger.json
index 4c9c8dd..f098d28 100644 (file)
@@ -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"
                 }
             }
         },
-        "/vnf_lc_ops/{vnfLcOpId}&responseId={responseId}": {
+        "/vnf_lc_ops/{vnfLcOpId}": {
             "get": {
                 "tags": [
                     "lcm Resource"
                     },
                     {
                         "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 (file)
index 0000000..f65f699
--- /dev/null
@@ -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 (file)
index 0000000..6764a1d
--- /dev/null
@@ -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 (file)
index 0000000..400d6dd
--- /dev/null
@@ -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)
index e60108b..a4ebda9 100644 (file)
@@ -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