Fix vnflcm samples pep8 error
[vfc/gvnfm/vnflcm.git] / lcm / lcm / samples / resources.py
1 # Copyright 2017 ZTE Corporation.
2 #
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
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 import logging
16 import threading
17 import traceback
18 import sys
19
20 from lcm.pub.vimapi import adaptor
21
22 logger = logging.getLogger(__name__)
23
24
25 class ResCreateThread(threading.Thread):
26     """
27     Create resource
28     """
29     def __init__(self, req_data):
30         threading.Thread.__init__(self)
31         self.data = req_data
32
33     def run(self):
34         try:
35             adaptor.create_vim_res(self.data, self.do_notify)
36         except:
37             logger.error(traceback.format_exc())
38             logger.error(str(sys.exc_info()))
39
40     def do_notify(self, res_type, ret):
41         logger.debug('ret of [%s] is %s', res_type, ret)
42
43
44 class ResDeleteThread(threading.Thread):
45     """
46     Delete resource
47     """
48     def __init__(self, req_data):
49         threading.Thread.__init__(self)
50         self.data = req_data
51
52     def run(self):
53         try:
54             adaptor.delete_vim_res(self.data, self.do_notify)
55         except:
56             logger.error(traceback.format_exc())
57             logger.error(str(sys.exc_info()))
58
59     def do_notify(self, res_type, res_id):
60         logger.debug('Delete %s(%s)', res_type, res_id)