summaryrefslogtreecommitdiffstats
path: root/lcm
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-02-08 13:58:17 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-02-08 13:58:17 +0800
commita446d5a1f68bea260fc020cef892aa764d962c95 (patch)
treec40ab51d8654a3116798159ae4c0818926fd013b /lcm
parent462aded144f4cdfbe7a8c1546c603dc554003a34 (diff)
Decompose the VNF instance
Change-Id: Iae0b45e3cddc87f2a2c01b7817947708d1f2d1e3 Issue-Id:GVNFM-7 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
Diffstat (limited to 'lcm')
-rw-r--r--lcm/lcm/nf/vnfs/create_vnfs.py115
-rw-r--r--lcm/lcm/pub/exceptions.py2
2 files changed, 116 insertions, 1 deletions
diff --git a/lcm/lcm/nf/vnfs/create_vnfs.py b/lcm/lcm/nf/vnfs/create_vnfs.py
new file mode 100644
index 00000000..0dc5216c
--- /dev/null
+++ b/lcm/lcm/nf/vnfs/create_vnfs.py
@@ -0,0 +1,115 @@
+# Copyright 2017 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import logging
+import traceback
+from threading import Thread
+
+from lcm.pub.exceptions import NFLCMException
+
+logger = logging.getLogger(__name__)
+
+
+class CreateVnfs(Thread):
+ def __init__(self, data, nf_inst_id, job_id):
+ super(CreateVnfs, self).__init__()
+ self.data = data
+ self.nf_inst_id = nf_inst_id
+ self.job_id = job_id
+
+ def run(self):
+ try:
+ args = {}
+ self.inst_pre(args)
+ self.apply_grant(args)
+ self.apply_res(args)
+ self.check_res_status(args)
+ self.wait_inst_finish(args)
+ self.lcm_notify(args)
+ except NFLCMException as e:
+ self.inst_exception(e.message)
+ pass
+ except Exception:
+ logger.error(traceback.format_exc())
+ self.inst_exception('unexpected exception')
+
+ def inst_pre(self, args):
+ try:
+ logger.info('inst_pre, args=%s' % args)
+ # InstPreTask(args).do_biz()
+ return {'result': '100', 'sessionid': '', 'msg': 'Nf instancing preprocess finish', 'context': {}}
+ except Exception as e:
+ logger.error('Nf instancing preprocess exception=%s' % e.message)
+ logger.error(traceback.format_exc())
+ return {'result': '255', 'msg': 'Nf instancing preprocess exception', 'context': {}}
+
+ def apply_grant(self, args):
+ try:
+ logger.info('apply_grant, args=%s' % args)
+ # ApplyGrantTask(args).do_biz()
+ return {'result': '100', 'msg': 'Nf instancing apply grant finish', 'context': {}}
+ except Exception as e:
+ logger.error('Nf instancing apply grant exception=%s' % e.message)
+ logger.error(traceback.format_exc())
+ return {'result': '255', 'msg': 'Nf instancing apply grant exception', 'context': {}}
+
+ def apply_res(self, args):
+ try:
+ logger.info('apply_res, args=%s' % args)
+ # ApplyResTask(args).do_biz()
+ return {'result': '100', 'msg': 'Nf instancing apply resource finish', 'context': {}}
+ except Exception as e:
+ logger.error('Nf instancing apply resource exception=%s' % e.message)
+ logger.error(traceback.format_exc())
+ return {'result': '255', 'msg': 'Nf instancing apply resource exception', 'context': {}}
+
+ def check_res_status(self, args):
+ try:
+ logger.info('check_res_status, args=%s' % args)
+ # CheckResStatusTask(args).do_biz()
+ return {'result': '100', 'msg': 'Nf instancing check resource status finish', 'context': {}}
+ except Exception as e:
+ logger.error('Nf instancing check resource status exception=%s' % e.message)
+ logger.error(traceback.format_exc())
+ return {'result': '255', 'msg': 'Nf instancing check resource status 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 inst_exception(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': {}} \ No newline at end of file
diff --git a/lcm/lcm/pub/exceptions.py b/lcm/lcm/pub/exceptions.py
index e06632c7..274c0d06 100644
--- a/lcm/lcm/pub/exceptions.py
+++ b/lcm/lcm/pub/exceptions.py
@@ -13,5 +13,5 @@
# limitations under the License.
-class NSLCMException(Exception):
+class NFLCMException(Exception):
pass