JIRA: BOTTLENECKS-29
[bottlenecks.git] / vstf / vstf / common / cfgparser.py
1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
3 #
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 ##############################################################################
9
10 import os
11 from oslo.config import cfg
12
13
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()
21
22     def register_my_opts(self, opts, name=None):
23         if name:
24             self.CONF.register_opts(opts, name)
25         else:
26             self.CONF.register_opts(opts)
27
28     def parse(self):
29         #  self.register_my_opts(opts, name=name)
30         self.CONF(args=[], default_config_files=[self.config_file])
31         return self.CONF