Fix pep8 error for vnfs 95/15295/1
authorfujinhua <fu.jinhua@zte.com.cn>
Tue, 26 Sep 2017 02:46:58 +0000 (10:46 +0800)
committerfujinhua <fu.jinhua@zte.com.cn>
Tue, 26 Sep 2017 02:46:58 +0000 (10:46 +0800)
Change-Id: I894c692c01af838e19d209dd2e43a4034c5d58f0
Issue-Id: VFC-455
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
lcm/ns/vnfs/create_vnfs.py
lcm/ns/vnfs/grant_vnfs.py
lcm/ns/vnfs/heal_vnfs.py
lcm/ns/vnfs/notify_lcm.py
lcm/ns/vnfs/scale_vnfs.py
lcm/ns/vnfs/terminate_nfs.py
lcm/ns/vnfs/verify_vnfs.py
lcm/ns/vnfs/views.py
lcm/ns/vnfs/wait_job.py

index 6850ba0..0af4c6d 100644 (file)
@@ -107,7 +107,7 @@ 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 = {'vnfs': [], 'vls': [], 'vnffgs': []}
             self.vnf_inst_name = self.vnfd_id + str(uuid.uuid4())
             self.vnf_inst_name = self.vnf_inst_name[:30]
             return
@@ -271,7 +271,6 @@ class CreateVnfs(Thread):
             vnf_list = vnffg_inst_infos[0].vnflist
             vnffg_inst_infos.update(vnf_list=vnf_list + ',' + self.nf_inst_id if vnf_list else self.nf_inst_id)
 
-
     def create_vnf_in_aai(self):
         logger.debug("CreateVnfs::create_vnf_in_aai::report vnf instance[%s] to aai." % self.nf_inst_id)
         data = {
index c93647f..0bef613 100644 (file)
@@ -42,7 +42,6 @@ class GrantVnfs(object):
         elif ignore_case_get(self.data, "removeResource"):
             grant_type = "removeResource"
         else:
-            #raise NSLCMException("No grant resource is found.")
             has_res_tpl = True
 
         for res in ignore_case_get(self.data, grant_type):
@@ -116,10 +115,3 @@ class GrantVnfs(object):
             if storage_id == storage["local_storage_id"]:
                 return int(storage["properties"]["size"])
         return 0
-
-
-
-
-
-
-
index 8b5847c..2ba7c8a 100644 (file)
@@ -83,8 +83,6 @@ class NFHealService(threading.Thread):
         vmid = ignore_case_get(actionvminfo, 'vmid')
         vmname = ignore_case_get(actionvminfo, 'vmname')
 
-
-        # Gets vduid
         vduid = self.get_vudId(vmid, self.vnf_instance_id)
 
         self.nf_heal_params = {
@@ -108,11 +106,11 @@ class NFHealService(threading.Thread):
 
     # Gets vdu id according to the given vm id.
     def get_vudId(self, vmid):
-        vnfcInstances = VNFCInstModel.objects.filter(vmid = vmid, nfinstid=self.vnf_instance_id)
-        if not vnfcInstances or len(vnfcInstances) > 1:
+        vnfcInstances = VNFCInstModel.objects.filter(vmid=vmid, nfinstid=self.vnf_instance_id)
+        if not vnfcInstances:
             raise NSLCMException('VDU [vmid=%s, vnfInstanceId=%s] does not exist' % (vmid, self.vnf_instance_id))
 
-        vnfcInstance = VNFCInstModel.objects.filter(vmid = vmid,nfinstid=self.vnf_instance_id).first()
+        vnfcInstance = VNFCInstModel.objects.filter(vmid=vmid, nfinstid=self.vnf_instance_id).first()
         return vnfcInstance.vduid
 
     def update_job(self, progress, desc=''):
index 6342f7a..3c23a4e 100644 (file)
@@ -48,7 +48,6 @@ class NotifyLcm(object):
             self.update_Vl()
             self.update_Cp()
             self.update_Storage()
-            #self.update_vnf_by_vnfdmodule()
             logger.debug("notify lcm end")
         except NSLCMException as e:
             self.exception(e.message)
@@ -75,12 +74,6 @@ class NotifyLcm(object):
             vimId = ignore_case_get(vnfc, 'vimid')
             vmId = ignore_case_get(vnfc, 'vmid')
             vmName = ignore_case_get(vnfc, 'vmname')
-            # resourceType = ignore_case_get(vmResource, 'resourceType')
-            # resourceId = ignore_case_get(vmId, 'resourceId')
-
-
-            # if resourceType != 'vm':
-            #     self.exception('affectedVnfc struct error: resourceType not euqal vm')
 
             if changeType == 'added':
                 VNFCInstModel(vnfcinstanceid=vnfcInstanceId, vduid=vduId,
@@ -125,7 +118,6 @@ class NotifyLcm(object):
     def update_Cp(self):
         for cp in self.affectedCp:
             virtualLinkInstanceId = ignore_case_get(cp, 'virtualLinkInstanceId')
-            #ownerid = ignore_case_get(cp, 'ownerid')
             ownertype = ignore_case_get(cp, 'ownertype')
             if not ownertype:
                 ownertype = 0
@@ -142,7 +134,6 @@ class NotifyLcm(object):
                 tenant = ignore_case_get(portResource, 'tenant')
                 ipAddress = ignore_case_get(portResource, 'ipAddress')
                 macAddress = ignore_case_get(portResource, 'macAddress')
-                sfcEncapsulation = ignore_case_get(portResource, 'sfcEncapsulation')
                 instId = ignore_case_get(portResource, 'instId')
                 portid = str(uuid.uuid4())
                 PortInstModel(portid=portid, networkid='unknown', subnetworkid='unknown', vimid=vimId,
index fb4f2be..61d84cf 100644 (file)
@@ -102,4 +102,4 @@ class NFManualScaleService(threading.Thread):
         NfInstModel.objects.filter(nfinstid=self.vnf_instance_id).update(status=status)
 
     def update_job(self, progress, desc=''):
-        JobUtil.add_job_status(self.job_id, progress, desc)
\ No newline at end of file
+        JobUtil.add_job_status(self.job_id, progress, desc)
index b42ceee..14edc0f 100644 (file)
@@ -22,7 +22,7 @@ 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.msapi.aai import query_vnf_aai, delete_vnf_aai, query_vserver_aai, delete_vserver_aai
-from lcm.pub.msapi.extsys import get_vnfm_by_id, split_vim_to_owner_region, get_vim_by_id
+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
index aa6761b..8375acb 100644 (file)
@@ -19,7 +19,7 @@ import traceback
 import time
 
 from lcm.pub.exceptions import NSLCMException
-from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE, JOB_MODEL_STATUS
+from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
 from lcm.pub.utils.values import ignore_case_get
 from lcm.pub.utils.restcall import req_by_msb
 
@@ -27,6 +27,7 @@ logger = logging.getLogger(__name__)
 
 JOB_ERROR = 255
 
+
 class VerifyVnfs(threading.Thread):
     def __init__(self, data, job_id):
         super(VerifyVnfs, self).__init__()
@@ -53,7 +54,6 @@ class VerifyVnfs(threading.Thread):
             logger.warn("Ignore terminate vnf operation")
             if self.verify_ok:
                 self.update_job(100, "Ignore terminate vnf operation.")
-            #self.do_term_vnf()
 
     def do_on_boarding(self):
         self.update_job(10, "Start vnf on boarding.")
index ea04bdc..2a94c8c 100644 (file)
@@ -118,6 +118,7 @@ class NfScaleView(APIView):
         except Exception as e:
             return Response(data={'error': '%s' % e.message}, status=status.HTTP_409_CONFLICT)
 
+
 class NfVerifyView(APIView):
     def post(self, request):
         job_id = "VNFSDK_" + str(uuid.uuid4())
@@ -125,6 +126,7 @@ class NfVerifyView(APIView):
         VerifyVnfs(request.data, job_id).start()
         return Response(data={"jobId": job_id}, status=status.HTTP_202_ACCEPTED)
 
+
 class NfVnfmInfoView(APIView):
     def get(self, request, vnfmid):
         logger.debug("NfVnfmInfoView--get::> %s" % vnfmid)
@@ -139,6 +141,7 @@ class NfVnfmInfoView(APIView):
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
         return Response(data=vnfm_info, status=status.HTTP_200_OK)
 
+
 class NfVimInfoView(APIView):
     def get(self, request, vimid):
         logger.debug("NfVimInfoView--get::> %s" % vimid)
index 39a9555..99b4507 100644 (file)
@@ -54,8 +54,7 @@ def default_callback(vnfo_job_id, vnfm_job_id, job_status, jobs, progress_range,
     return False, JOB_MODEL_STATUS.PROCESSING
 
 
-def wait_job_finish(vnfm_id, vnfo_job_id, vnfm_job_id, progress_range=None, timeout=600, 
-    job_callback=default_callback, **kwargs):
+def wait_job_finish(vnfm_id, vnfo_job_id, vnfm_job_id, progress_range=None, timeout=600, job_callback=default_callback, **kwargs):
     progress_range = [0, 100] if not progress_range else progress_range
     response_id = 0
     query_interval = 2