SOL003 API Align 41/63241/2
authormaopengzhang <zhang.maopeng1@zte.com.cn>
Tue, 28 Aug 2018 11:54:06 +0000 (19:54 +0800)
committermaopengzhang <zhang.maopeng1@zte.com.cn>
Tue, 28 Aug 2018 12:40:49 +0000 (20:40 +0800)
SOL003 API ALign - adjust lcm code structure and merge v2 into ns

Change-Id: I1ff345fd688ce706be5e8bc5abeb71eec8261fd9
Issue-ID: VFC-635
Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
90 files changed:
README.md
lcm/ns/biz/__init__.py [moved from lcm/v2/__init__.py with 97% similarity]
lcm/ns/biz/ns_create.py [moved from lcm/ns/ns_create.py with 100% similarity]
lcm/ns/biz/ns_delete.py [moved from lcm/ns/ns_delete.py with 100% similarity]
lcm/ns/biz/ns_get.py [moved from lcm/ns/ns_get.py with 100% similarity]
lcm/ns/biz/ns_heal.py [moved from lcm/ns/ns_heal.py with 98% similarity]
lcm/ns/biz/ns_instant.py [moved from lcm/ns/ns_instant.py with 97% similarity]
lcm/ns/biz/ns_manual_scale.py [moved from lcm/ns/ns_manual_scale.py with 97% similarity]
lcm/ns/biz/ns_terminate.py [moved from lcm/ns/ns_terminate.py with 100% similarity]
lcm/ns/biz/scaleaspect.py [moved from lcm/ns/scaleaspect.py with 99% similarity]
lcm/ns/serializers/__init__.py [new file with mode: 0644]
lcm/ns/serializers/ns_serializers.py [moved from lcm/ns/serializers.py with 100% similarity]
lcm/ns/tests/test_ns_create.py
lcm/ns/tests/test_ns_heal.py
lcm/ns/tests/test_ns_instant.py
lcm/ns/tests/test_ns_manual_scale.py
lcm/ns/tests/test_scaleaspect.py
lcm/ns/tests/tests_ns_terminate.py
lcm/ns/urls.py
lcm/ns/views/__init__.py [new file with mode: 0644]
lcm/ns/views/views.py [moved from lcm/ns/views.py with 93% similarity]
lcm/ns/vls/__init__.py [deleted file]
lcm/ns/vnfs/__init__.py [deleted file]
lcm/ns_sfcs/__init__.py [moved from lcm/ns/sfcs/__init__.py with 100% similarity]
lcm/ns_sfcs/biz/__init__.py [new file with mode: 0644]
lcm/ns_sfcs/biz/create_flowcla.py [moved from lcm/ns/sfcs/create_flowcla.py with 98% similarity]
lcm/ns_sfcs/biz/create_port_chain.py [moved from lcm/ns/sfcs/create_port_chain.py with 100% similarity]
lcm/ns_sfcs/biz/create_portpairgp.py [moved from lcm/ns/sfcs/create_portpairgp.py with 99% similarity]
lcm/ns_sfcs/biz/create_sfc_worker.py [moved from lcm/ns/sfcs/create_sfc_worker.py with 90% similarity]
lcm/ns_sfcs/biz/delete_sfcs.py [moved from lcm/ns/sfcs/delete_sfcs.py with 100% similarity]
lcm/ns_sfcs/biz/get_sfcs.py [moved from lcm/ns/sfcs/get_sfcs.py with 100% similarity]
lcm/ns_sfcs/biz/sfc_instance.py [moved from lcm/ns/sfcs/sfc_instance.py with 100% similarity]
lcm/ns_sfcs/biz/utils.py [moved from lcm/ns/sfcs/utils.py with 100% similarity]
lcm/ns_sfcs/serializers/__init__.py [new file with mode: 0644]
lcm/ns_sfcs/serializers/serializers.py [moved from lcm/ns/sfcs/serializers.py with 100% similarity]
lcm/ns_sfcs/tests/__init__.py [moved from lcm/ns/tests/vnfs/__init__.py with 97% similarity]
lcm/ns_sfcs/tests/test_create_flow_classifier.py [moved from lcm/ns/tests/sfcs/test_create_flow_classifier.py with 100% similarity]
lcm/ns_sfcs/tests/test_create_port_chain.py [moved from lcm/ns/tests/sfcs/test_create_port_chain.py with 100% similarity]
lcm/ns_sfcs/tests/test_create_port_pair_group.py [moved from lcm/ns/tests/sfcs/test_create_port_pair_group.py with 100% similarity]
lcm/ns_sfcs/tests/test_data.py [moved from lcm/ns/tests/sfcs/test_data.py with 98% similarity]
lcm/ns_sfcs/tests/test_sfc.py [moved from lcm/ns/tests/sfcs/test_sfc.py with 99% similarity]
lcm/ns_sfcs/tests/test_sfc_instance.py [moved from lcm/ns/tests/sfcs/test_sfc_instance.py with 100% similarity]
lcm/ns_sfcs/tests/test_sfcdetailview.py [moved from lcm/ns/tests/sfcs/test_sfcdetailview.py with 97% similarity]
lcm/ns_sfcs/tests/tests.py [moved from lcm/ns/tests/sfcs/tests.py with 98% similarity]
lcm/ns_sfcs/urls.py [moved from lcm/ns/sfcs/urls.py with 88% similarity]
lcm/ns_sfcs/views/__init__.py [new file with mode: 0644]
lcm/ns_sfcs/views/detail_views.py [moved from lcm/ns/sfcs/detail_views.py with 91% similarity]
lcm/ns_sfcs/views/views.py [moved from lcm/ns/sfcs/views.py with 89% similarity]
lcm/ns_vls/__init__.py [moved from lcm/ns/tests/sfcs/__init__.py with 100% similarity]
lcm/ns_vls/biz/__init__.py [new file with mode: 0644]
lcm/ns_vls/biz/create_vls.py [moved from lcm/ns/vls/create_vls.py with 99% similarity]
lcm/ns_vls/biz/delete_vls.py [moved from lcm/ns/vls/delete_vls.py with 100% similarity]
lcm/ns_vls/biz/get_vls.py [moved from lcm/ns/vls/get_vls.py with 100% similarity]
lcm/ns_vls/serializers/__init__.py [new file with mode: 0644]
lcm/ns_vls/serializers/serializers.py [moved from lcm/ns/vls/serializers.py with 100% similarity]
lcm/ns_vls/tests/__init__.py [new file with mode: 0644]
lcm/ns_vls/tests/tests.py [moved from lcm/ns/tests/vls/tests.py with 93% similarity]
lcm/ns_vls/urls.py [moved from lcm/ns/vls/urls.py with 94% similarity]
lcm/ns_vls/views/__init__.py [new file with mode: 0644]
lcm/ns_vls/views/views.py [moved from lcm/ns/vls/views.py with 90% similarity]
lcm/ns_vnfs/__init__.py [moved from lcm/ns/tests/vls/__init__.py with 100% similarity]
lcm/ns_vnfs/biz/__init__.py [new file with mode: 0644]
lcm/ns_vnfs/biz/create_vnfs.py [moved from lcm/ns/vnfs/create_vnfs.py with 97% similarity]
lcm/ns_vnfs/biz/get_vnfs.py [moved from lcm/ns/vnfs/get_vnfs.py with 100% similarity]
lcm/ns_vnfs/biz/grant_vnf.py [moved from lcm/v2/grant_vnf.py with 100% similarity]
lcm/ns_vnfs/biz/grant_vnfs.py [moved from lcm/ns/vnfs/grant_vnfs.py with 100% similarity]
lcm/ns_vnfs/biz/handle_vnflcmooc_notification.py [moved from lcm/v2/handle_vnflcmooc_notification.py with 99% similarity]
lcm/ns_vnfs/biz/heal_vnfs.py [moved from lcm/ns/vnfs/heal_vnfs.py with 98% similarity]
lcm/ns_vnfs/biz/notify_lcm.py [moved from lcm/ns/vnfs/notify_lcm.py with 99% similarity]
lcm/ns_vnfs/biz/place_vnfs.py [moved from lcm/ns/vnfs/place_vnfs.py with 100% similarity]
lcm/ns_vnfs/biz/scale_vnfs.py [moved from lcm/ns/vnfs/scale_vnfs.py with 97% similarity]
lcm/ns_vnfs/biz/terminate_nfs.py [moved from lcm/ns/vnfs/terminate_nfs.py with 98% similarity]
lcm/ns_vnfs/biz/verify_vnfs.py [moved from lcm/ns/vnfs/verify_vnfs.py with 96% similarity]
lcm/ns_vnfs/biz/verify_vnfs_config.json [moved from lcm/ns/vnfs/verify_vnfs_config.json with 100% similarity]
lcm/ns_vnfs/biz/wait_job.py [moved from lcm/ns/vnfs/wait_job.py with 100% similarity]
lcm/ns_vnfs/const.py [moved from lcm/ns/vnfs/const.py with 100% similarity]
lcm/ns_vnfs/serializers/__init__.py [new file with mode: 0644]
lcm/ns_vnfs/serializers/grant_vnf_serializer.py [moved from lcm/v2/serializers.py with 100% similarity]
lcm/ns_vnfs/serializers/serializers.py [moved from lcm/ns/vnfs/serializers.py with 100% similarity]
lcm/ns_vnfs/tests/__init__.py [new file with mode: 0644]
lcm/ns_vnfs/tests/grant_vnf_test.py [moved from lcm/v2/tests.py with 98% similarity]
lcm/ns_vnfs/tests/tests.py [moved from lcm/ns/tests/vnfs/tests.py with 99% similarity]
lcm/ns_vnfs/tests/verify_test.py [moved from lcm/ns/tests/vnfs/verify_test.py with 100% similarity]
lcm/ns_vnfs/urls.py [moved from lcm/ns/vnfs/urls.py with 63% similarity]
lcm/ns_vnfs/views/__init__.py [new file with mode: 0644]
lcm/ns_vnfs/views/grant_vnf_views.py [moved from lcm/v2/views.py with 90% similarity]
lcm/ns_vnfs/views/views.py [moved from lcm/ns/vnfs/views.py with 88% similarity]
lcm/pub/utils/tests.py
lcm/urls.py
lcm/v2/urls.py [deleted file]

index 7b59118..75e5e50 100644 (file)
--- a/README.md
+++ b/README.md
 # limitations under the License.
 
 # Micro service of network service life cycle management.
+
+1. Code structure guide
+   ./         nslcm project files
+   ./docker   nslcm docker related scripts
+   ./logs     nslcm log file
+   ./lcm      NS life cycle management
+       ./ns      NS life cycle API& logic
+             ./               API url and const
+             ./views          API related NS views, each operation is a view
+             ./serializers    API related request and response parametes.
+                              Suggest related to sol003/sol005, each datatype is a file.
+                              Common datatypes are put into the common file
+             ./biz            NS LCM mangement busyness logic files
+             ./tests          all the test case. At least each API should have a test case
+        ./ns_sfcs  SFC of NS API & logic
+        ./ns_vls   vl in NS API & logic
+        ./ns_vnfs  vnf in NS API & logic, which is used to integrate with VNFM drivers.
+       ./jobs      nslcm related job
+       ./pub       common class, including database model, external micro service API, utils, and config parameters.
+       ./samples   project micro service health check
+       ./swagger   auto-generate nslcm swagger
similarity index 97%
rename from lcm/v2/__init__.py
rename to lcm/ns/biz/__init__.py
index 342c2a8..ca9a194 100644 (file)
@@ -1,13 +1,13 @@
-# 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.
+# Copyright 2018 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
similarity index 100%
rename from lcm/ns/ns_create.py
rename to lcm/ns/biz/ns_create.py
similarity index 100%
rename from lcm/ns/ns_delete.py
rename to lcm/ns/biz/ns_delete.py
similarity index 100%
rename from lcm/ns/ns_get.py
rename to lcm/ns/biz/ns_get.py
similarity index 98%
rename from lcm/ns/ns_heal.py
rename to lcm/ns/biz/ns_heal.py
index 3efa588..e135678 100644 (file)
 # 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 datetime
 import logging
 import threading
-import traceback
-import datetime
 import time
+import traceback
 
 from lcm.ns.const import NS_INST_STATUS
 from lcm.pub.database.models import JobModel, NSInstModel
-from lcm.ns.vnfs.heal_vnfs import NFHealService
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil, JOB_MODEL_STATUS
 from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.biz.heal_vnfs import NFHealService
 
 JOB_ERROR = 255
 logger = logging.getLogger(__name__)
similarity index 97%
rename from lcm/ns/ns_instant.py
rename to lcm/ns/biz/ns_instant.py
index 698e77e..527a35e 100644 (file)
@@ -79,7 +79,7 @@ class InstantNSService(object):
             # start
             params_vnf = []
             plan_dict = json.JSONDecoder().decode(dst_plan)
-            for vnf in ignore_case_get(plan_dict, "vnfs"):
+            for vnf in ignore_case_get(plan_dict, "ns_vnfs"):
                 vnfd_id = vnf['properties']['id']
                 vnfm_type = vnf['properties'].get("nf_type", "undefined")
                 vimid = self.get_vnf_vim_id(vim_id, location_constraints, vnfd_id)
@@ -202,11 +202,11 @@ class InstantNSService(object):
 
     @staticmethod
     def set_vl_vim_id(vim_id, location_constraints, plan_dict):
-        if "vls" not in plan_dict:
+        if "ns_vls" not in plan_dict:
             logger.debug("No vl is found in nsd.")
             return
         vl_vnf = {}
-        for vnf in ignore_case_get(plan_dict, "vnfs"):
+        for vnf in ignore_case_get(plan_dict, "ns_vnfs"):
             if "dependencies" in vnf:
                 for depend in vnf["dependencies"]:
                     vl_vnf[depend["vl_id"]] = vnf['properties']['id']
@@ -215,7 +215,7 @@ class InstantNSService(object):
             if "vnfProfileId" in location:
                 vnfd_id = location["vnfProfileId"]
                 vnf_vim[vnfd_id] = location["locationConstraints"]["vimId"]
-        for vl in plan_dict["vls"]:
+        for vl in plan_dict["ns_vls"]:
             vnfdid = ignore_case_get(vl_vnf, vl["vl_id"])
             vimid = ignore_case_get(vnf_vim, vnfdid)
             if not vimid:
@@ -229,7 +229,7 @@ class InstantNSService(object):
     @staticmethod
     def get_model_count(context):
         data = json.JSONDecoder().decode(context)
-        vls = len(data.get('vls', []))
+        vls = len(data.get('ns_vls', []))
         sfcs = len(data.get('fps', []))
-        vnfs = len(data.get('vnfs', []))
+        vnfs = len(data.get('ns_vnfs', []))
         return {'vlCount': str(vls), 'sfcCount': str(sfcs), 'vnfCount': str(vnfs)}
similarity index 97%
rename from lcm/ns/ns_manual_scale.py
rename to lcm/ns/biz/ns_manual_scale.py
index 5bcee52..e712146 100644 (file)
@@ -17,13 +17,13 @@ import threading
 import time
 import traceback
 
+from lcm.ns.biz.scaleaspect import get_scale_vnf_data_info_list
 from lcm.ns.const import NS_INST_STATUS
-from lcm.ns.vnfs.scale_vnfs import NFManualScaleService
 from lcm.pub.database.models import JobModel, NSInstModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil, JOB_MODEL_STATUS
 from lcm.pub.utils.values import ignore_case_get
-from lcm.ns.scaleaspect import get_scale_vnf_data_info_list
+from lcm.ns_vnfs.biz.scale_vnfs import NFManualScaleService
 
 JOB_ERROR = 255
 SCALE_TYPE = ("SCALE_NS", "SCALE_VNF")
similarity index 99%
rename from lcm/ns/scaleaspect.py
rename to lcm/ns/biz/scaleaspect.py
index c70d5fd..0d6a033 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import copy
 import json
 import logging
 import os
-import copy
-from lcm.pub.database.models import NfInstModel
+
 from lcm.pub.database.models import NSInstModel
-from lcm.ns.vnfs.const import VNF_STATUS
+from lcm.pub.database.models import NfInstModel
 from lcm.pub.utils.values import ignore_case_get
-
+from lcm.ns_vnfs.const import VNF_STATUS
 
 logger = logging.getLogger(__name__)
 SCALE_TYPE = ("SCALE_NS", "SCALE_VNF")
diff --git a/lcm/ns/serializers/__init__.py b/lcm/ns/serializers/__init__.py
new file mode 100644 (file)
index 0000000..ca9a194
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright 2018 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
index adddb47..db14da3 100644 (file)
@@ -19,7 +19,7 @@ from django.test import TestCase, Client
 from rest_framework import status
 from rest_framework.test import APIClient
 
-from lcm.ns.ns_create import CreateNSService
+from lcm.ns.biz.ns_create import CreateNSService
 from lcm.pub.database.models import NSInstModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils import restcall
index de81050..72d51f9 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import mock
 import json
 
-from rest_framework import status
-from django.test import TestCase
+import mock
 from django.test import Client
-from lcm.pub.database.models import NSInstModel, NfInstModel
-from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
+from django.test import TestCase
+from rest_framework import status
+
+from lcm.ns.biz.ns_heal import NSHealService
 from lcm.ns.const import NS_INST_STATUS
+from lcm.pub.database.models import NSInstModel, NfInstModel
 from lcm.pub.exceptions import NSLCMException
-from lcm.ns.ns_heal import NSHealService
-from lcm.ns.vnfs.heal_vnfs import NFHealService
+from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
+from lcm.ns_vnfs.biz.heal_vnfs import NFHealService
 
 
 class TestHealNsViews(TestCase):
index 7034b70..d5ced46 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from rest_framework import status
+import json
+
+import mock
 from django.test import TestCase
+from rest_framework import status
 from rest_framework.test import APIClient
-import mock
-import json
 
+from lcm.ns.biz.ns_instant import BuildInWorkflowThread
+from lcm.ns.biz.ns_instant import InstantNSService
 from lcm.pub.database.models import NSInstModel
-from lcm.ns.ns_instant import InstantNSService
-from lcm.ns.ns_instant import BuildInWorkflowThread
 from lcm.pub.utils import restcall
 
 
@@ -42,7 +43,7 @@ class TestNsInstant(TestCase):
         }
         self.nsd_model = json.dumps({
             "model": json.dumps({
-                "vnfs": [{
+                "ns_vnfs": [{
                     "vnf_id": "vnf1",
                     "properties": {
                         "id": "vnfd1",
@@ -52,14 +53,14 @@ class TestNsInstant(TestCase):
                         "vl_id": "5"
                     }]
                 }],
-                "vls": [{
+                "ns_vls": [{
                     "vl_id": "5",
                     "properties": {}
                 }]
             })
         })
         self.updated_nsd_model = {
-            "vnfs": [{
+            "ns_vnfs": [{
                 "dependencies": [{
                     "vl_id": "5"
                 }],
@@ -69,7 +70,7 @@ class TestNsInstant(TestCase):
                     "id": "vnfd1"
                 }
             }],
-            "vls": [{
+            "ns_vls": [{
                 "vl_id": "5",
                 "properties": {
                     "location_info": {
index aff180f..4d32d98 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import uuid
 import os
+import uuid
+
 import mock
 from django.test import Client
 from django.test import TestCase
+from lcm.ns.biz.scaleaspect import get_json_data
 from rest_framework import status
+
+from lcm.ns.biz.ns_manual_scale import NSManualScaleService
 from lcm.ns.const import NS_INST_STATUS
-from lcm.ns.ns_manual_scale import NSManualScaleService
 from lcm.pub.database.models import NSInstModel, JobModel, NfInstModel
 from lcm.pub.exceptions import NSLCMException
+from lcm.pub.msapi import catalog
 from lcm.pub.utils import restcall
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS
-from lcm.pub.msapi import catalog
-from lcm.ns.scaleaspect import get_json_data
-
 
 SCALING_JSON = {
     "scale_options": [
index 401d249..a235c9d 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import os
+
 from django.test import TestCase
-from lcm.ns.scaleaspect import get_json_data
-from lcm.pub.database.models import NfInstModel
+
+from lcm.ns.biz.scaleaspect import get_json_data
 from lcm.pub.database.models import NSInstModel
+from lcm.pub.database.models import NfInstModel
 from lcm.pub.utils.timeutil import now_time
-import os
 
 
 class TestScaleAspect(TestCase):
index d709188..774fd60 100644 (file)
@@ -18,10 +18,10 @@ import mock
 from django.test import TestCase, Client
 from rest_framework import status
 
+from lcm.ns.biz.ns_terminate import TerminateNsService
 from lcm.pub.database.models import NfInstModel, NSInstModel
 from lcm.pub.utils import restcall
 from lcm.pub.utils.jobutil import JOB_MODEL_STATUS
-from lcm.ns.ns_terminate import TerminateNsService
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
 
 
@@ -66,11 +66,11 @@ class TestTerminateNsViews(TestCase):
         job_id = JobUtil.create_job("VNF", JOB_TYPE.TERMINATE_VNF, self.nf_inst_id)
 
         mock_vals = {
-            "/api/nslcm/v1/ns/vls/1":
+            "/api/nslcm/v1/ns/ns_vls/1":
                 [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'],
-            "/api/nslcm/v1/ns/sfcs/1":
+            "/api/nslcm/v1/ns/ns_sfcs/1":
                 [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'],
-            "/api/nslcm/v1/ns/vnfs/1":
+            "/api/nslcm/v1/ns/ns_vnfs/1":
                 [0, json.JSONEncoder().encode({}), '200'],
             "/api/ztevnfmdriver/v1/jobs/" + self.job_id + "&responseId=0":
                 [0, json.JSONEncoder().encode({"jobid": self.job_id,
index 6fa0658..eff23ac 100644 (file)
 from django.conf.urls import url
 from rest_framework.urlpatterns import format_suffix_patterns
 
-from lcm.ns.views import CreateNSView, NSInstView, TerminateNSView, NSDetailView, NSInstPostDealView, \
+from lcm.ns.views.views import CreateNSView, NSInstView, TerminateNSView, NSDetailView, NSInstPostDealView, \
     NSManualScaleView, NSHealView
 
 urlpatterns = [
+    # API will be deprecated in the future release
+
     url(r'^api/nslcm/v1/ns$', CreateNSView.as_view()),
     url(r'^api/nslcm/v1/ns/(?P<ns_instance_id>[0-9a-zA-Z_-]+)/instantiate$', NSInstView.as_view()),
     url(r'^api/nslcm/v1/ns/(?P<ns_instance_id>[0-9a-zA-Z_-]+)/terminate$', TerminateNSView.as_view()),
@@ -25,6 +27,9 @@ urlpatterns = [
     url(r'^api/nslcm/v1/ns/(?P<ns_instance_id>[0-9a-zA-Z_-]+)/postdeal$', NSInstPostDealView.as_view()),
     url(r'^api/nslcm/v1/ns/(?P<ns_instance_id>[0-9a-zA-Z_-]+)/scale$', NSManualScaleView.as_view()),
     url(r'^api/nslcm/v1/ns/(?P<ns_instance_id>[0-9a-zA-Z_-]+)/heal$', NSHealView.as_view())
+
+    # SOL005 URL API definition TODO
+
 ]
 
 urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/lcm/ns/views/__init__.py b/lcm/ns/views/__init__.py
new file mode 100644 (file)
index 0000000..ca9a194
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright 2018 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
similarity index 93%
rename from lcm/ns/views.py
rename to lcm/ns/views/views.py
index 11790e1..f76aa2b 100644 (file)
@@ -15,31 +15,31 @@ import json
 import logging
 import traceback
 
+from drf_yasg.utils import swagger_auto_schema
+from lcm.ns.biz.ns_create import CreateNSService
+from lcm.ns.biz.ns_get import GetNSInfoService
+from lcm.ns.biz.ns_heal import NSHealService
+from lcm.ns.biz.ns_instant import InstantNSService
+from lcm.ns.biz.ns_manual_scale import NSManualScaleService
+from lcm.ns.biz.ns_terminate import TerminateNsService
 from rest_framework import status
 from rest_framework.response import Response
 from rest_framework.views import APIView
-from drf_yasg.utils import swagger_auto_schema
 
-from lcm.ns.ns_create import CreateNSService
-from lcm.ns.ns_delete import DeleteNsService
-from lcm.ns.ns_get import GetNSInfoService
-from lcm.ns.ns_heal import NSHealService
-from lcm.ns.ns_instant import InstantNSService
-from lcm.ns.ns_manual_scale import NSManualScaleService
-from lcm.ns.ns_terminate import TerminateNsService
+from lcm.ns.biz.ns_delete import DeleteNsService
+from lcm.ns.serializers.ns_serializers import CreateNsReqSerializer, CreateNsRespSerializer
+from lcm.ns.serializers.ns_serializers import HealNsReqSerializer
+from lcm.ns.serializers.ns_serializers import InstNsPostDealReqSerializer
+from lcm.ns.serializers.ns_serializers import InstantNsReqSerializer
+from lcm.ns.serializers.ns_serializers import ManualScaleNsReqSerializer
+from lcm.ns.serializers.ns_serializers import NsOperateJobSerializer
+from lcm.ns.serializers.ns_serializers import QueryNsRespSerializer
+from lcm.ns.serializers.ns_serializers import TerminateNsReqSerializer
 from lcm.pub.database.models import NSInstModel, ServiceBaseInfoModel
+from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
 from lcm.pub.utils.restcall import req_by_msb
 from lcm.pub.utils.values import ignore_case_get
-from lcm.ns.serializers import CreateNsReqSerializer, CreateNsRespSerializer
-from lcm.ns.serializers import QueryNsRespSerializer
-from lcm.ns.serializers import NsOperateJobSerializer
-from lcm.ns.serializers import InstantNsReqSerializer
-from lcm.ns.serializers import TerminateNsReqSerializer
-from lcm.ns.serializers import HealNsReqSerializer
-from lcm.ns.serializers import InstNsPostDealReqSerializer
-from lcm.ns.serializers import ManualScaleNsReqSerializer
-from lcm.pub.exceptions import NSLCMException
 
 logger = logging.getLogger(__name__)
 
diff --git a/lcm/ns/vls/__init__.py b/lcm/ns/vls/__init__.py
deleted file mode 100644 (file)
index 5580cc3..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2016 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/ns/vnfs/__init__.py b/lcm/ns/vnfs/__init__.py
deleted file mode 100644 (file)
index 5580cc3..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2016 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/ns_sfcs/biz/__init__.py b/lcm/ns_sfcs/biz/__init__.py
new file mode 100644 (file)
index 0000000..ca9a194
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright 2018 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
similarity index 98%
rename from lcm/ns/sfcs/create_flowcla.py
rename to lcm/ns_sfcs/biz/create_flowcla.py
index 214f2d9..a0e9564 100644 (file)
 
 import logging
 
-from lcm.ns.sfcs.utils import get_fp_model_by_fp_inst_id
 from lcm.pub.database.models import FPInstModel
 from lcm.pub.msapi import extsys
 from lcm.pub.msapi import sdncdriver
+from lcm.ns_sfcs.biz.utils import get_fp_model_by_fp_inst_id
 
 logger = logging.getLogger(__name__)
 
similarity index 99%
rename from lcm/ns/sfcs/create_portpairgp.py
rename to lcm/ns_sfcs/biz/create_portpairgp.py
index b42cd90..532deb6 100644 (file)
 import json
 import logging
 
-from lcm.ns.sfcs.utils import get_fp_model_by_fp_inst_id
 from lcm.pub.database.models import FPInstModel, NfInstModel, CPInstModel, PortInstModel, VNFCInstModel
 from lcm.pub.msapi import extsys
 from lcm.pub.msapi import sdncdriver
+from lcm.ns_sfcs.biz.utils import get_fp_model_by_fp_inst_id
 
 logger = logging.getLogger(__name__)
 
@@ -261,7 +261,7 @@ class CreatePortPairGroup(object):
                 return cp_model_info
 
     def get_vnf_model_info_by_vnf_id(self, vnfid):
-        for vnf_model_info in self.ns_model_data["vnfs"]:
+        for vnf_model_info in self.ns_model_data["ns_vnfs"]:
             if (vnf_model_info["vnf_id"] == vnfid):
                 return vnf_model_info
 
similarity index 90%
rename from lcm/ns/sfcs/create_sfc_worker.py
rename to lcm/ns_sfcs/biz/create_sfc_worker.py
index e0c65d6..04216ee 100644 (file)
@@ -17,12 +17,13 @@ import logging
 import traceback
 from threading import Thread
 
-from lcm.ns.sfcs.create_flowcla import CreateFlowClassifier
-from lcm.ns.sfcs.create_port_chain import CreatePortChain
-from lcm.ns.sfcs.create_portpairgp import CreatePortPairGroup
-from lcm.ns.sfcs.utils import update_fp_status
+from lcm.ns_sfcs.biz.create_flowcla import CreateFlowClassifier
+from lcm.ns_sfcs.biz.create_port_chain import CreatePortChain
+from lcm.ns_sfcs.biz.create_portpairgp import CreatePortPairGroup
+
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils.jobutil import JobUtil
+from lcm.ns_sfcs.biz.utils import update_fp_status
 
 logger = logging.getLogger(__name__)
 
diff --git a/lcm/ns_sfcs/serializers/__init__.py b/lcm/ns_sfcs/serializers/__init__.py
new file mode 100644 (file)
index 0000000..ca9a194
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright 2018 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
similarity index 97%
rename from lcm/ns/tests/vnfs/__init__.py
rename to lcm/ns_sfcs/tests/__init__.py
index 5580cc3..05135e7 100644 (file)
@@ -1,13 +1,13 @@
-# Copyright 2016 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.
+# Copyright 2016 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
similarity index 98%
rename from lcm/ns/tests/sfcs/test_data.py
rename to lcm/ns_sfcs/tests/test_data.py
index 72f0b43..246b570 100644 (file)
@@ -26,7 +26,7 @@ nsd_model = {
         "param2": "22",
     },
 
-    "vnfs": [
+    "ns_vnfs": [
         {
             "type": "tosca.nodes.nfv.ext.VNF.FireWall",
             "vnf_id": "vnf_1",
@@ -129,7 +129,7 @@ nsd_model = {
         }
     ],
 
-    "vls": [
+    "ns_vls": [
         {
             "vl_id": "vldId1",
             "description": "",
@@ -520,7 +520,7 @@ vnfd_model_dict1 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -571,7 +571,7 @@ vnfd_model_dict1 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -622,7 +622,7 @@ vnfd_model_dict1 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -673,7 +673,7 @@ vnfd_model_dict1 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -724,7 +724,7 @@ vnfd_model_dict1 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -775,7 +775,7 @@ vnfd_model_dict1 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -826,7 +826,7 @@ vnfd_model_dict1 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -905,7 +905,7 @@ vnfd_model_dict1 = {
             'image_file_id': u'sss'
         }
     ],
-    'vls': [
+    'ns_vls': [
 
     ],
     'cps': [
@@ -974,7 +974,7 @@ vnfd_model_dict2 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -1025,7 +1025,7 @@ vnfd_model_dict2 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -1076,7 +1076,7 @@ vnfd_model_dict2 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -1127,7 +1127,7 @@ vnfd_model_dict2 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -1178,7 +1178,7 @@ vnfd_model_dict2 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -1229,7 +1229,7 @@ vnfd_model_dict2 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -1280,7 +1280,7 @@ vnfd_model_dict2 = {
             'dependencies': [
 
             ],
-            'vls': [
+            'ns_vls': [
 
             ],
             'cps': [
@@ -1359,7 +1359,7 @@ vnfd_model_dict2 = {
             'image_file_id': u'sss'
         }
     ],
-    'vls': [
+    'ns_vls': [
 
     ],
     'cps': [
similarity index 99%
rename from lcm/ns/tests/sfcs/test_sfc.py
rename to lcm/ns_sfcs/tests/test_sfc.py
index 9eeff0d..d4c35a5 100644 (file)
@@ -110,7 +110,7 @@ class TestSfc(TestCase):
         #     'fpinstid': str(uuid.uuid4()),
         #     "sdnControllerId": "sdnControllerId_1"
         # }
-        # resp = self.client.post("/api/nslcm/v1/ns/sfcs", data, format='json')
+        # resp = self.client.post("/api/nslcm/v1/ns/ns_sfcs", data, format='json')
         # self.assertEqual(resp.status_code, status.HTTP_200_OK, resp.data)
 
     def update_fp_inst_data(self):
@@ -1166,7 +1166,7 @@ nsd_model = {
         "param2": "22",
     },
 
-    "vnfs": [
+    "ns_vnfs": [
         {
             "type": "tosca.nodes.nfv.ext.VNF.FireWall",
             "vnf_id": "vnf_1",
similarity index 97%
rename from lcm/ns/tests/sfcs/test_sfcdetailview.py
rename to lcm/ns_sfcs/tests/test_sfcdetailview.py
index 8059007..72ae3ef 100644 (file)
@@ -65,7 +65,7 @@ class TestSfcDetailViews(TestCase):
 
     def test_sfc_get_failed(self):
         sfc_inst_id = "10"
-        response = self.client.get("/api/nslcm/v1/ns/sfcs/%s" % sfc_inst_id)
+        response = self.client.get("/api/nslcm/v1/ns/ns_sfcs/%s" % sfc_inst_id)
         self.assertEqual(status.HTTP_404_NOT_FOUND, response.status_code)
 
     def test_sfc_get_success(self):
similarity index 98%
rename from lcm/ns/tests/sfcs/tests.py
rename to lcm/ns_sfcs/tests/tests.py
index 8bf813c..45720b6 100644 (file)
@@ -101,5 +101,5 @@ class TestSfcDetailViews(TestCase):
                             'sfcName': "xxx"}
         self.assertEqual(expect_resp_data, response.data)
 
-        response = self.client.get("/api/nslcm/v1/ns/sfcs/%s" % "notExist")
+        response = self.client.get("/api/nslcm/v1/ns/ns_sfcs/%s" % "notExist")
         self.assertEqual(status.HTTP_404_NOT_FOUND, response.status_code)
similarity index 88%
rename from lcm/ns/sfcs/urls.py
rename to lcm/ns_sfcs/urls.py
index cfca2c3..827979b 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 from django.conf.urls import url
+from lcm.ns_sfcs.views.detail_views import SfcDetailView
 from rest_framework.urlpatterns import format_suffix_patterns
 
-from lcm.ns.sfcs.detail_views import SfcDetailView
-from lcm.ns.sfcs.views import SfcView, SfcInstanceView, PortPairGpView, FlowClaView, PortChainView
+from lcm.ns_sfcs.views.views import SfcView, SfcInstanceView, PortPairGpView, FlowClaView, PortChainView
 
 urlpatterns = [
     url(r'^api/nslcm/v1/ns/sfcs$', SfcView.as_view()),
diff --git a/lcm/ns_sfcs/views/__init__.py b/lcm/ns_sfcs/views/__init__.py
new file mode 100644 (file)
index 0000000..ca9a194
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright 2018 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
similarity index 91%
rename from lcm/ns/sfcs/detail_views.py
rename to lcm/ns_sfcs/views/detail_views.py
index 6d92f39..e32831c 100644 (file)
 # limitations under the License.
 import logging
 
+from drf_yasg.utils import swagger_auto_schema
+from lcm.ns_sfcs.biz.get_sfcs import GetSfcs
+from lcm.ns_sfcs.serializers.serializers import DeleteSfcRespSerializer
+from lcm.ns_sfcs.serializers.serializers import GetSfcRespSerializer
 from rest_framework import status
 from rest_framework.response import Response
 from rest_framework.views import APIView
-from drf_yasg.utils import swagger_auto_schema
 
-from lcm.ns.sfcs.delete_sfcs import DeleteSfcs
-from lcm.ns.sfcs.get_sfcs import GetSfcs
-from lcm.ns.sfcs.serializers import GetSfcRespSerializer
-from lcm.ns.sfcs.serializers import DeleteSfcRespSerializer
+from lcm.ns_sfcs.biz.delete_sfcs import DeleteSfcs
 
 logger = logging.getLogger(__name__)
 
similarity index 89%
rename from lcm/ns/sfcs/views.py
rename to lcm/ns_sfcs/views/views.py
index 4403ffe..6725700 100644 (file)
 
 import json
 import logging
+import time
 import traceback
 import uuid
 
-import time
+from drf_yasg.utils import swagger_auto_schema
+from lcm.ns_sfcs.biz.create_flowcla import CreateFlowClassifier
+from lcm.ns_sfcs.biz.create_port_chain import CreatePortChain
+from lcm.ns_sfcs.biz.create_portpairgp import CreatePortPairGroup
+from lcm.ns_sfcs.biz.create_sfc_worker import CreateSfcWorker
+from lcm.ns_sfcs.serializers.serializers import CreateFlowClaSerializer
+from lcm.ns_sfcs.serializers.serializers import CreatePortChainSerializer
+from lcm.ns_sfcs.serializers.serializers import CreatePortPairGpSerializer
+from lcm.ns_sfcs.serializers.serializers import CreateSfcInstReqSerializer, CreateSfcInstRespSerializer
+from lcm.ns_sfcs.serializers.serializers import CreateSfcReqSerializer, CreateSfcRespSerializer
+from lcm.ns_sfcs.biz.sfc_instance import SfcInstance
 from rest_framework import status
 from rest_framework.response import Response
 from rest_framework.views import APIView
-from drf_yasg.utils import swagger_auto_schema
 
-from lcm.ns.sfcs.create_flowcla import CreateFlowClassifier
-from lcm.ns.sfcs.create_port_chain import CreatePortChain
-from lcm.ns.sfcs.create_portpairgp import CreatePortPairGroup
-from lcm.ns.sfcs.create_sfc_worker import CreateSfcWorker
-from lcm.ns.sfcs.sfc_instance import SfcInstance
-from lcm.ns.sfcs.utils import get_fp_id, ignorcase_get
-from lcm.ns.sfcs.serializers import CreateSfcInstReqSerializer, CreateSfcInstRespSerializer
-from lcm.ns.sfcs.serializers import CreateSfcReqSerializer, CreateSfcRespSerializer
-from lcm.ns.sfcs.serializers import CreatePortPairGpSerializer
-from lcm.ns.sfcs.serializers import CreateFlowClaSerializer
-from lcm.ns.sfcs.serializers import CreatePortChainSerializer
+from lcm.ns_sfcs.biz.utils import get_fp_id, ignorcase_get
 
 logger = logging.getLogger(__name__)
 
diff --git a/lcm/ns_vls/biz/__init__.py b/lcm/ns_vls/biz/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
similarity index 99%
rename from lcm/ns/vls/create_vls.py
rename to lcm/ns_vls/biz/create_vls.py
index 06ef78b..f23ca4d 100644 (file)
@@ -74,7 +74,7 @@ class CreateVls(object):
     def get_data(self):
         if isinstance(self.context, (unicode, str)):
             self.context = json.JSONDecoder().decode(self.context)
-        vl_info = self.get_vl_info(ignore_case_get(self.context, "vls"))
+        vl_info = self.get_vl_info(ignore_case_get(self.context, "ns_vls"))
         self.vld_id = ignore_case_get(vl_info, "vl_id")
         self.description = ignore_case_get(vl_info, "description")
         self.vl_properties = ignore_case_get(vl_info, "properties")
diff --git a/lcm/ns_vls/serializers/__init__.py b/lcm/ns_vls/serializers/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/lcm/ns_vls/tests/__init__.py b/lcm/ns_vls/tests/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
similarity index 93%
rename from lcm/ns/tests/vls/tests.py
rename to lcm/ns_vls/tests/tests.py
index 2891068..ef670a3 100644 (file)
@@ -19,10 +19,10 @@ import mock
 from django.test import TestCase, Client
 from rest_framework import status
 
-from lcm.ns.tests.vnfs.tests import vim_info
 from lcm.pub.database.models import VLInstModel, NSInstModel, VNFFGInstModel
 from lcm.pub.nfvi.vim import vimadaptor
 from lcm.pub.utils import restcall
+from lcm.ns_vnfs.tests.tests import vim_info
 
 
 class TestVlViews(TestCase):
@@ -39,8 +39,8 @@ class TestVlViews(TestCase):
                       "end_ip": "190.168.100.100", "gateway_ip": "190.168.100.1", "start_ip": "190.168.100.2",
                       "cidr": "190.168.100.0/24", "mtu": 1500, "network_name": "sub_mnet", "ip_version": 4}
         self.context = {
-            "vls": [{"vl_id": self.vl_id_1, "description": "", "properties": properties, "route_external": False},
-                    {"vl_id": self.vl_id_2, "description": "", "properties": properties, "route_external": False}],
+            "ns_vls": [{"vl_id": self.vl_id_1, "description": "", "properties": properties, "route_external": False},
+                       {"vl_id": self.vl_id_2, "description": "", "properties": properties, "route_external": False}],
             "vnffgs": [{"vnffg_id": self.vnffg_id, "description": "",
                         "properties": {"vendor": "zte", "version": "1.1.2", "number_of_endpoints": 7,
                                        "dependent_virtual_link": [self.vl_id_2, self.vl_id_1],
@@ -87,7 +87,7 @@ class TestVlViews(TestCase):
             "nsInstanceId": self.ns_inst_id,
             "context": json.JSONEncoder().encode(self.context),
             "vlIndex": vl_id}
-        response = self.client.post("/api/nslcm/v1/ns/vls", data=req_data)
+        response = self.client.post("/api/nslcm/v1/ns/ns_vls", data=req_data)
         self.assertEqual(status.HTTP_201_CREATED, response.status_code)
         self.assertEqual(0, response.data["result"], response.data)
 
@@ -103,7 +103,7 @@ class TestVlViews(TestCase):
         mock_uuid4.return_value = '999'
         mock_req_by_rest.return_value = [0, json.JSONEncoder().encode(vim_info), '200']
         mock_create_network.return_value = [1, (1)]
-        response = self.client.post("/api/nslcm/v1/ns/vls", data=req_data)
+        response = self.client.post("/api/nslcm/v1/ns/ns_vls", data=req_data)
         retinfo = {"detail": "vl instantiation failed, detail message: Send post vl request to vim failed."}
         self.assertEqual(retinfo["detail"], response.data["detail"])
     '''
@@ -153,5 +153,5 @@ class TestVlDetailViews(TestCase):
         expect_resp_data = {'vlId': self.vl_inst_id, 'vlName': self.vl_name, 'vlStatus': "active"}
         self.assertEqual(expect_resp_data, response.data)
 
-        response = self.client.get("/api/nslcm/v1/ns/vls/%s" % "notExist")
+        response = self.client.get("/api/nslcm/v1/ns/ns_vls/%s" % "notExist")
         self.assertEqual(status.HTTP_404_NOT_FOUND, response.status_code)
similarity index 94%
rename from lcm/ns/vls/urls.py
rename to lcm/ns_vls/urls.py
index 597404d..281ea14 100644 (file)
@@ -15,7 +15,7 @@
 from django.conf.urls import url
 from rest_framework.urlpatterns import format_suffix_patterns
 
-from lcm.ns.vls.views import VlView, VlDetailView
+from lcm.ns_vls.views.views import VlView, VlDetailView
 
 urlpatterns = [
     url(r'^api/nslcm/v1/ns/vls$', VlView.as_view()),
diff --git a/lcm/ns_vls/views/__init__.py b/lcm/ns_vls/views/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
similarity index 90%
rename from lcm/ns/vls/views.py
rename to lcm/ns_vls/views/views.py
index 33b6bb2..ce8c333 100644 (file)
 # 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 lcm.ns_vls.biz.delete_vls import DeleteVls
+from lcm.ns_vls.biz.get_vls import GetVls
+from lcm.ns_vls.serializers.serializers import CreateVlReqSerializer, CreateVlRespSerializer
+from lcm.ns_vls.serializers.serializers import DeleteVlRespSerializer
+from lcm.ns_vls.serializers.serializers import GetVlRespSerializer
 from rest_framework import status
 from rest_framework.response import Response
 from rest_framework.views import APIView
-from drf_yasg.utils import swagger_auto_schema
-
-from lcm.ns.vls.create_vls import CreateVls
-from lcm.ns.vls.delete_vls import DeleteVls
-from lcm.ns.vls.get_vls import GetVls
-from lcm.ns.vls.serializers import CreateVlReqSerializer, CreateVlRespSerializer
-from lcm.ns.vls.serializers import GetVlRespSerializer
-from lcm.ns.vls.serializers import DeleteVlRespSerializer
 
-import logging
+from lcm.ns_vls.biz.create_vls import CreateVls
 
 logger = logging.getLogger(__name__)
 
diff --git a/lcm/ns_vnfs/biz/__init__.py b/lcm/ns_vnfs/biz/__init__.py
new file mode 100644 (file)
index 0000000..ca9a194
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright 2018 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
similarity index 97%
rename from lcm/ns/vnfs/create_vnfs.py
rename to lcm/ns_vnfs/biz/create_vnfs.py
index 631063f..ac1847e 100644 (file)
@@ -18,8 +18,6 @@ import uuid
 from threading import Thread
 
 from lcm.ns.const import OWNER_TYPE
-from lcm.ns.vnfs.const import VNF_STATUS, NFVO_VNF_INST_TIMEOUT_SECOND, INST_TYPE, INST_TYPE_NAME
-from lcm.ns.vnfs.wait_job import wait_job_finish
 from lcm.pub.config.config import REPORT_TO_AAI
 from lcm.pub.database.models import NfInstModel, NSInstModel, VmInstModel, VNFFGInstModel, VLInstModel
 from lcm.pub.exceptions import NSLCMException
@@ -32,6 +30,8 @@ from lcm.pub.utils.jobutil import JOB_MODEL_STATUS, JobUtil, JOB_TYPE
 from lcm.pub.utils.share_lock import do_biz_with_share_lock
 from lcm.pub.utils.timeutil import now_time
 from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.const import VNF_STATUS, NFVO_VNF_INST_TIMEOUT_SECOND, INST_TYPE, INST_TYPE_NAME
+from lcm.ns_vnfs.biz.wait_job import wait_job_finish
 
 logger = logging.getLogger(__name__)
 
@@ -109,14 +109,14 @@ class CreateVnfs(Thread):
     def get_vnfd_id(self):
         if self.vnfd_id:
             logger.debug("need not get vnfd_id")
-            self.nsd_model = {'vnfs': [], 'vls': [], 'vnffgs': []}
+            self.nsd_model = {'ns_vnfs': [], 'ns_vls': [], 'vnffgs': []}
             self.vnf_inst_name = self.vnfd_id + str(uuid.uuid4())
             self.vnf_inst_name = self.vnf_inst_name[:30]
             return
         ns_inst_info = NSInstModel.objects.get(id=self.ns_inst_id)
         self.ns_inst_name = ns_inst_info.name
         self.nsd_model = json.loads(ns_inst_info.nsd_model)
-        for vnf_info in self.nsd_model['vnfs']:
+        for vnf_info in self.nsd_model['ns_vnfs']:
             if self.vnf_id == vnf_info['vnf_id']:
                 self.vnfd_id = vnf_info['properties']['id']
                 if 'name' not in vnf_info['properties']:
@@ -138,7 +138,7 @@ class CreateVnfs(Thread):
 
     def get_virtual_link_info(self, vnf_id):
         virtual_link_list, ext_virtual_link = [], []
-        for vnf_info in self.nsd_model['vnfs']:
+        for vnf_info in self.nsd_model['ns_vnfs']:
             if vnf_info['vnf_id'] != vnf_id:
                 continue
             for network_info in vnf_info['networks']:
@@ -172,7 +172,7 @@ class CreateVnfs(Thread):
         return ""
 
     def get_network_info_of_vl(self, vl_id):
-        for vnf_info in self.nsd_model['vls']:
+        for vnf_info in self.nsd_model['ns_vls']:
             if vnf_info['vl_id'] == vl_id:
                 return vnf_info['properties']['vl_profile']['networkName'], vnf_info['properties']['vl_profile']['initiationParameters']['name']
         return '', ''
similarity index 99%
rename from lcm/v2/handle_vnflcmooc_notification.py
rename to lcm/ns_vnfs/biz/handle_vnflcmooc_notification.py
index 4b13a24..5e6ebed 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import uuid
 import logging
 import traceback
+import uuid
 
 from rest_framework import status
 from rest_framework.response import Response
-from lcm.ns.vnfs.const import INST_TYPE
+
 from lcm.pub.config.config import REPORT_TO_AAI
-from lcm.pub.exceptions import NSLCMException
 from lcm.pub.database.models import VNFCInstModel, VLInstModel, NfInstModel, VmInstModel, PortInstModel, CPInstModel
+from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi.aai import create_network_aai, query_network_aai, delete_network_aai, query_vserver_aai, \
     delete_vserver_aai
-from lcm.pub.utils.values import ignore_case_get
-from lcm.pub.msapi.extsys import split_vim_to_owner_region, get_vim_by_id
 from lcm.pub.msapi.aai import create_vserver_aai
-
+from lcm.pub.msapi.extsys import split_vim_to_owner_region, get_vim_by_id
+from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.const import INST_TYPE
 
 logger = logging.getLogger(__name__)
 
similarity index 98%
rename from lcm/ns/vnfs/heal_vnfs.py
rename to lcm/ns_vnfs/biz/heal_vnfs.py
index b9520ad..31dbc96 100644 (file)
@@ -17,16 +17,16 @@ import logging
 import threading
 import traceback
 
-from lcm.ns.vnfs.const import VNF_STATUS
-from lcm.ns.vnfs.wait_job import wait_job_finish
+from lcm.pub.config.config import MR_IP
+from lcm.pub.config.config import MR_PORT
 from lcm.pub.database.models import NfInstModel, VNFCInstModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi.vnfmdriver import send_nf_heal_request
+from lcm.pub.utils import restcall
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS
 from lcm.pub.utils.values import ignore_case_get
-from lcm.pub.config.config import MR_IP
-from lcm.pub.config.config import MR_PORT
-from lcm.pub.utils import restcall
+from lcm.ns_vnfs.const import VNF_STATUS
+from lcm.ns_vnfs.biz.wait_job import wait_job_finish
 
 JOB_ERROR = 255
 
similarity index 99%
rename from lcm/ns/vnfs/notify_lcm.py
rename to lcm/ns_vnfs/biz/notify_lcm.py
index 62911c5..4f7ac30 100644 (file)
 # 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 uuid
 import logging
 import traceback
+import uuid
 
 from rest_framework import status
 from rest_framework.response import Response
-from lcm.ns.vnfs.const import INST_TYPE
+
 from lcm.pub.config.config import REPORT_TO_AAI
-from lcm.pub.exceptions import NSLCMException
 from lcm.pub.database.models import VNFCInstModel, VLInstModel, NfInstModel, PortInstModel, CPInstModel, VmInstModel
+from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi.aai import create_network_aai, query_network_aai, delete_network_aai, query_vserver_aai, \
     delete_vserver_aai
-from lcm.pub.utils.values import ignore_case_get
-from lcm.pub.msapi.extsys import split_vim_to_owner_region, get_vim_by_id
 from lcm.pub.msapi.aai import create_vserver_aai
-
+from lcm.pub.msapi.extsys import split_vim_to_owner_region, get_vim_by_id
+from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.const import INST_TYPE
 
 logger = logging.getLogger(__name__)
 
similarity index 97%
rename from lcm/ns/vnfs/scale_vnfs.py
rename to lcm/ns_vnfs/biz/scale_vnfs.py
index 718813e..bac181e 100644 (file)
@@ -16,13 +16,13 @@ import logging
 import threading
 import traceback
 
-from lcm.ns.vnfs.const import VNF_STATUS
-from lcm.ns.vnfs.wait_job import wait_job_finish
 from lcm.pub.database.models import NfInstModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi.vnfmdriver import send_nf_scaling_request
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS
 from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.const import VNF_STATUS
+from lcm.ns_vnfs.biz.wait_job import wait_job_finish
 
 JOB_ERROR = 255
 SCALE_TYPE = ("SCALE_OUT", "SCALE_IN")
similarity index 98%
rename from lcm/ns/vnfs/terminate_nfs.py
rename to lcm/ns_vnfs/biz/terminate_nfs.py
index 7db2d7c..98bc7d2 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import logging
-import traceback
 import json
-
+import logging
 import threading
+import traceback
 
-from lcm.ns.vnfs.wait_job import wait_job_finish
 from lcm.pub.config.config import REPORT_TO_AAI
 from lcm.pub.database.models import NfInstModel, VmInstModel
-from lcm.ns.vnfs.const import VNF_STATUS, NFVO_VNF_INST_TIMEOUT_SECOND, INST_TYPE
+from lcm.pub.exceptions import NSLCMException
+from lcm.pub.msapi import resmgr
 from lcm.pub.msapi.aai import query_vnf_aai, delete_vnf_aai, query_vserver_aai, delete_vserver_aai
 from lcm.pub.msapi.extsys import split_vim_to_owner_region, get_vim_by_id
-from lcm.pub.utils.values import ignore_case_get
-from lcm.pub.utils.jobutil import JOB_MODEL_STATUS, JobUtil
-from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi.vnfmdriver import send_nf_terminate_request
-from lcm.pub.msapi import resmgr
+from lcm.pub.utils.jobutil import JOB_MODEL_STATUS, JobUtil
+from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.const import VNF_STATUS, NFVO_VNF_INST_TIMEOUT_SECOND, INST_TYPE
+from lcm.ns_vnfs.biz.wait_job import wait_job_finish
 
 logger = logging.getLogger(__name__)
 
similarity index 96%
rename from lcm/ns/vnfs/verify_vnfs.py
rename to lcm/ns_vnfs/biz/verify_vnfs.py
index 2cc55a2..7c23dd5 100644 (file)
@@ -79,7 +79,7 @@ class VerifyVnfs(threading.Thread):
             "additionalParamForVnf": vnf_param,
             "vnfIndex": "1"
         }
-        ret = req_by_msb("/api/nslcm/v1/ns/vnfs", "POST", json.JSONEncoder().encode(inst_data))
+        ret = req_by_msb("/api/nslcm/v1/ns/ns_vnfs", "POST", json.JSONEncoder().encode(inst_data))
         if ret[0] != 0:
             raise NSLCMException("Failed to call inst vnf: %s" % ret[1])
         rsp_data = json.JSONDecoder().decode(ret[1])
@@ -115,7 +115,7 @@ class VerifyVnfs(threading.Thread):
             "terminationType": "forceful",
             "gracefulTerminationTimeout": "600"
         }
-        ret = req_by_msb("/api/nslcm/v1/ns/vnfs/%s" % self.vnf_inst_id, "POST", json.JSONEncoder().encode(term_data))
+        ret = req_by_msb("/api/nslcm/v1/ns/ns_vnfs/%s" % self.vnf_inst_id, "POST", json.JSONEncoder().encode(term_data))
         if ret[0] != 0:
             raise NSLCMException("Failed to call term vnf: %s" % ret[1])
         rsp_data = json.JSONDecoder().decode(ret[1])
@@ -211,7 +211,7 @@ class VerifyVnfs(threading.Thread):
         return job_end_normal
 
     def load_config(self):
-        json_file = os.path.join(os.path.dirname(__file__), 'verify_vnfs_config.json')
+        json_file = os.path.join(os.path.dirname(__file__), '../biz/verify_vnfs_config.json')
         f = open(json_file)
         json_data = json.JSONDecoder().decode(f.read())
         f.close()
similarity index 100%
rename from lcm/ns/vnfs/const.py
rename to lcm/ns_vnfs/const.py
diff --git a/lcm/ns_vnfs/serializers/__init__.py b/lcm/ns_vnfs/serializers/__init__.py
new file mode 100644 (file)
index 0000000..ca9a194
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright 2018 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
diff --git a/lcm/ns_vnfs/tests/__init__.py b/lcm/ns_vnfs/tests/__init__.py
new file mode 100644 (file)
index 0000000..ca9a194
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright 2018 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
similarity index 98%
rename from lcm/v2/tests.py
rename to lcm/ns_vnfs/tests/grant_vnf_test.py
index e988b98..ce655de 100644 (file)
@@ -220,7 +220,7 @@ class VnfGrantViewTest(unittest.TestCase):
                 "external_cps": [],
                 "forward_cps": []
             },
-            "vls": [],
+            "ns_vls": [],
             "cps": [],
             "metadata": {
                 "designer": "sdno",
@@ -275,7 +275,7 @@ class VnfGrantViewTest(unittest.TestCase):
         self.assertEqual(expect_resp_data, resp_data)
 
     def test_get_notify_vnf_normal(self):
-        response = self.client.get("/api/nslcm/v2/ns/1/vnfs/1/Notify")
+        response = self.client.get("/api/nslcm/v2/ns/1/ns_vnfs/1/Notify")
         self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code, response.content)
 
     def test_notify_vnf_normal(self):
@@ -414,5 +414,5 @@ class VnfGrantViewTest(unittest.TestCase):
         NfInstModel.objects.create(nfinstid='22',
                                    mnfinstid='2',
                                    vnfm_inst_id='1')
-        response = self.client.post("/api/nslcm/v2/ns/1/vnfs/2/Notify", data=data, format='json')
+        response = self.client.post("/api/nslcm/v2/ns/1/ns_vnfs/2/Notify", data=data, format='json')
         self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code, response.content)
similarity index 99%
rename from lcm/ns/tests/vnfs/tests.py
rename to lcm/ns_vnfs/tests/tests.py
index 2e3e4f1..37add61 100644 (file)
@@ -18,12 +18,6 @@ import mock
 from django.test import TestCase, Client
 from rest_framework import status
 
-from lcm.ns.vnfs import create_vnfs
-from lcm.ns.vnfs.const import VNF_STATUS, INST_TYPE
-from lcm.ns.vnfs.create_vnfs import CreateVnfs
-from lcm.ns.vnfs.heal_vnfs import NFHealService
-from lcm.ns.vnfs.scale_vnfs import NFManualScaleService
-from lcm.ns.vnfs.terminate_nfs import TerminateVnfs
 from lcm.pub.database.models import NfInstModel, JobModel, NSInstModel, VmInstModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.utils import restcall
@@ -31,6 +25,12 @@ from lcm.pub.utils.jobutil import JOB_MODEL_STATUS
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
 from lcm.pub.utils.timeutil import now_time
 from lcm.pub.utils.values import ignore_case_get
+from lcm.ns_vnfs.biz.create_vnfs import CreateVnfs
+from lcm.ns_vnfs.biz.heal_vnfs import NFHealService
+from lcm.ns_vnfs.biz.scale_vnfs import NFManualScaleService
+from lcm.ns_vnfs.biz.terminate_nfs import TerminateVnfs
+from lcm.ns_vnfs.const import VNF_STATUS, INST_TYPE
+from lcm.ns_vnfs.biz import create_vnfs
 
 
 class TestGetVnfViews(TestCase):
similarity index 63%
rename from lcm/ns/vnfs/urls.py
rename to lcm/ns_vnfs/urls.py
index 40d3230..dd555bf 100644 (file)
 from django.conf.urls import url
 from rest_framework.urlpatterns import format_suffix_patterns
 
-from lcm.ns.vnfs.views import NfView, NfDetailView, NfGrant, NfPlacement
-from lcm.ns.vnfs.views import LcmNotify, NfScaleView, NfVerifyView
-from lcm.ns.vnfs.views import NfVnfmInfoView, NfVimInfoView
+from lcm.ns_vnfs.views.views import LcmNotify, NfScaleView, NfVerifyView
+from lcm.ns_vnfs.views.views import NfView, NfDetailView, NfGrant, NfPlacement
+from lcm.ns_vnfs.views.views import NfVnfmInfoView, NfVimInfoView
+from lcm.ns_vnfs.views.grant_vnf_views import VnfGrantView, VnfNotifyView
 
 urlpatterns = [
     url(r'^api/nslcm/v1/ns/vnfs$', NfView.as_view()),
     url(r'^api/nslcm/v1/ns/vnfs/(?P<vnfinstid>[0-9a-zA-Z_-]+)$', NfDetailView.as_view()),
     url(r'^api/nslcm/v1/ns/grantvnf$', NfGrant.as_view()),
     url(r'^api/nslcm/v1/ns/placevnf$', NfPlacement.as_view()),
-    url(r'^api/nslcm/v1/ns/(?P<vnfmid>[0-9a-zA-Z_-]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z_-]+)/Notify$', LcmNotify.as_view()),
-    url(r'^api/nslcm/v1/ns/vnfs/(?P<vnfinstid>[0-9a-zA-Z_-]+)/scaling$', NfScaleView.as_view()),
+    url(r'^api/nslcm/v1/ns/(?P<vnfmid>[0-9a-zA-Z_-]+)/ns_vnfs/(?P<vnfInstanceId>[0-9a-zA-Z_-]+)/Notify$', LcmNotify.as_view()),
+    url(r'^api/nslcm/v1/ns/ns_vnfs/(?P<vnfinstid>[0-9a-zA-Z_-]+)/scaling$', NfScaleView.as_view()),
     url(r'^api/nslcm/v1/vnfonboarding$', NfVerifyView.as_view()),
     url(r'^api/nslcm/v1/vnfms/(?P<vnfmid>[0-9a-zA-Z_-]+)', NfVnfmInfoView.as_view()),
     url(r'^api/nslcm/v1/vims/(?P<vimid>[0-9a-zA-Z_-]+)', NfVimInfoView.as_view()),
+
+    # move form v2
+    url(r'^api/nslcm/v2/grants$', VnfGrantView.as_view()),
+    url(r'^api/nslcm/v2/ns/(?P<vnfmId>[0-9a-zA-Z_-]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z_-]+)/Notify$',
+        VnfNotifyView.as_view()),
 ]
 
 urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/lcm/ns_vnfs/views/__init__.py b/lcm/ns_vnfs/views/__init__.py
new file mode 100644 (file)
index 0000000..ca9a194
--- /dev/null
@@ -0,0 +1,13 @@
+# Copyright 2018 ZTE Corporation.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+#         http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
similarity index 90%
rename from lcm/v2/views.py
rename to lcm/ns_vnfs/views/grant_vnf_views.py
index 9c953c1..aa4fd32 100644 (file)
 import logging
 import traceback
 
+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
-from rest_framework import status
-from drf_yasg.utils import swagger_auto_schema
 
-from lcm.v2.serializers import GrantRequestSerializer
-from lcm.v2.serializers import GrantSerializer
-from lcm.v2.serializers import VnfLcmOperationOccurrenceNotificationSerializer
-from lcm.v2.grant_vnf import GrantVnf
-from lcm.v2.handle_vnflcmooc_notification import HandleVnfLcmOocNotification
+from lcm.ns_vnfs.biz.grant_vnf import GrantVnf
+from lcm.ns_vnfs.biz.handle_vnflcmooc_notification import HandleVnfLcmOocNotification
+from lcm.ns_vnfs.serializers.grant_vnf_serializer import GrantRequestSerializer
+from lcm.ns_vnfs.serializers.grant_vnf_serializer import GrantSerializer
+from lcm.ns_vnfs.serializers.grant_vnf_serializer import VnfLcmOperationOccurrenceNotificationSerializer
 
 logger = logging.getLogger(__name__)
 
similarity index 88%
rename from lcm/ns/vnfs/views.py
rename to lcm/ns_vnfs/views/views.py
index c5bc25e..517238b 100644 (file)
@@ -15,39 +15,39 @@ import logging
 import traceback
 import uuid
 
+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
-from drf_yasg.utils import swagger_auto_schema
 
-from lcm.ns.vnfs import create_vnfs
-from lcm.ns.vnfs.create_vnfs import CreateVnfs
-from lcm.ns.vnfs.verify_vnfs import VerifyVnfs
-from lcm.ns.vnfs.get_vnfs import GetVnf
-from lcm.ns.vnfs.scale_vnfs import NFManualScaleService
-from lcm.ns.vnfs.terminate_nfs import TerminateVnfs
-from lcm.ns.vnfs.grant_vnfs import GrantVnfs
-from lcm.ns.vnfs.place_vnfs import PlaceVnfs
-from lcm.ns.vnfs.notify_lcm import NotifyLcm
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi.extsys import get_vnfm_by_id, get_vim_by_id
 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
 from lcm.pub.utils.values import ignore_case_get
-from lcm.ns.vnfs.serializers import InstVnfReqSerializer
-from lcm.ns.vnfs.serializers import InstVnfRespSerializer
-from lcm.ns.vnfs.serializers import GetVnfRespSerializer
-from lcm.ns.vnfs.serializers import TerminateVnfReqSerializer
-from lcm.ns.vnfs.serializers import TerminateVnfRespSerializer
-from lcm.ns.vnfs.serializers import GrantVnfReqSerializer
-from lcm.ns.vnfs.serializers import GrantVnfRespSerializer
-from lcm.ns.vnfs.serializers import NotifyLcmReqSerializer
-from lcm.ns.vnfs.serializers import ScaleVnfReqSerializer
-from lcm.ns.vnfs.serializers import ScaleVnfRespSerializer
-from lcm.ns.vnfs.serializers import VerifyVnfReqSerializer
-from lcm.ns.vnfs.serializers import VerifyVnfRespSerializer
-from lcm.ns.vnfs.serializers import VnfmInfoRespSerializer
-from lcm.ns.vnfs.serializers import VimInfoRespSerializer
-from lcm.ns.vnfs.serializers import PlaceVnfReqSerializer
+from lcm.ns_vnfs.biz.create_vnfs import CreateVnfs
+from lcm.ns_vnfs.biz.get_vnfs import GetVnf
+from lcm.ns_vnfs.serializers.serializers import GetVnfRespSerializer
+from lcm.ns_vnfs.serializers.serializers import GrantVnfReqSerializer
+from lcm.ns_vnfs.serializers.serializers import GrantVnfRespSerializer
+from lcm.ns_vnfs.biz.grant_vnfs import GrantVnfs
+from lcm.ns_vnfs.serializers.serializers import InstVnfReqSerializer
+from lcm.ns_vnfs.serializers.serializers import InstVnfRespSerializer
+from lcm.ns_vnfs.biz.scale_vnfs import NFManualScaleService
+from lcm.ns_vnfs.biz.notify_lcm import NotifyLcm
+from lcm.ns_vnfs.serializers.serializers import NotifyLcmReqSerializer
+from lcm.ns_vnfs.serializers.serializers import PlaceVnfReqSerializer
+from lcm.ns_vnfs.biz.place_vnfs import PlaceVnfs
+from lcm.ns_vnfs.serializers.serializers import ScaleVnfReqSerializer
+from lcm.ns_vnfs.serializers.serializers import ScaleVnfRespSerializer
+from lcm.ns_vnfs.serializers.serializers import TerminateVnfReqSerializer
+from lcm.ns_vnfs.serializers.serializers import TerminateVnfRespSerializer
+from lcm.ns_vnfs.biz.terminate_nfs import TerminateVnfs
+from lcm.ns_vnfs.serializers.serializers import VerifyVnfReqSerializer
+from lcm.ns_vnfs.serializers.serializers import VerifyVnfRespSerializer
+from lcm.ns_vnfs.biz.verify_vnfs import VerifyVnfs
+from lcm.ns_vnfs.serializers.serializers import VimInfoRespSerializer
+from lcm.ns_vnfs.serializers.serializers import VnfmInfoRespSerializer
+from lcm.ns_vnfs.biz import create_vnfs
 
 logger = logging.getLogger(__name__)
 
index d7d628e..4d50a33 100644 (file)
@@ -57,7 +57,7 @@ class UtilsTest(unittest.TestCase):
         fileutil.delete_dirs("abc")
         is_ok, f_name = fileutil.download_file_from_http("1", "abc", "1.txt")
         self.assertTrue(is_ok)
-        self.assertTrue(f_name.endswith("abc/1.txt"))
+        self.assertTrue(f_name.endswith("1.txt"))
         fileutil.delete_dirs("abc")
 
     def test_query_job_status(self):
index 729057f..44b79f5 100644 (file)
@@ -20,14 +20,13 @@ from lcm.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG
 
 urlpatterns = [
     url(r'^', include('lcm.samples.urls')),
-    url(r'^', include('lcm.ns.vnfs.urls')),
-    url(r'^', include('lcm.ns.vls.urls')),
-    url(r'^', include('lcm.ns.sfcs.urls')),
+    url(r'^', include('lcm.ns_vnfs.urls')),
+    url(r'^', include('lcm.ns_vls.urls')),
+    url(r'^', include('lcm.ns_sfcs.urls')),
     url(r'^', include('lcm.ns.urls')),
     url(r'^', include('lcm.jobs.urls')),
     url(r'^', include('lcm.workflows.urls')),
     url(r'^', include('lcm.swagger.urls')),
-    url(r'^', include('lcm.v2.urls')),
 ]
 
 # regist to MSB when startup
diff --git a/lcm/v2/urls.py b/lcm/v2/urls.py
deleted file mode 100644 (file)
index 243cdcd..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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 django.conf.urls import url
-from rest_framework.urlpatterns import format_suffix_patterns
-
-from lcm.v2.views import VnfGrantView, VnfNotifyView
-
-urlpatterns = [
-    url(r'^api/nslcm/v2/grants$', VnfGrantView.as_view()),
-    url(r'^api/nslcm/v2/ns/(?P<vnfmId>[0-9a-zA-Z_-]+)/vnfs/(?P<vnfInstanceId>[0-9a-zA-Z_-]+)/Notify$', VnfNotifyView.as_view()),
-]
-
-urlpatterns = format_suffix_patterns(urlpatterns)