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
16 from ssh_util import SSH_CONFIG
19 class Service(object):
24 except Exception as ex:
26 LOG.error(traceback.format_exc())
27 LOG.error("For more logs check: %(log_path)s"
28 % {'log_path': LOG_PATH})
32 parser = self._create_cli_parser()
33 sys_args = parser.parse_args()
34 config = self.read_config(sys_args)
35 if sys_args.ssh_key_file:
36 SSH_CONFIG['ID_RSA_PATH'] = sys_args.ssh_key_file
37 self.run(sys_args, config)
40 def run(self, sys_args, config):
45 def create_cli_parser(self, parser):
46 # Read in own sys args
49 def _create_cli_parser(self):
50 parser = argparse.ArgumentParser(description='OVS Debugger')
51 # parser.add_argument('-c', '--config', help="Path to config.yaml",
53 # parser.add_argument('--boolean', help="",
54 # required=False, action='store_true')
55 parser.add_argument('--ssh-key-file',
56 help="SSH private key file to use",
58 return self.create_cli_parser(parser)
60 def read_config(self, sys_args):
61 if not hasattr(sys_args, 'config'):
63 if not sys_args.config:
64 config_path = './etc/config.yaml'
66 config_path = sys_args.config
68 with open(config_path) as f:
70 except yaml.scanner.ScannerError as ex:
71 LOG.error("Yaml file corrupt. Try putting spaces after the "