summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-02-13 10:24:23 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-02-13 10:24:23 +0800
commit24cfd0fe5dfe517646c17198d54febaf8c3fad33 (patch)
treedab86d7fa417713bab3198cf86868f8161e6cfb0 /lcm
parent34dd4f0efa95472fcc57eb9a8069647524668ee6 (diff)
Update cp table after create resource
Change-Id: I416dacca28321ae43174437b1272178a0eb193d0 Issue-Id: GVNFM-19 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/vnfs/tests/test_vnf_create.py4
-rw-r--r--lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py46
-rw-r--r--lcm/lcm/pub/database/models.py44
3 files changed, 75 insertions, 19 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
index a1ed126e..68a77812 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
@@ -22,7 +22,7 @@ from rest_framework import status
from lcm.nf.vnfs.vnf_create.create_vnf_identifier import CreateVnf
from lcm.nf.vnfs.vnf_create.inst_vnf import InstVnf
from lcm.pub.database.models import NfInstModel, JobStatusModel, NfvoRegInfoModel, VmInstModel, NetworkInstModel, \
- SubNetworkInstModel
+ SubNetworkInstModel, PortInstModel
from lcm.pub.utils import restcall
from lcm.pub.utils.jobutil import JobUtil
@@ -85,6 +85,8 @@ class TestNsInstantiate(TestCase):
tenant='admin', insttype=0, instid='1')
SubNetworkInstModel.objects.create(subnetworkid='1', vimid='1', resouceid='1', networkid='1',
name='sub_pnet',tenant='admin', insttype=0, instid='1')
+ PortInstModel.objects.create(portid='1', networkid='1', subnetworkid='1', vimid='1', resouceid='1',
+ name='aaa_pnet_cp', tenant='admin', insttype=0, instid='1')
def tearDown(self):
pass
diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
index 025a1ca9..669dfb0e 100644
--- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
+++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
@@ -17,7 +17,7 @@ import traceback
from threading import Thread
from lcm.pub.database.models import NfInstModel, JobStatusModel, NfvoRegInfoModel, VmInstModel, VNFCInstModel, \
- NetworkInstModel, SubNetworkInstModel, VLInstModel
+ NetworkInstModel, SubNetworkInstModel, VLInstModel, PortInstModel, CPInstModel
from lcm.pub.exceptions import NFLCMException
from lcm.pub.msapi.nfvolcm import vnfd_rawdata_get, apply_grant_to_nfvo, apply_res_to_nfvo
from lcm.pub.utils.jobutil import JobUtil
@@ -57,9 +57,16 @@ class InstVnf(Thread):
'virtuallinkdescid': '',
}
],
- 'affectedcp':{
+ 'affectedcp':[{
+ 'status': 'success',
+ 'portresource':{'resourceid':'1'},
+ 'cpinstanceid':'2',
+ 'cpdid':'22',
+ 'ownertype':'222',
+ 'ownerid':'2222',
+ 'virtuallinkinstanceid':'22222',
- }
+ }],
}
}
@@ -146,6 +153,7 @@ class InstVnf(Thread):
def create_res(self):
logger.info("[NF instantiation] create resource start")
volumns = ignore_case_get(self.data, "volumn_storages")
+ #create_vim_res(data, do_notify, do_rollback)
#create_volumns(volumns)
JobUtil.add_job_status(self.job_id, 35, 'Nf instancing create resource(volumn_storages) finish')
@@ -196,21 +204,21 @@ class InstVnf(Thread):
ownerid=self.nf_inst_id,
relatednetworkid=networkinst.networkid,
relatedsubnetworkid=subnetinst.subnetworkid)
- pass
# # for vs in vss:
- # for cp in cps:
- # if 'failed' == cp['status']:
- # continue
- # port_resource = cp['portresource']
- # portinst = PortInstModel.objects.filter(resouceid=port_resource['resourceid']).first()
- # CPInstModel.objects.create(
- # cpinstanceid=cp['cpinstanceid'],
- # cpdid=cp['cpdid'],
- # relatedtype='2', # port
- # relatedport=portinst.portid,
- # ownertype=cp['ownertype'],
- # ownerid=cp['ownerid'],
- # vlinstanceid=cp['virtuallinkinstanceid'])
+ for cp in cps:
+ if 'failed' == cp['status']:
+ continue
+ port_resource = cp['portresource']
+ portinst = PortInstModel.objects.filter(resouceid=port_resource['resourceid']).first()
+ ttt = portinst.portid
+ CPInstModel.objects.create(
+ cpinstanceid=cp['cpinstanceid'],
+ cpdid=cp['cpdid'],
+ relatedtype='2',
+ relatedport=portinst.portid,
+ ownertype=cp['ownertype'],
+ ownerid=cp['ownerid'],
+ vlinstanceid=cp['virtuallinkinstanceid'])
# self.add_job(43, 'INST_DPLY_VM_PRGS')
logger.info("[NF instantiation] confirm all vms are active end")
@@ -260,4 +268,8 @@ class InstVnf(Thread):
JobUtil.add_job_status(self.job_id, 255, error_msg)
# JobUtil.add_job_status(self.job_id, 255, 'VNF instantiation failed, detail message: %s' % error_msg, 0)
+ def add_job_and_update_table(self, progress, msgid, args_=None):
+ logger.info('add job, progress=%s, msgid=%s, args=%s' % (progress, msgid, args_))
+ JobUtil.add_job_status(self.job_id, 90, '')
+
diff --git a/lcm/lcm/pub/database/models.py b/lcm/lcm/pub/database/models.py
index 8820945a..23376681 100644
--- a/lcm/lcm/pub/database/models.py
+++ b/lcm/lcm/pub/database/models.py
@@ -196,4 +196,46 @@ class VLInstModel(models.Model):
relatedsubnetworkid = models.CharField(db_column='RELATEDSUBNETWORKID', max_length=255, blank=True, null=True)
vltype = models.IntegerField(db_column='VLTYPE', default=0)
vimid = models.CharField(db_column='VIMID', max_length=255)
- tenant = models.CharField(db_column='TENANT', max_length=50) \ No newline at end of file
+ tenant = models.CharField(db_column='TENANT', max_length=50)
+
+class PortInstModel(models.Model):
+ class Meta:
+ db_table = 'PORTINST'
+
+ portid = models.CharField(db_column='PORTID', primary_key=True, max_length=255)
+ networkid = models.CharField(db_column='NETWORKID', max_length=255)
+ subnetworkid = models.CharField(db_column='SUBNETWORKID', max_length=255, null=True)
+ vimid = models.CharField(db_column='VIMID', max_length=255)
+ resouceid = models.CharField(db_column='RESOURCEID', max_length=255)
+ name = models.CharField(db_column='NAME', max_length=255, null=True)
+ insttype = models.IntegerField(db_column='INSTTYPE')
+ instid = models.CharField(db_column='INSTID', max_length=255)
+ cpinstanceid = models.CharField(db_column='CPINSTANCEID', max_length=255, null=True)
+ bandwidth = models.CharField(db_column='BANDWIDTH', max_length=255, null=True)
+ operationalstate = models.CharField(db_column='OPERATIONALSTATE', max_length=255, null=True)
+ ipaddress = models.CharField(db_column='IPADDRESS', max_length=255)
+ macaddress = models.CharField(db_column='MACADDRESS', max_length=255)
+ nicorder = models.CharField(db_column='NICORDER', max_length=255)
+ floatipaddress = models.CharField(db_column='FLOATIPADDRESS', max_length=255, null=True)
+ serviceipaddress = models.CharField(db_column='SERVICEIPADDRESS', max_length=255, null=True)
+ typevirtualnic = models.CharField(db_column='TYPEVIRTUALNIC', max_length=255, null=True)
+ sfcencapsulation = models.CharField(db_column='SFCENCAPSULATION', max_length=255, null=True)
+ direction = models.CharField(db_column='DIRECTION', max_length=255, null=True)
+ tenant = models.CharField(db_column='TENANT', max_length=255, null=True)
+ interfacename = models.CharField(db_column='INTERFACENAME', max_length=255, blank=True, null=True)
+ vmid = models.CharField(db_column='VMID', max_length=255, blank=True, null=True)
+
+class CPInstModel(models.Model):
+ class Meta:
+ db_table = 'CPINST'
+
+ cpinstanceid = models.CharField(db_column='CPINSTANCEID', max_length=255, primary_key=True)
+ cpdid = models.CharField(db_column='CPDID', max_length=255)
+ cpinstancename = models.CharField(db_column='CPINSTANCENAME', max_length=255)
+ vlinstanceid = models.CharField(db_column='VLINSTANCEID', max_length=255)
+ ownertype = models.IntegerField(db_column='OWNERTYPE')
+ ownerid = models.CharField(db_column='OWNERID', max_length=255)
+ relatedtype = models.IntegerField(db_column='RELATEDTYPE')
+ relatedvl = models.CharField(db_column='RELATEDVL', max_length=255, blank=True, null=True)
+ relatedcp = models.CharField(db_column='RELATEDCP', max_length=255, blank=True, null=True)
+ relatedport = models.CharField(db_column='RELATEDPORT', max_length=255, blank=True, null=True) \ No newline at end of file