diff options
-rw-r--r-- | lcm/lcm/nf/vnfs/const.py | 51 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/tests/test_vnf_create.py | 8 | ||||
-rw-r--r-- | lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py | 21 | ||||
-rw-r--r-- | lcm/lcm/pub/database/models.py | 18 | ||||
-rw-r--r-- | lcm/lcm/pub/vimapi/adaptor.py | 2 |
5 files changed, 75 insertions, 25 deletions
diff --git a/lcm/lcm/nf/vnfs/const.py b/lcm/lcm/nf/vnfs/const.py index 66dae1ea..9adb4ed6 100644 --- a/lcm/lcm/nf/vnfs/const.py +++ b/lcm/lcm/nf/vnfs/const.py @@ -345,14 +345,14 @@ vnfd_model_dict = { "inner_hugepage_size": "2048", "action": "add" }, - "image_file": "omm_image", + "image_file": u'sss', "local_storages": [ "local_storage_id1", "local_storage_id2" ], "volume_storages": [ { - "volume_storage_id": "volume_storage_id1", + "volume_storage_id": "volume_storage1", "location": "/usr/data", "device": "/dev/hda1" } @@ -386,11 +386,9 @@ vnfd_model_dict = { }, "vls": [ "vlId1", - "vlIdN" ], "cps": [ "cpId1", - "cpIdN" ], "scalable": { "min_instances": 1, @@ -555,7 +553,7 @@ vnfd_model_dict = { ], 'cps': [ { - "cp_id": "cpId", + "cp_id": "cpId1", "description": "", "properties": { "name": "", @@ -692,7 +690,7 @@ c6_data_create_port = { "vnicType": "normal", "securityGroups": "" } -c1_data_create_flavor ={ +c7_data_create_flavor ={ "returnCode": 0, "vimId": "11111", "vimName": "11111", @@ -706,4 +704,43 @@ c1_data_create_flavor ={ "swap": 20, "isPublic": True, "extraSpecs": "testtt" -}
\ No newline at end of file +} + +c8_data_list_image = { + "vimid": "", + "vimname": "", + "imageList": [ + { + "status": "active", + "id": "5e2757c1-f846-4727-915c-9a872553ed75", + "size": 862016, + "name": u'sss.vmdk' + } + ] +} +c9_data_create_vm = { + "returnCode": 1, + "id": "3c9eebdbbfd345658269340b9ea6fb73", + "name": "vm1", + "vimId": "11111", + "vimName": "11111", + "tenantId": "tenant1", + "boot": "boot_1", + "nicArray": "dfdf", + "volumeArray": "dfdf", + "availabilityZone": "fdvfdv", + "flavorId": "fdvfdv", + "metadata": "fdvfdv", + "securityGroups": "fdvfdv", + "serverGroup": "fdvfdv", + "status": "ACTIVE" +} +c10_data_get_vm = { + "returnCode": 1, + "id": "3c9eebdbbfd345658269340b9ea6fb73", + "name": "vm1", + "vimId": "11111", + "vimName": "11111", + "tenantId": "tenant1", + "status": "ACTIVE" +} diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py index a666130c..36f4d2e7 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py @@ -19,14 +19,14 @@ from django.test import TestCase, Client from rest_framework import status from lcm.nf.vnfs.const import vnfd_rawdata, c1_data_get_tenant_id, c4_data_create_network, c2_data_create_volume, \ - c5_data_create_subnet, c3_data_get_volume, c6_data_create_port, c1_data_create_flavor + c5_data_create_subnet, c3_data_get_volume, c6_data_create_port, c7_data_create_flavor, c8_data_list_image, c9_data_create_vm, \ + c10_data_get_vm from lcm.nf.vnfs.vnf_create.inst_vnf import InstVnf from lcm.pub.database.models import NfInstModel, JobStatusModel, VmInstModel, NetworkInstModel, \ SubNetworkInstModel, PortInstModel from lcm.pub.utils import restcall from lcm.pub.utils.jobutil import JobUtil from lcm.pub.utils.timeutil import now_time -from lcm.pub.vimapi import adaptor from lcm.pub.vimapi import api @@ -224,14 +224,14 @@ class TestNFInstantiate(TestCase): mock_call_req.side_effect = [r1, r2, r3] mock_call.side_effect = [c1_data_get_tenant_id, c2_data_create_volume, c3_data_get_volume, c4_data_create_network, c5_data_create_subnet, c6_data_create_port, - c1_data_create_flavor] + c7_data_create_flavor, c8_data_list_image, c9_data_create_vm, c10_data_get_vm] self.nf_inst_id = '1111' self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id) JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY") data = inst_req_data InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run() - self.assert_job_result(self.job_id, 255, "Undefined image(omm_image)") + self.assert_job_result(self.job_id, 100, "Instantiate Vnf success.") diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py index 1d5825e9..0727844e 100644 --- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py +++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py @@ -90,7 +90,7 @@ class InstVnf(Thread): self.inst_pre() self.apply_grant() self.create_res() - self.lcm_notify() + # self.lcm_notify() JobUtil.add_job_status(self.job_id, 100, "Instantiate Vnf success.") # is_exist = JobStatusModel.objects.filter(jobid=self.job_id).exists() # logger.debug("check_ns_inst_name_exist::is_exist=%s" % is_exist) @@ -482,12 +482,21 @@ class InstVnf(Thread): JobUtil.add_job_status(self.job_id, 70, 'Create vms!') VmInstModel.objects.create( vmid=str(uuid.uuid4()), - vimid=ret["vimId"], - resouceid=ret["id"], + vmname=ignore_case_get(ret, "name"), + vimid=ignore_case_get(ret, "vimId"), + resouceid=ignore_case_get(ret, "id"), + tenant=ignore_case_get(ret, "tenantId"), + nic_array=ignore_case_get(ret, "nicArray"), + metadata=ignore_case_get(ret, "metadata"), + volume_array=ignore_case_get(ret, "volumeArray"), + server_group=ignore_case_get(ret, "serverGroup"), + availability_zone=ignore_case_get(ret, "availabilityZone"), + flavor_id=ignore_case_get(ret, "flavorId"), + security_groups=ignore_case_get(ret, "securityGroups"), + operationalstate=ignore_case_get(ret, "status"), insttype=0, - instid=self.nf_inst_id, - vmname=ret["name"], - is_predefined=ret["returnCode"]) + is_predefined=ignore_case_get(ret, "returnCode"), + instid=self.nf_inst_id) # def do_rollback(self, args_=None): # logger.error('error info : %s' % args_) diff --git a/lcm/lcm/pub/database/models.py b/lcm/lcm/pub/database/models.py index de6dc8df..a15a7df9 100644 --- a/lcm/lcm/pub/database/models.py +++ b/lcm/lcm/pub/database/models.py @@ -120,17 +120,21 @@ class VmInstModel(models.Model): vmid = models.CharField(db_column='VMID', primary_key=True, max_length=255) vimid = models.CharField(db_column='VIMID', max_length=255) + tenant = models.CharField(db_column='TENANT', max_length=255, null=True) resouceid = models.CharField(db_column='RESOURCEID', max_length=255) - insttype = models.IntegerField(db_column='INSTTYPE') - instid = models.CharField(db_column='INSTID', max_length=255) vmname = models.CharField(db_column='VMNAME', max_length=255) - operationalstate = models.IntegerField(db_column='OPERATIONALSTATE', null=True) - zoneid = models.CharField(db_column='ZONEID', max_length=255, null=True) - tenant = models.CharField(db_column='TENANT', max_length=255, null=True) - hostid = models.CharField(db_column='HOSTID', max_length=255, null=True) - detailinfo = models.TextField(db_column='DETAILINFO', max_length=8192, null=True) + nic_array = models.CharField(db_column='NICARRAY', max_length=255) + metadata = models.CharField(db_column='METADATA', max_length=255) + volume_array = models.CharField(db_column='VOLUMEARRAY', max_length=255) + server_group = models.CharField(db_column='SERVERGROUP', max_length=255) + availability_zone = models.CharField(db_column='AVAILABILITYZONE', max_length=255) + flavor_id = models.CharField(db_column='FLAVORID', max_length=255) + security_groups = models.CharField(db_column='SECURITYGROUPS', max_length=255) + operationalstate = models.CharField(db_column='OPERATIONALSTATE', max_length=255, null=True) + insttype = models.IntegerField(db_column='INSTTYPE') is_predefined = models.IntegerField(db_column='ISPREDEFINED', default=0, null=True) create_time = models.CharField(db_column='CREATETIME', max_length=200, null=True, blank=True) + instid = models.CharField(db_column='INSTID', max_length=255) class VNFCInstModel(models.Model): class Meta: diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py index 593d779d..4b156708 100644 --- a/lcm/lcm/pub/vimapi/adaptor.py +++ b/lcm/lcm/pub/vimapi/adaptor.py @@ -277,7 +277,7 @@ def create_vm(vim_cache, res_cache, data, vm, do_notify, res_type): opt_vm_status = "Timeout" retry_count, max_retry_count = 0, 100 while retry_count < max_retry_count: - vm_info = api.get_vm(vim_id, vm_id) + vm_info = api.get_vm(vim_id, tenant_id, vm_id) if vm_info["status"].upper() == "ACTIVE": logger.debug("Vm(%s) is active", vim_id) return |