Browse Source

Merge "Fix use of the oslo-config-generator"

Jenkins 4 years ago
parent
commit
e8cdd14bc8

+ 0
- 5
config-generator.conf View File

@@ -1,5 +0,0 @@
1
-[DEFAULT]
2
-output_file = etc/muranoagent/muranoagent.conf.sample
3
-namespace = muranoagent.common.config
4
-namespace = muranoagent.openstack.common.log
5
-namespace = muranoagent.openstack.common.eventlet_backdoor

+ 3
- 0
etc/oslo-config-generator/muranoagent.conf View File

@@ -0,0 +1,3 @@
1
+[DEFAULT]
2
+output_file = etc/muranoagent/muranoagent.conf.sample
3
+namespace = muranoagent

+ 7
- 8
muranoagent/common/config.py View File

@@ -17,7 +17,6 @@
17 17
 Routines for configuring Murano-Agent
18 18
 """
19 19
 
20
-import copy
21 20
 import logging
22 21
 import logging.config
23 22
 import logging.handlers
@@ -29,9 +28,12 @@ from oslo.config import cfg
29 28
 from muranoagent import version
30 29
 
31 30
 CONF = cfg.CONF
32
-CONF.register_cli_opt(cfg.StrOpt('storage',
33
-                                 default='/var/murano/plans',
34
-                                 help='Directory to store execution plans'))
31
+
32
+storage_opt = [
33
+    cfg.StrOpt('storage',
34
+               default='/var/murano/plans',
35
+               help='Directory to store execution plans')
36
+]
35 37
 
36 38
 rabbit_opts = [
37 39
     cfg.StrOpt('host',
@@ -66,13 +68,10 @@ rabbit_opts = [
66 68
 
67 69
 ]
68 70
 
71
+CONF.register_cli_opts(storage_opt)
69 72
 CONF.register_opts(rabbit_opts, group='rabbitmq')
70 73
 
71 74
 
72
-def list_opts():
73
-    return [('rabbitmq', copy.deepcopy(rabbit_opts))]
74
-
75
-
76 75
 def parse_args(args=None, usage=None, default_config_files=None):
77 76
     version_string = version.version_info.version_string()
78 77
     CONF(args=args,

+ 0
- 4
muranoagent/openstack/common/eventlet_backdoor.py View File

@@ -17,7 +17,6 @@
17 17
 from __future__ import print_function
18 18
 
19 19
 import errno
20
-import copy
21 20
 import gc
22 21
 import os
23 22
 import pprint
@@ -58,9 +57,6 @@ class EventletBackdoorConfigValueError(Exception):
58 57
         super(EventletBackdoorConfigValueError, self).__init__(msg)
59 58
         self.port_range = port_range
60 59
 
61
-def list_opts():
62
-    return [(None, copy.deepcopy(eventlet_backdoor_opts))]
63
-
64 60
 
65 61
 def _dont_use_this():
66 62
     print("Don't use this, just disconnect instead")

+ 0
- 9
muranoagent/openstack/common/log.py View File

@@ -27,7 +27,6 @@ It also allows setting of formatting information through conf.
27 27
 
28 28
 """
29 29
 
30
-import copy
31 30
 import inspect
32 31
 import itertools
33 32
 import logging
@@ -184,14 +183,6 @@ CONF.register_opts(log_opts)
184 183
 logging.AUDIT = logging.INFO + 1
185 184
 logging.addLevelName(logging.AUDIT, 'AUDIT')
186 185
 
187
-
188
-def list_opts():
189
-    yield None, copy.deepcopy(common_cli_opts)
190
-    yield None, copy.deepcopy(logging_cli_opts)
191
-    yield None, copy.deepcopy(generic_log_opts)
192
-    yield None, copy.deepcopy(log_opts)
193
-
194
-
195 186
 try:
196 187
     NullHandler = logging.NullHandler
197 188
 except AttributeError:  # NOTE(jkoelker) NullHandler added in Python 2.7

+ 59
- 0
muranoagent/opts.py View File

@@ -0,0 +1,59 @@
1
+#    Copyright (c) 2014 Mirantis, Inc.
2
+#
3
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+#    not use this file except in compliance with the License. You may obtain
5
+#    a copy of the License at
6
+#
7
+#         http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+#    Unless required by applicable law or agreed to in writing, software
10
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+#    License for the specific language governing permissions and limitations
13
+#    under the License.
14
+
15
+
16
+import copy
17
+import itertools
18
+
19
+import muranoagent.common.config
20
+import muranoagent.openstack.common.eventlet_backdoor
21
+import muranoagent.openstack.common.log
22
+
23
+
24
+def build_list(opt_list):
25
+    return list(itertools.chain(*opt_list))
26
+
27
+
28
+# List of *all* options in [DEFAULT] namespace of murano.
29
+# Any new option list or option needs to be registered here.
30
+_opt_lists = [
31
+    ('rabbitmq', muranoagent.common.config.rabbit_opts),
32
+    (None, build_list([
33
+        muranoagent.common.config.storage_opt,
34
+        muranoagent.openstack.common.eventlet_backdoor.eventlet_backdoor_opts,
35
+        muranoagent.openstack.common.log.common_cli_opts,
36
+        muranoagent.openstack.common.log.generic_log_opts,
37
+        muranoagent.openstack.common.log.log_opts,
38
+        muranoagent.openstack.common.log.logging_cli_opts
39
+    ]))
40
+]
41
+
42
+
43
+def list_opts():
44
+    """Return a list of oslo.config options available in Murano-Agent.
45
+
46
+    Each element of the list is a tuple. The first element is the name of the
47
+    group under which the list of elements in the second element will be
48
+    registered. A group name of None corresponds to the [DEFAULT] group in
49
+    config files.
50
+
51
+    This function is also discoverable via the 'muranoagent' entry point
52
+    under the 'oslo.config.opts' namespace.
53
+
54
+    The purpose of this is to allow tools like the Oslo sample config file
55
+    generator to discover the options exposed to users by Murano.
56
+
57
+    :returns: a list of (group_name, opts) tuples
58
+    """
59
+    return [(g, copy.deepcopy(o)) for g, o in _opt_lists]

+ 0
- 1
openstack-common.conf View File

@@ -7,7 +7,6 @@ module=importutils
7 7
 module=jsonutils
8 8
 module=log
9 9
 module=install_venv_common
10
-module=config
11 10
 module=service
12 11
 module=strutils
13 12
 

+ 1
- 3
setup.cfg View File

@@ -27,9 +27,7 @@ setup-hooks =
27 27
 
28 28
 [entry_points]
29 29
 oslo.config.opts =
30
-    muranoagent.common.config = muranoagent.common.config:list_opts
31
-    muranoagent.openstack.common.eventlet_backdoor = muranoagent.openstack.common.eventlet_backdoor:list_opts
32
-    muranoagent.openstack.common.log = muranoagent.openstack.common.log:list_opts
30
+    muranoagent = muranoagent.opts:list_opts
33 31
 
34 32
 console_scripts =
35 33
     muranoagent = muranoagent.cmd.run:main

+ 1
- 1
tox.ini View File

@@ -32,7 +32,7 @@ deps = flake8
32 32
 commands = flake8
33 33
 
34 34
 [testenv:genconfig]
35
-commands = oslo-config-generator --config-file config-generator.conf
35
+commands = oslo-config-generator --config-file etc/oslo-config-generator/muranoagent.conf
36 36
 
37 37
 [flake8]
38 38
 # H301 one import per line

Loading…
Cancel
Save