Fix vfc-lcm/ns pep8 issue 35/16235/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Thu, 28 Sep 2017 06:15:17 +0000 (14:15 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Thu, 28 Sep 2017 06:15:17 +0000 (14:15 +0800)
Change-Id: I66e3a3e0a792b4beb6ad38687083e3458506bed5
Issue-ID: VFC-456
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
lcm/ns/ns_create.py
lcm/ns/ns_instant.py
lcm/ns/ns_manual_scale.py
lcm/ns/tests/sfcs/test_sfcdetailview.py
lcm/ns/tests/test_ns_create.py
lcm/ns/tests/test_ns_instant.py
lcm/ns/tests/test_ns_manual_scale.py
lcm/ns/views.py
lcm/samples/views.py

index 8df6fe5..e543581 100644 (file)
@@ -15,7 +15,7 @@ import logging
 import uuid
 
 from lcm.pub.config.config import REPORT_TO_AAI
-from lcm.pub.database.models import NSDModel, NSInstModel
+from lcm.pub.database.models import NSInstModel
 from lcm.pub.exceptions import NSLCMException
 from lcm.pub.msapi.aai import create_customer_aai
 from lcm.pub.msapi.sdc_run_catalog import query_nspackage_by_id
index ba6234d..23c5ba3 100644 (file)
@@ -95,18 +95,20 @@ class InstantNSService(object):
                     }
                 })
             # end
-            
+
             self.set_vl_vim_id(vim_id, location_constraints, plan_dict)
             dst_plan = json.JSONEncoder().encode(plan_dict)
             logger.debug('tosca plan dest add vimid:%s' % dst_plan)
             NSInstModel.objects.filter(id=self.ns_inst_id).update(nsd_model=dst_plan)
-            
+
             vnf_params_json = json.JSONEncoder().encode(params_vnf)
-            plan_input = {'jobId': job_id, 
+            plan_input = {
+                'jobId': job_id,
                 'nsInstanceId': self.req_data["nsInstanceId"],
                 'object_context': dst_plan,
                 'object_additionalParamForNs': params_json,
-                'object_additionalParamForVnf': vnf_params_json}
+                'object_additionalParamForVnf': vnf_params_json
+            }
             plan_input.update(**self.get_model_count(dst_plan))
             plan_input["sdnControllerId"] = ignore_case_get(
                 self.req_data['additionalParamForNs'], "sdncontroller")
@@ -131,14 +133,13 @@ class InstantNSService(object):
                 pass
 
             for key, val in self.req_data['additionalParamForNs'].items():
-                InputParamMappingModel(service_id=self.ns_inst_id,
-                    input_key=key, input_value=val).save()
+                InputParamMappingModel(service_id=self.ns_inst_id, input_key=key, input_value=val).save()
 
             for vnffg in ignore_case_get(plan_dict, "vnffgs"):
                 VNFFGInstModel(vnffgdid=vnffg["vnffg_id"],
-                    vnffginstid=str(uuid.uuid4()),
-                    nsinstid=self.ns_inst_id,
-                    endpointnumber=0).save()
+                               vnffginstid=str(uuid.uuid4()),
+                               nsinstid=self.ns_inst_id,
+                               endpointnumber=0).save()
 
             if WORKFLOW_OPTION == "wso2":
                 return self.start_wso2_workflow(job_id, ns_inst, plan_input)
@@ -152,7 +153,7 @@ class InstantNSService(object):
             logger.error("ns-instant(%s) workflow error:%s" % (self.ns_inst_id, e.message))
             JobUtil.add_job_status(job_id, 255, 'NS instantiation failed: %s' % e.message)
             return dict(data={'error': e.message}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
-    
+
     def start_wso2_workflow(self, job_id, ns_inst, plan_input):
         servicetemplate_id = get_servicetemplate_id(ns_inst.nsd_id)
         process_id = get_process_id('init', servicetemplate_id)
@@ -172,8 +173,8 @@ class InstantNSService(object):
         if not plans:
             raise NSLCMException("No plan is found, you should deploy plan first!")
         data = {
-            "processId": plans[0].process_id, 
-            "params": plan_input 
+            "processId": plans[0].process_id,
+            "params": plan_input
         }
         ret = activiti.exec_workflow(data)
         logger.info("ns-instant(%s) workflow result:%s" % (self.ns_inst_id, ret))
@@ -181,11 +182,10 @@ class InstantNSService(object):
             self.ns_inst_id, ret.get('status')))
         if ret.get('status') == 1:
             return dict(data={'jobId': job_id}, status=status.HTTP_200_OK)
-        return dict(data={'error': ret['message']}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)      
+        return dict(data={'error': ret['message']}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
 
     def start_buildin_workflow(self, job_id, plan_input):
-        JobUtil.add_job_status(job_id, 10, 'NS inst(%s) buildin workflow started.' % 
-            self.ns_inst_id)
+        JobUtil.add_job_status(job_id, 10, 'NS inst(%s) buildin workflow started.' % self.ns_inst_id)
         build_in.run_ns_instantiate(plan_input)
         return dict(data={'jobId': job_id}, status=status.HTTP_200_OK)
 
@@ -196,7 +196,7 @@ class InstantNSService(object):
         if vim_id:
             return vim_id
         raise NSLCMException("No Vim info is found for vnf(%s)." % vnfdid)
-        
+
     def set_vl_vim_id(self, vim_id, location_constraints, plan_dict):
         if "vls" not in plan_dict:
             logger.debug("No vl is found in nsd.")
@@ -221,7 +221,7 @@ class InstantNSService(object):
             if "location_info" not in vl["properties"]:
                 vl["properties"]["location_info"] = {}
             vl["properties"]["location_info"]["vimid"] = vimid
-       
+
     @staticmethod
     def get_model_count(context):
         data = json.JSONDecoder().decode(context)
index d8a089a..077f45e 100644 (file)
@@ -66,7 +66,7 @@ class NSManualScaleService(threading.Thread):
 
         # Get data if SCALE_NS
         self.scale_ns_data = ignore_case_get(self.request_data, 'scaleNsData')
-        self.scale_vnf_data = get_scale_vnf_data(self.scale_ns_data,self.ns_instance_id)
+        self.scale_vnf_data = get_scale_vnf_data(self.scale_ns_data, self.ns_instance_id)
         logger.debug('scale_vnf_data = %s' % self.scale_vnf_data)
         # Get data if SCALE_VNF
         if not self.scale_vnf_data:
index 9e18af1..8059007 100644 (file)
@@ -31,8 +31,8 @@ class TestSfcDetailViews(TestCase):
         self.sdn_controler_id = str(uuid.uuid4())
 
     def tearDown(self):
-        pass  
-    
+        pass
+
     def test_sfc_delete_failed(self):
         response = self.client.delete("/api/nslcm/v1/ns/sfcs/%s" % "notExist")
         expect_resp_data = {"result": 0, "detail": "sfc is not exist or has been already deleted"}
@@ -57,7 +57,7 @@ class TestSfcDetailViews(TestCase):
         FPInstModel(fpid="1", fpinstid="10", fpname="2", nsinstid="3", vnffginstid="4",
                     symmetric="5", policyinfo="6", forworderpaths="7", status="8", sdncontrollerid="9",
                     sfcid="10", flowclassifiers="11",
-                    portpairgroups=json.JSONEncoder().encode([{"groupid":"98","portpair":"99"}])
+                    portpairgroups=json.JSONEncoder().encode([{"groupid": "98", "portpair": "99"}])
                     ).save()
         response = self.client.delete("/api/nslcm/v1/ns/sfcs/%s" % sfc_inst_id)
         expect_resp_data = {"result": 0, "detail": "delete sfc success"}
index 293dfb3..f93e75e 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import json
-
 import uuid
-import mock
 
+import mock
 from django.test import TestCase, Client
 from rest_framework import status
 
 from lcm.ns.ns_create import CreateNSService
+from lcm.pub.database.models import NSInstModel
 from lcm.pub.exceptions import NSLCMException
-from lcm.pub.database.models import NSInstModel, NSDModel
 from lcm.pub.utils import restcall
 
 
index 10fa3a9..544c374 100644 (file)
@@ -56,7 +56,7 @@ class TestNsInstant(TestCase):
         resp = self.client.post("/api/nslcm/v1/ns/123/instantiate", data, format='json')
         self.assertEqual(resp.status_code, status.HTTP_200_OK)
     """
-    
+
     def test_swagger_ok(self):
         resp = self.client.get("/api/nslcm/v1/swagger.json", format='json')
         self.assertEqual(resp.status_code, status.HTTP_200_OK)
index 79182fd..f1e9e06 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import uuid
 
 import mock
-import uuid
-from rest_framework import status
-from django.test import TestCase
 from django.test import Client
-from lcm.pub.database.models import NSDModel, NSInstModel
-from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
+from django.test import TestCase
+from rest_framework import status
+
 from lcm.ns.const import NS_INST_STATUS
-from lcm.pub.utils import restcall
 from lcm.ns.ns_manual_scale import NSManualScaleService
+from lcm.pub.database.models import NSInstModel
 from lcm.pub.exceptions import NSLCMException
+from lcm.pub.utils import restcall
+from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
 
 
 class TestNsManualScale(TestCase):
@@ -35,7 +36,7 @@ class TestNsManualScale(TestCase):
 
         self.client = Client()
         self.context = '{"vnfs": ["a", "b"], "sfcs": ["c"], "vls": ["d", "e", "f"]}'
-        NSInstModel(id=self.ns_inst_id, name="abc",nspackage_id="7", nsd_id="111").save()
+        NSInstModel(id=self.ns_inst_id, name="abc", nspackage_id="7", nsd_id="111").save()
 
     def tearDown(self):
         NSInstModel.objects.filter().delete()
index 78fc51b..f7bb97a 100644 (file)
@@ -155,11 +155,11 @@ class NSInstPostDealView(APIView):
         return Response(data={'success': 'Update status of NS(%s) to %s' % (ns_instance_id, ns_status)},
                         status=status.HTTP_202_ACCEPTED)
 
-    def send_policy_request(self,ns_instance_id, nsd_id, file_url):
+    def send_policy_request(self, ns_instance_id, nsd_id, file_url):
         input_data = {
             "nsid": ns_instance_id,
             "nsdid": nsd_id,
-            "fileUri":file_url
+            "fileUri": file_url
         }
         req_param = json.JSONEncoder().encode(input_data)
         policy_engine_url = 'api/polengine/v1/policyinfo'
index 53153d0..eb6941c 100644 (file)
@@ -42,8 +42,7 @@ class TablesList(APIView):
                 logger.debug("End delete model %s", name)
         except:
             logger.error(traceback.format_exc())
-            return Response(data={"error": "failed"}, 
-                status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+            return Response(data={"error": "failed"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
         return Response(data={}, status=status.HTTP_204_NO_CONTENT)
 
     def get(self, request, modelName):
@@ -54,6 +53,5 @@ class TablesList(APIView):
             count = len(model_obj.filter())
         except:
             logger.error(traceback.format_exc())
-            return Response(data={"error": "failed"}, 
-                status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+            return Response(data={"error": "failed"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
         return Response(data={"count": count}, status=status.HTTP_200_OK)