2 # Copyright (c) 2015 All rights reserved
3 # This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
14 from utils_log import LOG, LOG_PATH
15 from abc import abstractmethod
18 class Service(object):
23 except Exception as ex:
25 LOG.error(traceback.format_exc())
26 LOG.error("For more logs check: %(log_path)s"
27 % {'log_path': LOG_PATH})
31 parser = self._create_cli_parser()
32 sys_args = parser.parse_args()
33 config = self.read_config(sys_args)
34 self.run(sys_args, config)
37 def run(self, sys_args, config):
42 def create_cli_parser(self, parser):
43 # Read in own sys args
46 def _create_cli_parser(self):
47 parser = argparse.ArgumentParser(description='OVS Debugger')
48 # parser.add_argument('-c', '--config', help="Path to config.yaml",
50 # parser.add_argument('--boolean', help="",
51 # required=False, action='store_true')
52 return self.create_cli_parser(parser)
54 def read_config(self, sys_args):
55 if not hasattr(sys_args, 'config'):
57 if not sys_args.config:
58 config_path = './etc/config.yaml'
60 config_path = sys_args.config
62 with open(config_path) as f:
64 except yaml.scanner.ScannerError as ex:
65 LOG.error("Yaml file corrupt. Try putting spaces after the "