diff options
author | 2017-09-29 13:53:43 +0800 | |
---|---|---|
committer | 2017-09-29 13:53:43 +0800 | |
commit | a015c592bfa7e2d9b3a8e3eee388ee0a17cac341 (patch) | |
tree | 8ba4f85b3f2ba0f9c4f57316439a33fba8d4a83a /gvnfmadapter | |
parent | 0112f3b6dc378869cc5543fa1be3eefd87ee4205 (diff) |
Fix vfc-gvnfm-driver pep8 issues
Change-Id: Iabcc59896b4b09118adfa32aabe28edcecd7d204
Issue-ID: VFC-478
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'gvnfmadapter')
-rw-r--r-- | gvnfmadapter/driver/interfaces/tests.py | 21 | ||||
-rw-r--r-- | gvnfmadapter/driver/interfaces/urls.py | 4 | ||||
-rw-r--r-- | gvnfmadapter/driver/interfaces/views.py | 11 | ||||
-rw-r--r-- | gvnfmadapter/driver/pub/exceptions.py | 1 | ||||
-rw-r--r-- | gvnfmadapter/driver/settings.py | 6 |
5 files changed, 24 insertions, 19 deletions
diff --git a/gvnfmadapter/driver/interfaces/tests.py b/gvnfmadapter/driver/interfaces/tests.py index f6bda99..b29aec6 100644 --- a/gvnfmadapter/driver/interfaces/tests.py +++ b/gvnfmadapter/driver/interfaces/tests.py @@ -118,7 +118,7 @@ class InterfacesTest(TestCase): } r1 = [0, json.JSONEncoder().encode(vnfm_info), "200"] r2 = [0, json.JSONEncoder().encode(job_info), "200"] - job_ret = [0, json.JSONEncoder().encode(job_status_info), "200"] + job_ret = [0, json.JSONEncoder().encode(job_status_info), "200"] mock_call_req.side_effect = [r1, r2, r1, job_ret, r1, r2] response = self.client.post("/api/gvnfmdriver/v1/ztevnfmid/vnfs/2/terminate") self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code) @@ -198,19 +198,22 @@ class InterfacesTest(TestCase): } resp_body = { "ResponseInfo": { - "vnfLcOpId":"NF-CREATE-11-ec6c2f2a-9f48-11e6-9405-fa163e91c2f9", - "responseDescriptor":{ + "vnfLcOpId": "NF-CREATE-11-ec6c2f2a-9f48-11e6-9405-fa163e91c2f9", + "responseDescriptor": { "responseId": 3, "progress": 40, "lcmOperationStatus": "PROCESSING", "statusDescription": "OMC VMs are decommissioned in VIM", "errorCode": "null", "responseHistoryList": [ - {"status": "error", - "progress": 255, - "errorcode": "", - "responseid": 20, - "statusdescription": "'JsonParser' object has no attribute 'parser_info'"}] + { + "status": "error", + "progress": 255, + "errorcode": "", + "responseid": 20, + "statusdescription": "'JsonParser' object has no attribute 'parser_info'" + } + ] } } } @@ -218,7 +221,7 @@ class InterfacesTest(TestCase): r2 = [0, json.JSONEncoder().encode(resp_body), '200'] mock_call_req.side_effect = [r1, r2] response = self.client.get("/api/gvnfmdriver/v1/%s/jobs/%s?responseId=0" - %(vnfm_info["vnfmId"], expected_body["jobId"])) + % (vnfm_info["vnfmId"], expected_body["jobId"])) self.assertEqual(status.HTTP_200_OK, response.status_code) self.assertDictEqual(expected_body, response.data) diff --git a/gvnfmadapter/driver/interfaces/urls.py b/gvnfmadapter/driver/interfaces/urls.py index 71b5608..b256658 100644 --- a/gvnfmadapter/driver/interfaces/urls.py +++ b/gvnfmadapter/driver/interfaces/urls.py @@ -19,9 +19,9 @@ urlpatterns = [ url(r'^api/(?P<vnfmtype>[0-9a-zA-Z\-\_]+)/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/vnfs$', views.instantiate_vnf, name='instantiate_vnf'), url(r'^api/(?P<vnfmtype>[0-9a-zA-Z\-\_]+)/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/vnfs/(?P<vnfInstanceId>' - r'[0-9a-zA-Z\-\_]+)/terminate$',views.terminate_vnf, name='terminate_vnf'), + r'[0-9a-zA-Z\-\_]+)/terminate$', views.terminate_vnf, name='terminate_vnf'), url(r'^api/(?P<vnfmtype>[0-9a-zA-Z\-\_]+)/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/vnfs/(?P<vnfInstanceId>' - r'[0-9a-zA-Z\-\_]+)$',views.query_vnf, name='query_vnf'), + r'[0-9a-zA-Z\-\_]+)$', views.query_vnf, name='query_vnf'), url(r'^api/(?P<vnfmtype>[0-9a-zA-Z\-\_]+)/v1/(?P<vnfmid>[0-9a-zA-Z\-\_]+)/jobs/(?P<jobid>[0-9a-zA-Z\-\_]+)$', views.operation_status, name='operation_status'), url(r'^api/(?P<vnfmtype>[0-9a-zA-Z\-\_]+)/v1/vnfpackages$', views.get_vnfpkgs, name='get_vnfpkgs'), diff --git a/gvnfmadapter/driver/interfaces/views.py b/gvnfmadapter/driver/interfaces/views.py index 267998b..8a33e47 100644 --- a/gvnfmadapter/driver/interfaces/views.py +++ b/gvnfmadapter/driver/interfaces/views.py @@ -130,7 +130,7 @@ def query_vnf(request, *args, **kwargs): } resp_response_data = mapping_conv(query_vnf_resp_mapping, ignorcase_get(resp, "ResponseInfo")) resp_data = { - "vnfInfo":resp_response_data + "vnfInfo": resp_response_data } ResponseInfo = ignorcase_get(resp, "ResponseInfo") resp_data["vnfInfo"]["version"] = ignorcase_get(ResponseInfo, "vnfSoftwareVersion") @@ -156,7 +156,7 @@ def operation_status(request, *args, **kwargs): jobId = ignorcase_get(kwargs, "jobId") responseId = ignorcase_get(kwargs, "responseId") logger.debug("[operation_status] vnfm_id=%s", vnfm_id) - vnfm_info = get_vnfminfo_from_nslcm( vnfm_id ) + vnfm_info = get_vnfminfo_from_nslcm(vnfm_id) logger.debug("[operation_status] vnfm_info=[%s]", vnfm_info) ret = call_vnfm("api/vnflcm/v1/vnf_lc_ops/%s?responseId=%s" % (jobId, responseId), "GET", vnfm_info) @@ -167,7 +167,7 @@ def operation_status(request, *args, **kwargs): logger.debug("[%s]resp_data=%s", fun_name(), resp_data) ResponseInfo = ignorcase_get(resp_data, "ResponseInfo") responseDescriptor = ignorcase_get(ResponseInfo, "responseDescriptor") - status_tmp = ignorcase_get(responseDescriptor,"lcmOperationStatus") + status_tmp = ignorcase_get(responseDescriptor, "lcmOperationStatus") del responseDescriptor["lcmOperationStatus"] responseDescriptor["status"] = status_tmp operation_data = { @@ -328,7 +328,8 @@ def wait4job(vnfm_id, job_id, gracefulTerminationTimeout=1200, retry_count=60, i break elif progress == 100: job_end_normal, job_timeout = True, False - logger.debug("Job(%s) ended normally", job_id) + logger.debug("Job(%s) ended normally,job_end_normal=[%s],job_timeout=[%s]", + job_id, job_end_normal, job_timeout) return {"success": "success"} if job_timeout: logger.error("Job(%s) timeout", job_id) @@ -363,7 +364,7 @@ def do_terminatevnf(vnfm_id, vnfInstanceId, data): logger.debug("[%s] request.data=%s", fun_name(), data) vnfm_info = get_vnfminfo_from_nslcm(vnfm_id) logger.debug("[do_terminatevnf] vnfm_info=[%s]", vnfm_info) - ret = call_vnfm("api/vnflcm/v1/vnf_instances/%s/terminate"% vnfInstanceId,"POST", vnfm_info, data) + ret = call_vnfm("api/vnflcm/v1/vnf_instances/%s/terminate" % vnfInstanceId, "POST", vnfm_info, data) if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) raise GvnfmDriverException('Failed to terminate vnf.') diff --git a/gvnfmadapter/driver/pub/exceptions.py b/gvnfmadapter/driver/pub/exceptions.py index 8b08d47..c16989d 100644 --- a/gvnfmadapter/driver/pub/exceptions.py +++ b/gvnfmadapter/driver/pub/exceptions.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + class GvnfmDriverException(Exception): pass diff --git a/gvnfmadapter/driver/settings.py b/gvnfmadapter/driver/settings.py index 882d28a..bf49cf9 100644 --- a/gvnfmadapter/driver/settings.py +++ b/gvnfmadapter/driver/settings.py @@ -41,7 +41,7 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'rest_framework', 'driver.interfaces' - ] +] MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', @@ -52,7 +52,7 @@ MIDDLEWARE_CLASSES = [ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - ] +] ROOT_URLCONF = 'driver.urls' @@ -105,7 +105,7 @@ LOGGING = { if 'test' in sys.argv: from driver.pub.config import config config.REG_TO_MSB_WHEN_START = False - + import platform if platform.system() == 'Linux': TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' |