add running profiler in python
[doctor.git] / tests / config.py
1 ##############################################################################\r
2 # Copyright (c) 2017 ZTE Corporation and others.\r
3 #\r
4 # All rights reserved. This program and the accompanying materials\r
5 # are made available under the terms of the Apache License, Version 2.0\r
6 # which accompanies this distribution, and is available at\r
7 # http://www.apache.org/licenses/LICENSE-2.0\r
8 ##############################################################################\r
9 import itertools\r
10 \r
11 from oslo_config import cfg\r
12 \r
13 import alarm\r
14 import consumer\r
15 import image\r
16 import instance\r
17 import installer\r
18 import network\r
19 import inspector\r
20 import monitor\r
21 import os_clients\r
22 import profiler_poc\r
23 import user\r
24 \r
25 \r
26 def list_opts():\r
27     return [\r
28         ('installer', installer.OPTS),\r
29         ('monitor', monitor.OPTS),\r
30         ('inspector', inspector.OPTS),\r
31         ('consumer', consumer.OPTS),\r
32         ('DEFAULT', itertools.chain(\r
33             os_clients.OPTS,\r
34             image.OPTS,\r
35             user.OPTS,\r
36             network.OPTS,\r
37             instance.OPTS,\r
38             alarm.OPTS,\r
39             profiler_poc.OPTS))\r
40     ]\r
41 \r
42 \r
43 def prepare_conf(args=None, conf=None, config_files=None):\r
44     if conf is None:\r
45         conf = cfg.ConfigOpts()\r
46 \r
47     for group, options in list_opts():\r
48         conf.register_opts(list(options),\r
49                            group=None if group == 'DEFAULT' else group)\r
50 \r
51     conf(args, project='doctor', validate_default_values=True,\r
52          default_config_files=config_files)\r
53 \r
54     return conf\r