summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-03-02 15:37:42 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-03-02 15:37:42 +0800
commit7d9854f33b85d5d9745f93f1953cf4bc4e134805 (patch)
tree1841d4220602b1264d99195f8d5832d2a4e03dde
parentb51f79348b419a755dd08f758c45ed56c2ea0a10 (diff)
Optimized code and testcase of vnflcm
Change-Id: I9d8cb889a25295e90e131dedb70f023d2e4e2151 Issue-Id: GVNFM-42 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--lcm/lcm/jobs/job_get.py1
-rw-r--r--lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py1
-rw-r--r--lcm/lcm/nf/vnfs/tests/test_vnf_create.py24
-rw-r--r--lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py16
-rw-r--r--lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py9
-rw-r--r--lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py120
6 files changed, 48 insertions, 123 deletions
diff --git a/lcm/lcm/jobs/job_get.py b/lcm/lcm/jobs/job_get.py
index a8a615a9..d7bee942 100644
--- a/lcm/lcm/jobs/job_get.py
+++ b/lcm/lcm/jobs/job_get.py
@@ -24,7 +24,6 @@ class GetJobInfoService(object):
self.response_id = response_id if response_id else 0
def do_biz(self):
- # logger.info("get job info, job_id=:%s, response_id=:%s" % (self.job_id, self.response_id))
jobs = JobUtil.query_job_status(self.job_id, self.response_id)
if not jobs:
return {"jobId": self.job_id}
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
index 09e209db..41c9758b 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
@@ -93,7 +93,6 @@ class TestNFTerminate(TestCase):
TermVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
self.assert_job_result(self.job_id, 255, "VnfInst(%s) does not exist" % self.nf_inst_id)
-
@mock.patch.object(restcall, 'call_req')
@mock.patch.object(api, 'call')
def test_terminate_vnf_success(self, mock_call, mock_call_req):
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
index e43e8fa5..47c0372a 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
@@ -49,7 +49,9 @@ class TestNFInstantiate(TestCase):
@mock.patch.object(restcall, 'call_req')
def test_create_vnf_identifier(self, mock_call_req):
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222', 'csar_id': '2222','vnfd_id':'111'}]), '200']
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
+ 'csar_id': '2222',
+ 'vnfd_id': '111'}]), '200']
r2_get_rawdata_from_catalog = [0, json.JSONEncoder().encode(vnfd_rawdata), '200']
mock_call_req.side_effect = [r1_get_csarid_by_vnfdid, r2_get_rawdata_from_catalog]
data = {
@@ -85,7 +87,9 @@ class TestNFInstantiate(TestCase):
NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
- r1_get_csarid_by_vnfdid = [1, json.JSONEncoder().encode([{'package_id': '222', 'csar_id': '2222','vnfd_id':'111'}]), '200']
+ r1_get_csarid_by_vnfdid = [1, json.JSONEncoder().encode([{'package_id': '222',
+ 'csar_id': '2222',
+ 'vnfd_id': '111'}]), '200']
mock_call_req.side_effect = [r1_get_csarid_by_vnfdid]
self.nf_inst_id = '1111'
self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
@@ -99,7 +103,9 @@ class TestNFInstantiate(TestCase):
NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222', 'csar_id': '2222','vnfd_id':'111'}]), '200']
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
+ 'csar_id': '2222',
+ 'vnfd_id': '111'}]), '200']
r2_get_rawdata_from_catalog = [1, json.JSONEncoder().encode(vnfd_rawdata), '200']
mock_call_req.side_effect = [r1_get_csarid_by_vnfdid, r2_get_rawdata_from_catalog]
self.nf_inst_id = '1111'
@@ -114,7 +120,9 @@ class TestNFInstantiate(TestCase):
NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222', 'csar_id': '2222','vnfd_id':'111'}]), '200']
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
+ 'csar_id': '2222',
+ 'vnfd_id': '111'}]), '200']
r2_get_rawdata_from_catalog = [0, json.JSONEncoder().encode(vnfd_rawdata), '200']
r3_apply_grant_result = [1, json.JSONEncoder().encode(
{"vim": {"vimid": 'vimid_1', "accessinfo": {"tenant": 'tenantname_1'}}}), '200']
@@ -132,7 +140,9 @@ class TestNFInstantiate(TestCase):
NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222', 'csar_id': '2222','vnfd_id':'111'}]), '200']
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
+ 'csar_id': '2222',
+ 'vnfd_id': '111'}]), '200']
r2_get_rawdata_from_catalog = [0, json.JSONEncoder().encode(vnfd_rawdata), '200']
r3_apply_grant_result = [0, json.JSONEncoder().encode(
{"vim": {"vimid": 'vimid_1', "accessinfo": {"tenant": 'tenantname_1'}}}), '200']
@@ -151,7 +161,9 @@ class TestNFInstantiate(TestCase):
NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
- r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222', 'csar_id': '2222','vnfd_id':'111'}]), '200']
+ r1_get_csarid_by_vnfdid = [0, json.JSONEncoder().encode([{'package_id': '222',
+ 'csar_id': '2222',
+ 'vnfd_id': '111'}]), '200']
r2_get_rawdata_from_catalog = [0, json.JSONEncoder().encode(vnfd_rawdata), '200']
r3_apply_grant_result = [0, json.JSONEncoder().encode(
{"vim": {"vimid": 'vimid_1', "accessinfo": {"tenant": 'tenantname_1'}}}), '200']
diff --git a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py
index 85df23cd..7c08e90b 100644
--- a/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py
+++ b/lcm/lcm/nf/vnfs/vnf_cancel/term_vnf.py
@@ -16,7 +16,7 @@ import traceback
from threading import Thread
from lcm.nf.vnfs.const import VNF_STATUS
-from lcm.pub.database.models import JobStatusModel, NfInstModel, VmInstModel, NetworkInstModel, StorageInstModel, \
+from lcm.pub.database.models import NfInstModel, VmInstModel, NetworkInstModel, StorageInstModel, \
FlavourInstModel, PortInstModel, SubNetworkInstModel, VNFCInstModel
from lcm.pub.exceptions import NFLCMException
from lcm.pub.msapi.nfvolcm import apply_grant_to_nfvo, notify_lcm_to_nfvo
@@ -38,7 +38,7 @@ class TermVnf(Thread):
self.gracefulTerminationTimeout = ignore_case_get(self.data, "gracefulTerminationTimeout")
self.apply_result = None
self.notify_data = None
- self.inst_resource = {'volumn': [], # [{"vim_id": ignore_case_get(ret, "vim_id")},{}]
+ self.inst_resource = {'volumn': [],
'network': [],
'subnet': [],
'port': [],
@@ -97,7 +97,6 @@ class TermVnf(Thread):
def query_inst_resource(self):
logger.info('[query_resource begin]:inst_id=%s' % self.nf_inst_id)
- # query_volumn_resource
vol_list = StorageInstModel.objects.filter(instid=self.nf_inst_id, is_predefined=1)
for vol in vol_list:
vol_info = {}
@@ -109,7 +108,6 @@ class TermVnf(Thread):
self.inst_resource['volumn'].append(vol_info)
logger.info('[query_volumn_resource]:ret_volumns=%s' % self.inst_resource['volumn'])
- # query_network_resource
network_list = NetworkInstModel.objects.filter(instid=self.nf_inst_id, is_predefined=1)
for network in network_list:
network_info = {}
@@ -121,7 +119,6 @@ class TermVnf(Thread):
self.inst_resource['network'].append(network_info)
logger.info('[query_network_resource]:ret_networks=%s' % self.inst_resource['network'])
- # query_subnetwork_resource
subnetwork_list = SubNetworkInstModel.objects.filter(instid=self.nf_inst_id, is_predefined=1)
for subnetwork in subnetwork_list:
subnetwork_info = {}
@@ -133,7 +130,6 @@ class TermVnf(Thread):
self.inst_resource['subnet'].append(subnetwork_info)
logger.info('[query_subnetwork_resource]:ret_networks=%s' % self.inst_resource['subnet'])
- # query_port_resource
port_list = PortInstModel.objects.filter(instid=self.nf_inst_id, is_predefined=1)
for port in port_list:
port_info = {}
@@ -145,7 +141,6 @@ class TermVnf(Thread):
self.inst_resource['port'].append(port_info)
logger.info('[query_port_resource]:ret_networks=%s' % self.inst_resource['port'])
- # query_flavor_resource
flavor_list = FlavourInstModel.objects.filter(instid=self.nf_inst_id, is_predefined=1)
for flavor in flavor_list:
flavor_info = {}
@@ -157,7 +152,6 @@ class TermVnf(Thread):
self.inst_resource['flavor'].append(flavor_info)
logger.info('[query_flavor_resource]:ret_networks=%s' % self.inst_resource['flavor'])
- # query_vm_resource
vm_list = VmInstModel.objects.filter(instid=self.nf_inst_id, is_predefined=1)
for vm in vm_list:
vm_info = {}
@@ -221,12 +215,6 @@ class TermVnf(Thread):
'affectedVnfc': affected_vnfc,
'affectedVirtualLink': affected_vl,
'affectedVirtualStorage': affected_vs,
- # "vnfdmodule": allocate_data,
- # "additionalParam": addition_param,
- # "nfvoInstanceId": self.nfvo_inst_id,
- # "vnfmInstanceId": self.vnfm_inst_id,
- # 'affectedcapacity': affectedcapacity,
- # 'affectedService': [],
'affectedCp': affected_cp
}
logger.info('content_args=%s' % self.notify_data)
diff --git a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py
index 41eeda43..0a901801 100644
--- a/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py
+++ b/lcm/lcm/nf/vnfs/vnf_create/create_vnf_identifier.py
@@ -32,6 +32,7 @@ class CreateVnf:
self.vnfd_id = ignore_case_get(self.data, "vnfdId")
self.vnf_instance_mame = ignore_case_get(self.data, "vnfInstanceName")
self.description = ignore_case_get(self.data, "vnfInstanceDescription")
+ self.vnfd = None
self.package_info = ''
self.package_id = ''
self.csar_id = ''
@@ -45,14 +46,12 @@ class CreateVnf:
nf_inst_id = str(uuid.uuid4())
try:
- # get package_info from nslcm by vnfd_id
self.package_info = get_packageinfo_by_vnfdid(self.vnfd_id)
for val in self.package_info:
if self.vnfd_id == ignore_case_get(val, "vnfd_id"):
self.package_id = ignore_case_get(val, "csar_id")
break
- # get rawdata from catalog by csar_id
raw_data = query_rawdata_from_catalog(self.package_id, self.data)
self.vnfd = toscautil.convert_vnfd_model(raw_data["rawData"]) # convert to inner json
self.vnfd = json.JSONDecoder().decode(self.vnfd)
@@ -74,6 +73,8 @@ class CreateVnf:
vnfSoftwareVersion='', create_time=now_time())
vnf_inst = NfInstModel.objects.get(nfinstid=nf_inst_id)
- logger.debug('id is [%s],name is [%s],vnfd_id is [%s],vnfd_model is [%s],description is [%s],create_time is [%s]' %
- (vnf_inst.nfinstid, vnf_inst.nf_name, vnf_inst.vnfdid, vnf_inst.vnfd_model, vnf_inst.nf_desc, vnf_inst.create_time))
+ logger.debug('id is [%s],name is [%s],vnfd_id is [%s],vnfd_model is [%s],'
+ 'description is [%s],create_time is [%s]' %
+ (vnf_inst.nfinstid, vnf_inst.nf_name, vnf_inst.vnfdid,
+ vnf_inst.vnfd_model, vnf_inst.nf_desc, vnf_inst.create_time))
return nf_inst_id
diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
index c950e153..361a3011 100644
--- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
+++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
@@ -41,15 +41,9 @@ class InstVnf(Thread):
self.vnfd_id = ''
self.nfvo_inst_id = ''
self.vnfm_inst_id = ''
- self.csar_id = ''
+ self.package_id = ''
+ # self.csar_id = ''
self.vnfd_info = []
- # self.inst_resource = {'volumn': [], # [{"vim_id": ignore_case_get(ret, "vim_id")},{}]
- # 'network': [],
- # 'subnet': [],
- # 'port': [],
- # 'flavor': [],
- # 'vm': [],
- # }
def run(self):
try:
@@ -61,6 +55,7 @@ class InstVnf(Thread):
except NFLCMException as e:
self.vnf_inst_failed_handle(e.message)
except:
+ logger.error(traceback.format_exc())
self.vnf_inst_failed_handle('unexpected exception')
def inst_pre(self):
@@ -68,21 +63,18 @@ class InstVnf(Thread):
if not vnf_insts.exists():
raise NFLCMException('VNF nf_inst_id is not exist.')
- # self.vnfm_inst_id = vnf_insts[0].vnfm_inst_id
if vnf_insts[0].status != 'NOT_INSTANTIATED':
raise NFLCMException('VNF instantiationState is not NOT_INSTANTIATED.')
JobUtil.add_job_status(self.job_id, 5, 'Get packageinfo by vnfd_id')
- # get csar_id from nslcm by vnfd_id
self.vnfd_id = vnf_insts[0].vnfdid
- self.package_info = get_packageinfo_by_vnfdid(self.vnfd_id)
- for val in self.package_info:
+ package_info = get_packageinfo_by_vnfdid(self.vnfd_id)
+ for val in package_info:
if self.vnfd_id == ignore_case_get(val, "vnfd_id"):
self.package_id = ignore_case_get(val, "csar_id")
break
JobUtil.add_job_status(self.job_id, 10, 'Get rawdata from catalog by csar_id')
- # get rawdata from catalog by csar_id
input_parameters = []
for key, val in self.data['additionalParams'].items():
input_parameters.append({"key": key, "value": val})
@@ -93,8 +85,7 @@ class InstVnf(Thread):
self.vnfd_info = vnfd_model_dict # just for test
self.update_cps()
- self.checkParameterExist()
- # update NfInstModel
+ self.check_parameter_exist()
NfInstModel.objects.filter(nfinstid=self.nf_inst_id).\
update(flavour_id=ignore_case_get(self.data, "flavourId"),
input_params=self.data,
@@ -106,7 +97,6 @@ class InstVnf(Thread):
def apply_grant(self):
logger.info('[NF instantiation] send resource grand request to nfvo start')
- # self.check_vm_capacity()
content_args = {'vnfInstanceId': self.nf_inst_id, 'vnfDescriptorId': '',
'lifecycleOperation': 'Instantiate', 'jobId': self.job_id,
'addResource': [], 'removeResource': [],
@@ -122,23 +112,21 @@ class InstVnf(Thread):
res_index += 1
logger.info('content_args=%s' % content_args)
- self.apply_result = apply_grant_to_nfvo(content_args)
- vim_info = ignore_case_get(self.apply_result, "vim")
+ apply_result = apply_grant_to_nfvo(content_args)
+ vim_info = ignore_case_get(apply_result, "vim")
- # update vnfd_info
- for vdu in self.vnfd_info["vdus"]:
+ for vdu in ignore_case_get(self.vnfd_info, "vdus"):
if "location_info" in vdu["properties"]:
vdu["properties"]["location_info"]["vimid"] = ignore_case_get(vim_info, "vimid")
vdu["properties"]["location_info"]["tenant"] = ignore_case_get(
ignore_case_get(vim_info, "accessinfo"), "tenant")
else:
- vdu["properties"]["location_info"] = {"vimid":ignore_case_get(vim_info, "vimid"),
- "tenant":ignore_case_get(
- ignore_case_get(vim_info, "accessinfo"), "tenant")}
+ vdu["properties"]["location_info"] = {
+ "vimid": ignore_case_get(vim_info, "vimid"),
+ "tenant": ignore_case_get(ignore_case_get(vim_info, "accessinfo"), "tenant")}
- # update resources_table
NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='INSTANTIATED', lastuptime=now_time())
- JobUtil.add_job_status(self.job_id,20, 'Nf instancing apply grant finish')
+ JobUtil.add_job_status(self.job_id, 20, 'Nf instancing apply grant finish')
logger.info("Nf instancing apply grant finish")
def create_res(self):
@@ -153,17 +141,17 @@ class InstVnf(Thread):
affected_vnfc = []
vnfcs = VNFCInstModel.objects.filter(instid=self.nf_inst_id)
for vnfc in vnfcs:
- vmResource = {}
+ vm_resource = {}
if vnfc.vmid:
vm = VmInstModel.objects.filter(vmid=vnfc.vmid)
if vm:
- vmResource = {'vimId': vm[0].vimid, 'resourceId': vm[0].resouceid,
- 'resourceName': vm[0].vmname, 'resourceType': 'vm'}
+ vm_resource = {'vimId': vm[0].vimid, 'resourceId': vm[0].resouceid,
+ 'resourceName': vm[0].vmname, 'resourceType': 'vm'}
affected_vnfc.append(
{'vnfcInstanceId': vnfc.vnfcinstanceid,
'vduId': vnfc.vduid,
'changeType': 'added',
- 'computeResource': vmResource})
+ 'computeResource': vm_resource})
affected_vl = []
networks = NetworkInstModel.objects.filter(instid=self.nf_inst_id)
for network in networks:
@@ -200,31 +188,13 @@ class InstVnf(Thread):
'affectedVnfc': affected_vnfc,
'affectedVirtualLink': affected_vl,
'affectedVirtualStorage': affected_vs,
- # "vnfdmodule": allocate_data,
- # "additionalParam": addition_param,
- # "nfvoInstanceId": self.nfvo_inst_id,
- # "vnfmInstanceId": self.vnfm_inst_id,
- # 'affectedcapacity': affectedcapacity,
- # 'affectedService': [],
'affectedCp': affected_cp
}
logger.info('content_args=%s' % content_args)
- # call rest api
resp = notify_lcm_to_nfvo(content_args)
logger.info('[NF instantiation] get lcm response %s' % resp)
logger.info('[NF instantiation] send notify request to nfvo end')
- # def load_nfvo_config(self):
- # logger.info("[NF instantiation]get nfvo connection info start")
- # reg_info = NfvoRegInfoModel.objects.filter(vnfminstid='vnfm111').first()
- # if reg_info:
- # self.vnfm_inst_id = reg_info.vnfminstid
- # self.nfvo_inst_id = reg_info.nfvoid
- # logger.info("[NF instantiation] Registered nfvo id is [%s]" % self.nfvo_inst_id)
- # else:
- # raise NFLCMException("Nfvo was not registered")
- # logger.info("[NF instantiation]get nfvo connection info end")
-
def vnf_inst_failed_handle(self, error_msg):
logger.error('VNF instantiation failed, detail message: %s' % error_msg)
NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='failed', lastuptime=now_time())
@@ -232,12 +202,8 @@ class InstVnf(Thread):
def do_notify(self, res_type, ret):
logger.info('creating [%s] resource' % res_type)
- # 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")})
JobUtil.add_job_status(self.job_id, 25, 'Create vloumns!')
StorageInstModel.objects.create(
storageid=str(uuid.uuid4()),
@@ -254,10 +220,6 @@ class InstVnf(Thread):
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")})
- # 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=str(uuid.uuid4()),
@@ -271,16 +233,12 @@ class InstVnf(Thread):
vlantrans=get_boolean(ignore_case_get(ret, "vlanTransparent")),
is_shared=get_boolean(ignore_case_get(ret, "shared")),
routerExternal=get_boolean(ignore_case_get(ret, "routerExternal")),
- insttype = 0,
+ insttype=0,
is_predefined=ignore_case_get(ret, "returnCode"),
nodeId=ignore_case_get(ret, "nodeId"),
- instid = self.nf_inst_id)
+ 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")})
- # 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=str(uuid.uuid4()),
@@ -301,10 +259,6 @@ class InstVnf(Thread):
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")})
- # 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=str(uuid.uuid4()),
@@ -314,8 +268,8 @@ class InstVnf(Thread):
vimid=ignore_case_get(ret, "vimId"),
resouceid=ignore_case_get(ret, "id"),
tenant=ignore_case_get(ret, "tenantId"),
- macaddress = ignore_case_get(ret, "macAddress"),
- ipaddress = ignore_case_get(ret, "ip"),
+ macaddress=ignore_case_get(ret, "macAddress"),
+ ipaddress=ignore_case_get(ret, "ip"),
typevirtualnic=ignore_case_get(ret, "vnicType"),
securityGroups=ignore_case_get(ret, "securityGroups"),
insttype=0,
@@ -324,10 +278,6 @@ class InstVnf(Thread):
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")})
- # self.inst_resource['flavor'].append({"vim_id": "1"}, {"res_id": "2"})
JobUtil.add_job_status(self.job_id, 60, 'Create flavors!')
FlavourInstModel.objects.create(
flavourid=str(uuid.uuid4()),
@@ -346,10 +296,6 @@ class InstVnf(Thread):
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")})
- # self.inst_resource['vm'].append({"vim_id": "1"}, {"res_id": "2"})
JobUtil.add_job_status(self.job_id, 70, 'Create vms!')
vm_id = str(uuid.uuid4())
VmInstModel.objects.create(
@@ -376,34 +322,14 @@ class InstVnf(Thread):
instid=self.nf_inst_id,
vmid=vm_id)
- # 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 update_cps(self):
for extlink in ignore_case_get(self.data, "extVirtualLinks"):
- for cp in self.vnfd_info["cps"]:
+ for cp in ignore_case_get(self.vnfd_info, "cps"):
cpdid = ignore_case_get(extlink, "cpdId")
if cpdid == ignore_case_get(cp, "cp_id"):
cp["networkId"] = ignore_case_get(extlink, "resourceId")
cp["subnetId"] = ignore_case_get(extlink, "resourceSubnetId")
break
- pass
- def checkParameterExist(self):
- # if ignore_case_get(self.data, "flavourId") not in self.vnfd_info:
- # raise NFLCMException('Input parameter is not defined in vnfd_info.')
+ def check_parameter_exist(self):
pass