aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-09-28 14:15:17 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-09-28 14:15:17 +0800
commitbafac37bbc63d991c332ce9e17fa730ae6e00304 (patch)
tree70ca71af75e8dbbe87cb0a9001e533412eba2f3b
parentee94f532cf429d9a687bd7d901389ebe05b3ab3c (diff)
Fix vfc-lcm/ns pep8 issue
Change-Id: I66e3a3e0a792b4beb6ad38687083e3458506bed5 Issue-ID: VFC-456 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--lcm/ns/ns_create.py2
-rw-r--r--lcm/ns/ns_instant.py34
-rw-r--r--lcm/ns/ns_manual_scale.py2
-rw-r--r--lcm/ns/tests/sfcs/test_sfcdetailview.py6
-rw-r--r--lcm/ns/tests/test_ns_create.py5
-rw-r--r--lcm/ns/tests/test_ns_instant.py2
-rw-r--r--lcm/ns/tests/test_ns_manual_scale.py15
-rw-r--r--lcm/ns/views.py4
-rw-r--r--lcm/samples/views.py6
9 files changed, 37 insertions, 39 deletions
diff --git a/lcm/ns/ns_create.py b/lcm/ns/ns_create.py
index 8df6fe52..e5435816 100644
--- a/lcm/ns/ns_create.py
+++ b/lcm/ns/ns_create.py
@@ -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
diff --git a/lcm/ns/ns_instant.py b/lcm/ns/ns_instant.py
index ba6234d3..23c5ba37 100644
--- a/lcm/ns/ns_instant.py
+++ b/lcm/ns/ns_instant.py
@@ -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)
diff --git a/lcm/ns/ns_manual_scale.py b/lcm/ns/ns_manual_scale.py
index d8a089a8..077f45ec 100644
--- a/lcm/ns/ns_manual_scale.py
+++ b/lcm/ns/ns_manual_scale.py
@@ -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:
diff --git a/lcm/ns/tests/sfcs/test_sfcdetailview.py b/lcm/ns/tests/sfcs/test_sfcdetailview.py
index 9e18af10..8059007c 100644
--- a/lcm/ns/tests/sfcs/test_sfcdetailview.py
+++ b/lcm/ns/tests/sfcs/test_sfcdetailview.py
@@ -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"}
diff --git a/lcm/ns/tests/test_ns_create.py b/lcm/ns/tests/test_ns_create.py
index 293dfb37..f93e75e5 100644
--- a/lcm/ns/tests/test_ns_create.py
+++ b/lcm/ns/tests/test_ns_create.py
@@ -12,16 +12,15 @@
# 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
diff --git a/lcm/ns/tests/test_ns_instant.py b/lcm/ns/tests/test_ns_instant.py
index 10fa3a9f..544c3743 100644
--- a/lcm/ns/tests/test_ns_instant.py
+++ b/lcm/ns/tests/test_ns_instant.py
@@ -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)
diff --git a/lcm/ns/tests/test_ns_manual_scale.py b/lcm/ns/tests/test_ns_manual_scale.py
index 79182fda..f1e9e061 100644
--- a/lcm/ns/tests/test_ns_manual_scale.py
+++ b/lcm/ns/tests/test_ns_manual_scale.py
@@ -12,18 +12,19 @@
# 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()
diff --git a/lcm/ns/views.py b/lcm/ns/views.py
index 78fc51bf..f7bb97a5 100644
--- a/lcm/ns/views.py
+++ b/lcm/ns/views.py
@@ -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'
diff --git a/lcm/samples/views.py b/lcm/samples/views.py
index 53153d0b..eb6941c1 100644
--- a/lcm/samples/views.py
+++ b/lcm/samples/views.py
@@ -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)