7a0bef2da3ad5d3bf7a273f4ff1d84be17c14acf
[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 from oslo_config import cfg\r
11 \r
12 import image\r
13 import os_clients\r
14 import user\r
15 \r
16 \r
17 def list_opts():\r
18     return [\r
19         ('DEFAULT', itertools.chain(\r
20             os_clients.OPTS,\r
21             image.OPTS,\r
22             user.OPTS))\r
23     ]\r
24 \r
25 \r
26 def prepare_conf(conf=None):\r
27     if conf is None:\r
28         conf = cfg.ConfigOpts()\r
29 \r
30     for group, options in list_opts():\r
31         conf.register_opts(list(options),\r
32                            group=None if group == 'DEFAULT' else group)\r
33 \r
34     return conf\r