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
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 = {
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):
if storage_id == storage["local_storage_id"]:
return int(storage["properties"]["size"])
return 0
-
-
-
-
-
-
-
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 = {
# 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=''):
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)
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,
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
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,
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)
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
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
JOB_ERROR = 255
+
class VerifyVnfs(threading.Thread):
def __init__(self, data, job_id):
super(VerifyVnfs, self).__init__()
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.")
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())
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)
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)
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