diff options
author | yunlong ying <ying.yunlong@zte.com.cn> | 2017-02-11 07:41:17 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@open-o.org> | 2017-02-11 07:41:17 +0000 |
commit | 6a53a2e1e895acddd0c9ae64f41d809da438e6de (patch) | |
tree | 7224c196e1fe7c452ff11d094b2d036d37551dc4 /lcm | |
parent | 8ac177318bab17f91ea10c1aef0be38cd8239e8e (diff) | |
parent | 0c9b10c7ef41e582415e67bd0ce390c3f0cd3a8a (diff) |
Merge "Save vnfc to DB"
Diffstat (limited to 'lcm')
-rw-r--r-- | lcm/lcm/nf/vnfs/tests/test_vnf_create.py | 7 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py | 47 | ||||
-rw-r--r-- | lcm/lcm/pub/database/models.py | 58 |
3 files changed, 88 insertions, 24 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py index f4d3a5ed..a1ed126e 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py @@ -21,7 +21,8 @@ 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 +from lcm.pub.database.models import NfInstModel, JobStatusModel, NfvoRegInfoModel, VmInstModel, NetworkInstModel, \ + SubNetworkInstModel from lcm.pub.utils import restcall from lcm.pub.utils.jobutil import JobUtil @@ -80,6 +81,10 @@ class TestNsInstantiate(TestCase): operationalstate=1) VmInstModel.objects.create(vmid="2", vimid="2", resouceid="22", insttype=0, instid="2", vmname="test_02", operationalstate=1) + NetworkInstModel.objects.create(networkid='1', vimid='1', resouceid='1', name='pnet_network', + 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') 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 289eadd5..025a1ca9 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py @@ -16,7 +16,8 @@ import logging import traceback from threading import Thread -from lcm.pub.database.models import NfInstModel, JobStatusModel, NfvoRegInfoModel, VmInstModel, VNFCInstModel +from lcm.pub.database.models import NfInstModel, JobStatusModel, NfvoRegInfoModel, VmInstModel, VNFCInstModel, \ + NetworkInstModel, SubNetworkInstModel, VLInstModel 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 @@ -45,18 +46,17 @@ class InstVnf(Thread): 'computeresource':{'resourceid':'11'}, 'vduid':'111', 'vdutype':'1111' - }, + } + ], + 'affectedvirtuallink':[ { 'status': 'success', - 'vnfcinstanceid': '2', - 'computeresource': {'resourceid':'22'}, - 'vduid': '222', - 'vdutype': '2222' + 'virtuallinkinstanceid':'', + 'networkresource':{'resourceid':'1'}, + 'subnetworkresource':{'resourceid':'1'}, + 'virtuallinkdescid': '', } ], - 'affectedvirtuallink':{ - - }, 'affectedcp':{ } @@ -182,20 +182,21 @@ class InstVnf(Thread): vdutype=vnfc['vdutype'], nfinstid=self.nf_inst_id, vmid=vminst.vmid) - # for vl in vls: - # if 'failed' == vl['status']: - # continue - # network_resource = vl['networkresource'] - # subnet_resource = vl['subnetworkresource'] - # networkinst = NetworkInstModel.objects.filter(resouceid=network_resource['resourceid']).first() - # subnetinst = SubNetworkInstModel.objects.filter(resouceid=subnet_resource['resourceid']).first() - # VLInstModel.objects.create( - # vlinstanceid=vl['virtuallinkinstanceid'], - # vldid=vl['virtuallinkdescid'], - # ownertype='0', # VNF - # ownerid=self.nf_inst_id, - # relatednetworkid=networkinst.networkid, - # relatedsubnetworkid=subnetinst.subnetworkid) + for vl in vls: + if 'failed' == vl['status']: + continue + network_resource = vl['networkresource'] + subnet_resource = vl['subnetworkresource'] + networkinst = NetworkInstModel.objects.filter(resouceid=network_resource['resourceid']).first() + subnetinst = SubNetworkInstModel.objects.filter(resouceid=subnet_resource['resourceid']).first() + VLInstModel.objects.create( + vlinstanceid=vl['virtuallinkinstanceid'], + vldid=vl['virtuallinkdescid'], + ownertype='0', + ownerid=self.nf_inst_id, + relatednetworkid=networkinst.networkid, + relatedsubnetworkid=subnetinst.subnetworkid) + pass # # for vs in vss: # for cp in cps: # if 'failed' == cp['status']: diff --git a/lcm/lcm/pub/database/models.py b/lcm/lcm/pub/database/models.py index 24dcdf33..8820945a 100644 --- a/lcm/lcm/pub/database/models.py +++ b/lcm/lcm/pub/database/models.py @@ -139,3 +139,61 @@ class VNFCInstModel(models.Model): vdutype = models.CharField(db_column='VDUTYPE', max_length=255) nfinstid = models.CharField(db_column='NFINSTID', max_length=255) vmid = models.CharField(db_column='VMID', max_length=255) + +class NetworkInstModel(models.Model): + class Meta: + db_table = 'NETWORKINST' + + networkid = models.CharField(db_column='NETWORKID', primary_key=True, max_length=255) + vimid = models.CharField(db_column='VIMID', max_length=255) + resouceid = models.CharField(db_column='RESOURCEID', max_length=255) + insttype = models.IntegerField(db_column='INSTTYPE') + instid = models.CharField(db_column='INSTID', max_length=255) + name = models.CharField(db_column='NAME', max_length=255) + tenant = models.CharField(db_column='TENANT', max_length=255, null=True) + is_shared = models.IntegerField(db_column='ISSHARED', default=0, null=True) + is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True) + desc = models.CharField(db_column='DESC', max_length=255, null=True) + vendor = models.CharField(db_column='VENDOR', max_length=255, null=True) + bandwidth = models.IntegerField(db_column='BANDWIDTH', null=True) + mtu = models.IntegerField(db_column='MTU', null=True) + network_type = models.CharField(db_column='NETWORKTYPE', max_length=255, null=True) + segmentid = models.CharField(db_column='SEGMENTID', max_length=255, null=True) + vlantrans = models.IntegerField(db_column='VLANTRANS', null=True) + networkqos = models.CharField(db_column='NETWORKQOS', max_length=255, null=True) + + +class SubNetworkInstModel(models.Model): + class Meta: + db_table = 'SUBNETWORKINST' + + subnetworkid = models.CharField(db_column='SUBNETWORKID', primary_key=True, max_length=255) + vimid = models.CharField(db_column='VIMID', max_length=255) + resouceid = models.CharField(db_column='RESOURCEID', max_length=255) + networkid = models.CharField(db_column='NETWORKID', max_length=255) + insttype = models.IntegerField(db_column='INSTTYPE') + instid = models.CharField(db_column='INSTID', max_length=255) + name = models.CharField(db_column='NAME', max_length=255) + ipversion = models.IntegerField(db_column='IPVERSION', null=True) + gatewayip = models.CharField(db_column='GATEWAYIP', max_length=255, null=True) + isdhcpenabled = models.IntegerField(db_column='ISDHCPENABLED', null=True) + cidr = models.CharField(db_column='CIDR', max_length=255) + vdsname = models.CharField(db_column='VDSNAME', max_length=255, null=True) + operationalstate = models.CharField(db_column='OPERATIONALSTATE', max_length=255, null=True) + tenant = models.CharField(db_column='TENANT', max_length=255, null=True) + is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True) + +class VLInstModel(models.Model): + class Meta: + db_table = 'VLINST' + + vlinstanceid = models.CharField(db_column='VLINSTANCEID', max_length=255, primary_key=True) + vldid = models.CharField(db_column='VLDID', max_length=255) + vlinstancename = models.CharField(db_column='VLINSTANCENAME', max_length=255, blank=True, null=True) + ownertype = models.IntegerField(db_column='OWNERTYPE') + ownerid = models.CharField(db_column='OWNERID', max_length=255) + relatednetworkid = models.CharField(db_column='RELATEDNETWORKID', max_length=255, blank=True, null=True) + 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 |