From: fujinhua Date: Sat, 30 Sep 2017 01:49:51 +0000 (+0800) Subject: Fix vnflcm vnf pep8 error X-Git-Tag: v1.0.0~6 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vfc%2Fgvnfm%2Fvnflcm.git;a=commitdiff_plain;h=2583004ea6a2e329bfdcf7888a03e0f93646b881 Fix vnflcm vnf pep8 error Change-Id: Iba89611125511ea38751f7cd9e3687bd93701c6d Issue-Id: VFC-485 Signed-off-by: fujinhua --- diff --git a/lcm/lcm/nf/vnfs/const.py b/lcm/lcm/nf/vnfs/const.py index d3489627..bf4343ad 100644 --- a/lcm/lcm/nf/vnfs/const.py +++ b/lcm/lcm/nf/vnfs/const.py @@ -778,7 +778,7 @@ c6_data_create_port = { } # create_flavor -c7_data_create_flavor ={ +c7_data_create_flavor = { "returnCode": 0, "vimId": "11111", "vimName": "11111", diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py index 4d5748cc..038cbcf1 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py @@ -165,9 +165,9 @@ class TestNFTerminate(TestCase): create_time=now_time()) t1_apply_grant_result = [0, json.JSONEncoder().encode( { - "vim":{ + "vim": { "vimid": 'vimid_1', - "accessinfo":{ + "accessinfo": { "tenant": 'tenantname_1' } } diff --git a/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py b/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py index 3442afa2..128ba351 100644 --- a/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py +++ b/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py @@ -34,7 +34,7 @@ class DeleteVnf: self.delete_vnf_in_aai() self.delete_info_from_db() except NFLCMException as e: - logger.debug('Delete VNF instance[%s] from AAI failed' % self.nf_inst_id) + logger.debug('Delete VNF instance[%s] failed: %s', self.nf_inst_id, e.message) except: logger.debug('Delete VNF instance[%s] failed' % self.nf_inst_id) diff --git a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py index b9a5e66b..c8c85d2b 100644 --- a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py @@ -67,14 +67,14 @@ class TermVnf(Thread): if not vnf_insts.exists(): logger.warn('VnfInst(%s) does not exist' % self.nf_inst_id) return False - #raise NFLCMException('VnfInst(%s) does not exist' % self.nf_inst_id) - sel_vnf = vnf_insts[0] - #if sel_vnf.status != 'VNF_INSTANTIATED': + # raise NFLCMException('VnfInst(%s) does not exist' % self.nf_inst_id) + # sel_vnf = vnf_insts[0] + # if sel_vnf.status != 'VNF_INSTANTIATED': # raise NFLCMException("Don't allow to terminate vnf(status:[%s])" % sel_vnf.status) if self.terminationType == 'GRACEFUL' and not self.gracefulTerminationTimeout: logger.warn("Set Graceful default termination timeout = 60") self.gracefulTerminationTimeout = 60 - #raise NFLCMException("Graceful termination must set timeout") + # raise NFLCMException("Graceful termination must set timeout") NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status=VNF_STATUS.TERMINATING) JobUtil.add_job_status(self.job_id, 10, 'Nf terminating pre-check finish') @@ -233,8 +233,8 @@ class TermVnf(Thread): 'affectedVnfc': affected_vnfc, 'affectedVirtualLink': affected_vl, 'affectedVirtualStorage': affected_vs, - 'affectedCp': affected_cp - } + 'affectedCp': affected_cp} + vnfmInfo = NfvoRegInfoModel.objects.filter(nfvoid=self.nf_inst_id) if len(vnfmInfo) == 0: raise NFLCMException('nf_inst_id(%s) does not exist in NfvoRegInfoModel' % self.nf_inst_id) diff --git a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py index 3b0e3751..9b4231b1 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py +++ b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py @@ -49,7 +49,7 @@ class CreateVnf: if REPORT_TO_AAI: self.create_vnf_in_aai() except NFLCMException as e: - logger.debug('Create VNF instance[%s] to AAI failed' % self.nf_inst_id) + logger.debug('Create VNF instance[%s] to AAI failed: %s', self.nf_inst_id, e.message) except: NfInstModel.objects.create(nfinstid=self.nf_inst_id, nf_name=self.vnf_instance_mame, diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py index b12d81ec..50948ca5 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py @@ -87,7 +87,7 @@ class InstVnf(Thread): self.vnfd_info = toscautil.convert_vnfd_model(raw_data["rawData"]) # convert to inner json self.vnfd_info = json.JSONDecoder().decode(self.vnfd_info) - #self.vnfd_info = vnfd_model_dict # just for test + # self.vnfd_info = vnfd_model_dict # just for test self.update_cps() self.check_parameter_exist() @@ -112,8 +112,10 @@ class InstVnf(Thread): lastuptime=now_time()) logger.info("self.vim_id = %s" % self.vim_id) - NfvoRegInfoModel.objects.create(nfvoid=self.nf_inst_id, - vnfminstid=ignore_case_get(self.data, "vnfmId"), apiurl=self.vim_id) + NfvoRegInfoModel.objects.create( + nfvoid=self.nf_inst_id, + vnfminstid=ignore_case_get(self.data, "vnfmId"), + apiurl=self.vim_id) JobUtil.add_job_status(self.job_id, 15, 'Nf instancing pre-check finish') logger.info("Nf instancing pre-check finish") @@ -141,8 +143,8 @@ class InstVnf(Thread): content_args['additionalParam']['vimid'] = vnfmInfo[0].apiurl logger.info('content_args=%s' % content_args) apply_result = apply_grant_to_nfvo(json.dumps(content_args)) - #vim_info = ignore_case_get(apply_result, "vim") - #vim_info = ignore_case_get(json.JSONDecoder().decode(apply_result), "vim") + # vim_info = ignore_case_get(apply_result, "vim") + # vim_info = ignore_case_get(json.JSONDecoder().decode(apply_result), "vim") for vdu in ignore_case_get(self.vnfd_info, "vdus"): if "location_info" in vdu["properties"]: @@ -228,8 +230,8 @@ class InstVnf(Thread): 'affectedVnfc': affected_vnfc, 'affectedVirtualLink': affected_vl, 'affectedVirtualStorage': affected_vs, - 'affectedCp': affected_cp - } + 'affectedCp': affected_cp} + vnfmInfo = NfvoRegInfoModel.objects.filter(nfvoid=self.nf_inst_id) if len(vnfmInfo) == 0: raise NFLCMException('nf_inst_id(%s) does not exist in NfvoRegInfoModel' % self.nf_inst_id) diff --git a/lcm/lcm/nf/vnfs/vnf_query/__init__.py b/lcm/lcm/nf/vnfs/vnf_query/__init__.py index 650d17ec..c7b6818e 100644 --- a/lcm/lcm/nf/vnfs/vnf_query/__init__.py +++ b/lcm/lcm/nf/vnfs/vnf_query/__init__.py @@ -10,4 +10,4 @@ # 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. \ No newline at end of file +# limitations under the License. diff --git a/lcm/lcm/nf/vnfs/vnf_query/query_vnf.py b/lcm/lcm/nf/vnfs/vnf_query/query_vnf.py index df625454..80e0d9b5 100644 --- a/lcm/lcm/nf/vnfs/vnf_query/query_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_query/query_vnf.py @@ -40,7 +40,7 @@ class QueryVnf: resp_data = [] for vnf_inst in vnf_insts: resp_data.append(self.fill_resp_data(vnf_inst)) - return resp_data + return resp_data def fill_resp_data(self, vnf): logger.info('Get the list of vloumes') diff --git a/lcm/lcm/pub/utils/enumutil.py b/lcm/lcm/pub/utils/enumutil.py index 9656f7de..48e4ffe9 100644 --- a/lcm/lcm/pub/utils/enumutil.py +++ b/lcm/lcm/pub/utils/enumutil.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. + def enum(**enums): return type('Enum', (), enums)