1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 from oslo.config import cfg
14 class CfgParser(object):
15 def __init__(self, config_file):
16 super(CfgParser, self).__init__()
17 if os.path.isfile(config_file) is False:
18 raise Exception('The config file not found <%s>' % config_file)
19 self.config_file = config_file
20 self.CONF = cfg.ConfigOpts()
22 def register_my_opts(self, opts, name=None):
24 self.CONF.register_opts(opts, name)
26 self.CONF.register_opts(opts)
29 # self.register_my_opts(opts, name=name)
30 self.CONF(args=[], default_config_files=[self.config_file])