summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-02-14 09:36:10 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-02-14 09:36:10 +0800
commitacd07e866f9e6934a66d0bc0d013b259ec9fdd0a (patch)
treee9d100b39e6883ba033b5f93e0b06f3f068d2a4f /lcm
parentddbced3e29882aed620a2729a6c43e533cfb7a4c (diff)
Optimizing instantiation code structure
Change-Id: I692924d2838f83a3c929480ae9d837364ffd7400 Issue-Id: GVNFM-8 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.py94
-rw-r--r--lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py65
2 files changed, 69 insertions, 90 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
index 64f07d36..08e55868 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
@@ -27,54 +27,6 @@ from lcm.pub.utils import restcall
from lcm.pub.vimapi import adaptor
from lcm.pub.utils.jobutil import JobUtil
-inst_req_data = {
- "flavourId": "flavour_1",
- "instantiationLevelId": "instantiationLevel_1",
- "extVirtualLinks": [
- {
- "vlInstanceId": "1",
- "vim": {
- "vimInfoId": "1",
- "vimId": "1",
- "interfaceInfo": {
- "vimType": "vim",
- "apiVersion": "v2",
- "protocolType": "http"
- },
- "accessInfo": {
- "tenant": "tenant_vCPE",
- "username": "vCPE",
- "password": "vCPE_321"
- },
- "interfaceEndpoint": "http://10.43.21.105:80/"
- },
- "resourceId": "1246",
- "extCps": [
- {
- "cpdId": "11",
- "addresses": [
- {
- "addressType": "MAC",
- "l2AddressData": "00:f3:43:20:a2:a3"
- },
- {
- "addressType": "IP",
- "l3AddressData": {
- "iPAddressType": "IPv4",
- "iPAddress": "192.168.104.2"
- }
- }
- ],
- "numDynamicAddresses": 0
- }
- ]
- }
- ],
- "localizationLanguage": "en_US",
- "additionalParams": {}
-}
-
-
class TestNsInstantiate(TestCase):
def setUp(self):
self.client = Client()
@@ -228,6 +180,52 @@ class TestNsInstantiate(TestCase):
# InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
# self.assert_job_result(self.job_id, 100, "Instantiate Vnf success.")
+inst_req_data = {
+ "flavourId": "flavour_1",
+ "instantiationLevelId": "instantiationLevel_1",
+ "extVirtualLinks": [
+ {
+ "vlInstanceId": "1",
+ "vim": {
+ "vimInfoId": "1",
+ "vimId": "1",
+ "interfaceInfo": {
+ "vimType": "vim",
+ "apiVersion": "v2",
+ "protocolType": "http"
+ },
+ "accessInfo": {
+ "tenant": "tenant_vCPE",
+ "username": "vCPE",
+ "password": "vCPE_321"
+ },
+ "interfaceEndpoint": "http://10.43.21.105:80/"
+ },
+ "resourceId": "1246",
+ "extCps": [
+ {
+ "cpdId": "11",
+ "addresses": [
+ {
+ "addressType": "MAC",
+ "l2AddressData": "00:f3:43:20:a2:a3"
+ },
+ {
+ "addressType": "IP",
+ "l3AddressData": {
+ "iPAddressType": "IPv4",
+ "iPAddress": "192.168.104.2"
+ }
+ }
+ ],
+ "numDynamicAddresses": 0
+ }
+ ]
+ }
+ ],
+ "localizationLanguage": "en_US",
+ "additionalParams": {}
+}
vnfd_model_dict = {
'local_storages': [],
diff --git a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
index af5b51cc..910fefeb 100644
--- a/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
+++ b/lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
@@ -163,21 +163,8 @@ class InstVnf(Thread):
def create_res(self):
logger.info("[NF instantiation] create resource start")
-
adaptor.create_vim_res(self.vnfd_info, self.do_notify, self.do_rollback)
- # volumns = ignore_case_get(self.data, "volumn_storages")
- #create_volumns(volumns)
- # JobUtil.add_job_status(self.job_id, 35, 'Nf instancing create resource(volumn_storages) finish')
- #
- # vls = ignore_case_get(self.data, "vls")
- # # create_networks(vls)
- # JobUtil.add_job_status(self.job_id, 55, 'Nf instancing create resource(networks) finish')
- #
- # vdus = ignore_case_get(self.data, "vdus")
- # # create_vdus(vdus)
- # JobUtil.add_job_status(self.job_id, 75, 'Nf instancing create resource(vms) finish')
-
JobUtil.add_job_status(self.job_id, 70, '[NF instantiation] create resource finish')
logger.info("[NF instantiation] create resource finish")
@@ -236,35 +223,30 @@ class InstVnf(Thread):
# self.add_job(43, 'INST_DPLY_VM_PRGS')
logger.info("[NF instantiation] confirm all vms are active end")
- def wait_inst_finish(self, args):
- try:
- logger.info('wait_inst_finish, args=%s' % args)
- # WaitInstFinishTask(args).do_biz()
- return {'result': '100', 'msg': 'Nf instancing wait finish', 'context': {}}
- except Exception as e:
- logger.error('Nf instancing wait exception=%s' % e.message)
- logger.error(traceback.format_exc())
- return {'result': '255', 'msg': 'Nf instancing wait exception', 'context': {}}
+ # def wait_inst_finish(self, args):
+ # try:
+ # logger.info('wait_inst_finish, args=%s' % args)
+ # # WaitInstFinishTask(args).do_biz()
+ # return {'result': '100', 'msg': 'Nf instancing wait finish', 'context': {}}
+ # except Exception as e:
+ # logger.error('Nf instancing wait exception=%s' % e.message)
+ # logger.error(traceback.format_exc())
+ # return {'result': '255', 'msg': 'Nf instancing wait exception', 'context': {}}
def lcm_notify(self, args):
- try:
- logger.info('lcm_notify, args=%s' % args)
- # LcmNotifyTask(args).do_biz()
- return {'result': '100', 'msg': 'Nf instancing lcm notify finish', 'context': {}}
- except Exception as e:
- logger.error('Nf instancing lcm notify exception=%s' % e.message)
- logger.error(traceback.format_exc())
- return {'result': '255', 'msg': 'Nf instancing lcm notify exception', 'context': {}}
-
- def rollback(self, args):
- try:
- logger.info('inst_exception, args=%s' % args)
- # InstExceptionTask(args).do_biz()
- return {'result': '100', 'msg': 'Nf instancing exception process finish', 'context': {}}
- except Exception as e:
- logger.error('Nf instancing exception process exception=%s' % e.message)
- logger.error(traceback.format_exc())
- return {'result': '255', 'msg': 'Nf instancing exception process exception', 'context': {}}
+ logger.info('lcm_notify, args=%s' % args)
+ # LcmNotifyTask(args).do_biz()
+ return {'result': '100', 'msg': 'Nf instancing lcm notify finish', 'context': {}}
+
+ # def rollback(self, args):
+ # try:
+ # logger.info('inst_exception, args=%s' % args)
+ # # InstExceptionTask(args).do_biz()
+ # return {'result': '100', 'msg': 'Nf instancing exception process finish', 'context': {}}
+ # except Exception as e:
+ # logger.error('Nf instancing exception process exception=%s' % e.message)
+ # logger.error(traceback.format_exc())
+ # return {'result': '255', 'msg': 'Nf instancing exception process exception', 'context': {}}
def load_nfvo_config(self):
logger.info("[NF instantiation]get nfvo connection info start")
@@ -280,10 +262,9 @@ class InstVnf(Thread):
logger.error('VNF instantiation failed, detail message: %s' % error_msg)
NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='failed', lastuptime=now_time())
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 do_notify(self, res_type, progress, ret):
- # logger.info('add job, progress=%s, msgid=%s, args=%s' % (progress, msgid, args_))
+ logger.info('creating [%s] resource'%res_type)
progress = 20 + int(progress/2) #20-70
if res_type == adaptor.RES_VOLUME:
logger.info('Create vloumns!')