summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py144
-rw-r--r--lcm/lcm/pub/database/models.py1
-rw-r--r--lcm/lcm/pub/vimapi/adaptor.py4
3 files changed, 77 insertions, 72 deletions
diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
index 46dbfaa6..3cd689ea 100644
--- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
+++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
@@ -159,6 +159,7 @@ class InstVnf(Thread):
self.apply_result = apply_grant_to_nfvo(content_args)
vim_info = ignore_case_get(self.apply_result, "vim")
+ # update vnfd_info
for vdu in self.vnfd_info["vdus"]:
if "location_info" in vdu["properties"]:
vdu["properties"]["location_info"]["vimid"] = ignore_case_get(vim_info, "vimid")
@@ -364,115 +365,118 @@ class InstVnf(Thread):
# progress = 20 + int(progress/2) # 20-70
if res_type == adaptor.RES_VOLUME:
logger.info('Create vloumns!')
- if ret["returnCode"] == adaptor.RES_NEW: # new create
- self.inst_resource['volumn'].append({"vim_id": ignore_case_get(ret, "vim_id"),
- "res_id": ignore_case_get(ret, "res_id")})
+ # if ret["returnCode"] == adaptor.RES_NEW: # new create
+ # self.inst_resource['volumn'].append({"vim_id": ignore_case_get(ret, "vim_id"),
+ # "res_id": ignore_case_get(ret, "res_id")})
JobUtil.add_job_status(self.job_id, 25, 'Create vloumns!')
StorageInstModel.objects.create(
- storageid='1',
- vimid='1',
- resouceid='1',
- name='40G',
- tenant='admin',
+ storageid=ret["id"],
+ vimid=ret["vimId"],
+ resouceid=ret["id"],
+ name=ret["name"],
+ tenant=ret["tenatId"],
insttype=0,
is_predefined=ret["returnCode"],
instid=self.nf_inst_id)
elif res_type == adaptor.RES_NETWORK:
logger.info('Create networks!')
- if ret["returnCode"] == adaptor.RES_NEW:
- self.inst_resource['network'].append({"vim_id": ignore_case_get(ret, "vim_id"),
- "res_id": ignore_case_get(ret, "res_id")})
+ # if ret["returnCode"] == adaptor.RES_NEW:
+ # self.inst_resource['network'].append({"vim_id": ignore_case_get(ret, "vim_id"),
+ # "res_id": ignore_case_get(ret, "res_id")})
# self.inst_resource['network'].append({"vim_id": "1"}, {"res_id": "2"})
JobUtil.add_job_status(self.job_id, 35, 'Create networks!')
NetworkInstModel.objects.create(
- networkid='1',
- vimid='1',
- resouceid='1',
- name='pnet_network',
- tenant='admin',
- insttype=0,
- is_predefined=ret["returnCode"],
- instid=self.nf_inst_id)
+ networkid=ret["id"],
+ vimid = ret["vimId"],
+ resouceid = ret["id"],
+ name = ret["name"],
+ tenant = ret["tenatId"],
+ insttype = 0,
+ is_predefined = ret["returnCode"],
+ instid = self.nf_inst_id)
elif res_type == adaptor.RES_SUBNET:
logger.info('Create subnets!')
- if ret["returnCode"] == adaptor.RES_NEW:
- self.inst_resource['subnet'].append({"vim_id": ignore_case_get(ret, "vim_id"),
- "res_id": ignore_case_get(ret, "res_id")})
+ # if ret["returnCode"] == adaptor.RES_NEW:
+ # self.inst_resource['subnet'].append({"vim_id": ignore_case_get(ret, "vim_id"),
+ # "res_id": ignore_case_get(ret, "res_id")})
# self.inst_resource['subnet'].append({"vim_id": "1"}, {"res_id": "2"})
JobUtil.add_job_status(self.job_id, 40, 'Create subnets!')
SubNetworkInstModel.objects.create(
- subnetworkid='1',
- vimid='1',
- resouceid='1',
- networkid='1',
- name='sub_pnet',
- tenant='admin',
+ subnetworkid=ret["id"],
+ vimid=ret["vimId"],
+ resouceid=ret["id"],
+ name=ret["name"],
+ tenant=ret["tenatId"],
insttype=0,
is_predefined=ret["returnCode"],
instid=self.nf_inst_id)
elif res_type == adaptor.RES_PORT:
logger.info('Create ports!')
- if ret["returnCode"] == adaptor.RES_NEW:
- self.inst_resource['port'].append({"vim_id": ignore_case_get(ret, "vim_id"),
- "res_id": ignore_case_get(ret, "res_id")})
+ # if ret["returnCode"] == adaptor.RES_NEW:
+ # self.inst_resource['port'].append({"vim_id": ignore_case_get(ret, "vim_id"),
+ # "res_id": ignore_case_get(ret, "res_id")})
# self.inst_resource['port'].append({"vim_id": "1"}, {"res_id": "2"})
JobUtil.add_job_status(self.job_id, 50, 'Create ports!')
PortInstModel.objects.create(
- portid='1',
- networkid='1',
- subnetworkid='1',
- vimid='1',
- resouceid='1',
- name='aaa_pnet_cp',
- tenant='admin',
+ portid=ret["id"],
+ networkid=ret["networkId"],
+ subnetworkid=ret["subnetId"],
+ vimid=ret["vimId"],
+ resouceid=ret["id"],
+ name=ret["name"],
+ tenant=ret["tenatId"],
insttype=0,
+ is_predefined=ret["returnCode"],
instid=self.nf_inst_id)
elif res_type == adaptor.RES_FLAVOR:
logger.info('Create flavors!')
- if ret["returnCode"] == adaptor.RES_NEW:
- self.inst_resource['flavor'].append({"vim_id": ignore_case_get(ret, "vim_id"),
- "res_id": ignore_case_get(ret, "res_id")})
+ # if ret["returnCode"] == adaptor.RES_NEW:
+ # self.inst_resource['flavor'].append({"vim_id": ignore_case_get(ret, "vim_id"),
+ # "res_id": ignore_case_get(ret, "res_id")})
# self.inst_resource['flavor'].append({"vim_id": "1"}, {"res_id": "2"})
JobUtil.add_job_status(self.job_id, 60, 'Create flavors!')
FlavourInstModel.objects.create(
- falavourid='1',
- name='1',
- vcpu='1',
- extraspecs='1',
+ falavourid=ret["id"],
+ name=ret["name"],
+ vcpu=ret["vcpu"],
+ memory=ret["memory"],
+ extraspecs=ret["extraSpecs"],
+ is_predefined=ret["returnCode"],
+ tenant=ret["tenatId"],
+ vimid=ret["vimId"],
instid=self.nf_inst_id)
elif res_type == adaptor.RES_VM:
logger.info('Create vms!')
- if ret["returnCode"] == adaptor.RES_NEW:
- self.inst_resource['vm'].append({"vim_id": ignore_case_get(ret, "vim_id"),
- "res_id": ignore_case_get(ret, "res_id")})
+ # if ret["returnCode"] == adaptor.RES_NEW:
+ # self.inst_resource['vm'].append({"vim_id": ignore_case_get(ret, "vim_id"),
+ # "res_id": ignore_case_get(ret, "res_id")})
# self.inst_resource['vm'].append({"vim_id": "1"}, {"res_id": "2"})
JobUtil.add_job_status(self.job_id, 70, 'Create vms!')
VmInstModel.objects.create(
- vmid="1",
- vimid="1",
- resouceid="11",
+ vmid=ret["id"],
+ vimid=ret["vimId"],
+ resouceid=ret["id"],
insttype=0,
instid=self.nf_inst_id,
- vmname="test_01",
- is_predefined=ret["returnCode"],
- operationalstate=1)
-
- def do_rollback(self, args_=None):
- logger.error('error info : %s' % args_)
- adaptor.delete_vim_res(self.inst_resource, self.do_notify_delete)
- logger.error('rollback resource complete')
-
- StorageInstModel.objects.filter(instid=self.nf_inst_id).delete()
- NetworkInstModel.objects.filter(instid=self.nf_inst_id).delete()
- SubNetworkInstModel.objects.filter(instid=self.nf_inst_id).delete()
- PortInstModel.objects.filter(instid=self.nf_inst_id).delete()
- FlavourInstModel.objects.filter(instid=self.nf_inst_id).delete()
- VmInstModel.objects.filter(instid=self.nf_inst_id).delete()
- logger.error('delete table complete')
- raise NFLCMException("Create resource failed")
+ vmname=ret["name"],
+ is_predefined=ret["returnCode"])
- def do_notify_delete(self, ret):
- logger.error('Deleting [%s] resource' % ret)
+ # def do_rollback(self, args_=None):
+ # logger.error('error info : %s' % args_)
+ # adaptor.delete_vim_res(self.inst_resource, self.do_notify_delete)
+ # logger.error('rollback resource complete')
+ #
+ # StorageInstModel.objects.filter(instid=self.nf_inst_id).delete()
+ # NetworkInstModel.objects.filter(instid=self.nf_inst_id).delete()
+ # SubNetworkInstModel.objects.filter(instid=self.nf_inst_id).delete()
+ # PortInstModel.objects.filter(instid=self.nf_inst_id).delete()
+ # FlavourInstModel.objects.filter(instid=self.nf_inst_id).delete()
+ # VmInstModel.objects.filter(instid=self.nf_inst_id).delete()
+ # logger.error('delete table complete')
+ # raise NFLCMException("Create resource failed")
+ #
+ # def do_notify_delete(self, ret):
+ # logger.error('Deleting [%s] resource' % ret)
def checkParameterExist(self):
# if ignore_case_get(self.data, "flavourId") not in self.vnfd_info:
diff --git a/lcm/lcm/pub/database/models.py b/lcm/lcm/pub/database/models.py
index 3c45ff5b..2fdc0177 100644
--- a/lcm/lcm/pub/database/models.py
+++ b/lcm/lcm/pub/database/models.py
@@ -151,6 +151,7 @@ class FlavourInstModel(models.Model):
extraspecs = models.CharField(db_column='EXTRASPECS', max_length=255)
instid = models.CharField(db_column='INSTID', max_length=255)
tenant = models.CharField(db_column='TENANT', max_length=255, null=True)
+ vmid = models.CharField(db_column='VMID', max_length=255)
class NetworkInstModel(models.Model):
class Meta:
diff --git a/lcm/lcm/pub/vimapi/adaptor.py b/lcm/lcm/pub/vimapi/adaptor.py
index 6431daa7..b63cf1ee 100644
--- a/lcm/lcm/pub/vimapi/adaptor.py
+++ b/lcm/lcm/pub/vimapi/adaptor.py
@@ -173,7 +173,7 @@ def create_port(vim_cache, res_cache, port, do_notify, res_type):
tenant_id = get_tenant_id(vim_cache, vim_id, tenant_name)
ret = api.create_subnet(vim_id, tenant_id, param)
do_notify(res_type, ret)
- set_res_cache(res_cache, res_type, subnet["cp_id"], ret["id"])
+ set_res_cache(res_cache, res_type, port["cp_id"], ret["id"])
def create_flavor(vim_cache, res_cache, data, flavor, do_notify, res_type):
location_info = flavor["properties"]["location_info"]
@@ -181,7 +181,7 @@ def create_flavor(vim_cache, res_cache, data, flavor, do_notify, res_type):
param = {
"name": "Flavor_%s" % flavor["vdu_id"],
"vcpu": int(flavor["nfv_compute"]["num_cpus"]),
- "memory": int(flavor["nfv_compute"]["mem_size"].replace('MB', '').strip()),
+ "memory": '',
"isPublic": True
}
for local_storage_id in ignore_case_get(flavor, "local_storages"):