1 # Copyright 2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 from threading import Thread
19 from lcm.pub.exceptions import NFLCMException
21 logger = logging.getLogger(__name__)
24 class InstVnf(Thread):
25 def __init__(self, data, nf_inst_id, job_id):
26 super(InstVnf, self).__init__()
28 self.nf_inst_id = nf_inst_id
35 self.apply_grant(args)
37 self.check_res_status(args)
38 self.wait_inst_finish(args)
40 except NFLCMException as e:
41 self.inst_exception(e.message)
44 logger.error(traceback.format_exc())
45 self.inst_exception('unexpected exception')
47 def inst_pre(self, args):
49 logger.info('inst_pre, args=%s' % args)
50 # InstPreTask(args).do_biz()
51 return {'result': '100', 'sessionid': '', 'msg': 'Nf instancing preprocess finish', 'context': {}}
52 except Exception as e:
53 logger.error('Nf instancing preprocess exception=%s' % e.message)
54 logger.error(traceback.format_exc())
55 return {'result': '255', 'msg': 'Nf instancing preprocess exception', 'context': {}}
57 def apply_grant(self, args):
59 logger.info('apply_grant, args=%s' % args)
60 # ApplyGrantTask(args).do_biz()
61 return {'result': '100', 'msg': 'Nf instancing apply grant finish', 'context': {}}
62 except Exception as e:
63 logger.error('Nf instancing apply grant exception=%s' % e.message)
64 logger.error(traceback.format_exc())
65 return {'result': '255', 'msg': 'Nf instancing apply grant exception', 'context': {}}
67 def apply_res(self, args):
69 logger.info('apply_res, args=%s' % args)
70 # ApplyResTask(args).do_biz()
71 return {'result': '100', 'msg': 'Nf instancing apply resource finish', 'context': {}}
72 except Exception as e:
73 logger.error('Nf instancing apply resource exception=%s' % e.message)
74 logger.error(traceback.format_exc())
75 return {'result': '255', 'msg': 'Nf instancing apply resource exception', 'context': {}}
77 def check_res_status(self, args):
79 logger.info('check_res_status, args=%s' % args)
80 # CheckResStatusTask(args).do_biz()
81 return {'result': '100', 'msg': 'Nf instancing check resource status finish', 'context': {}}
82 except Exception as e:
83 logger.error('Nf instancing check resource status exception=%s' % e.message)
84 logger.error(traceback.format_exc())
85 return {'result': '255', 'msg': 'Nf instancing check resource status exception', 'context': {}}
87 def wait_inst_finish(self, args):
89 logger.info('wait_inst_finish, args=%s' % args)
90 # WaitInstFinishTask(args).do_biz()
91 return {'result': '100', 'msg': 'Nf instancing wait finish', 'context': {}}
92 except Exception as e:
93 logger.error('Nf instancing wait exception=%s' % e.message)
94 logger.error(traceback.format_exc())
95 return {'result': '255', 'msg': 'Nf instancing wait exception', 'context': {}}
97 def lcm_notify(self, args):
99 logger.info('lcm_notify, args=%s' % args)
100 # LcmNotifyTask(args).do_biz()
101 return {'result': '100', 'msg': 'Nf instancing lcm notify finish', 'context': {}}
102 except Exception as e:
103 logger.error('Nf instancing lcm notify exception=%s' % e.message)
104 logger.error(traceback.format_exc())
105 return {'result': '255', 'msg': 'Nf instancing lcm notify exception', 'context': {}}
107 def inst_exception(self, args):
109 logger.info('inst_exception, args=%s' % args)
110 # InstExceptionTask(args).do_biz()
111 return {'result': '100', 'msg': 'Nf instancing exception process finish', 'context': {}}
112 except Exception as e:
113 logger.error('Nf instancing exception process exception=%s' % e.message)
114 logger.error(traceback.format_exc())
115 return {'result': '255', 'msg': 'Nf instancing exception process exception', 'context': {}}