3d50a1b1ea574fdae7a464b1789cd7297f3be8e5
[bottlenecks.git] / vstf / vstf / common / cfgparser.py
1 """
2 Created on 2015-8-5
3
4 @author: c00225995
5 """
6 import os
7 from oslo.config import cfg
8
9
10 class CfgParser(object):
11     def __init__(self, config_file):
12         super(CfgParser, self).__init__()
13         if os.path.isfile(config_file) is False:
14             raise Exception('The config file not found <%s>' % config_file)
15         self.config_file = config_file
16         self.CONF = cfg.ConfigOpts()
17
18     def register_my_opts(self, opts, name=None):
19         if name:
20             self.CONF.register_opts(opts, name)
21         else:
22             self.CONF.register_opts(opts)
23
24     def parse(self):
25         #  self.register_my_opts(opts, name=name)
26         self.CONF(args=[], default_config_files=[self.config_file])
27         return self.CONF