diff --git a/magnum/api/servicegroup.py b/magnum/api/servicegroup.py index c6014d720c..1077689eb6 100644 --- a/magnum/api/servicegroup.py +++ b/magnum/api/servicegroup.py @@ -11,20 +11,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from oslo_config import cfg from oslo_utils import timeutils +import magnum.conf from magnum.objects import magnum_service -periodic_opts = [ - cfg.IntOpt('service_down_time', - default=180, - help='Max interval size between periodic tasks execution in ' - 'seconds.'), -] - -CONF = cfg.CONF -CONF.register_opts(periodic_opts) +CONF = magnum.conf.CONF class ServiceGroup(object): diff --git a/magnum/common/context.py b/magnum/common/context.py index 5a53250781..fc943ce3b7 100644 --- a/magnum/common/context.py +++ b/magnum/common/context.py @@ -11,10 +11,11 @@ # under the License. from eventlet.green import threading -from oslo_config import cfg from oslo_context import context -CONF = cfg.CONF +import magnum.conf + +CONF = magnum.conf.CONF class RequestContext(context.RequestContext): diff --git a/magnum/common/exception.py b/magnum/common/exception.py index 5177d7b079..db6e94f2da 100644 --- a/magnum/common/exception.py +++ b/magnum/common/exception.py @@ -27,13 +27,14 @@ from oslo_config import cfg from oslo_log import log as logging import six +import magnum.conf from magnum.i18n import _ from magnum.i18n import _LE LOG = logging.getLogger(__name__) -CONF = cfg.CONF +CONF = magnum.conf.CONF try: CONF.import_opt('fatal_exception_format_errors', diff --git a/magnum/common/urlfetch.py b/magnum/common/urlfetch.py index 83b0bf20df..f19fad0794 100644 --- a/magnum/common/urlfetch.py +++ b/magnum/common/urlfetch.py @@ -13,25 +13,18 @@ """Utility for fetching a resource (e.g. a manifest) from a URL.""" -from oslo_config import cfg from oslo_log import log as logging import requests from requests import exceptions from six.moves import urllib from magnum.common import exception +import magnum.conf from magnum.i18n import _ from magnum.i18n import _LE from magnum.i18n import _LI -URLFETCH_OPTS = [ - cfg.IntOpt('max_manifest_size', - default=524288, - help=_('Maximum raw byte size of any manifest.')) -] - -cfg.CONF.register_opts(URLFETCH_OPTS) - +CONF = magnum.conf.CONF LOG = logging.getLogger(__name__) @@ -76,10 +69,10 @@ def get(url, allowed_schemes=('http', 'https')): result = "" for chunk in reader: result += chunk - if len(result) > cfg.CONF.max_manifest_size: + if len(result) > CONF.max_manifest_size: raise URLFetchError(_LE("Manifest exceeds maximum allowed" "size (%s bytes)") % - cfg.CONF.max_manifest_size) + CONF.max_manifest_size) return result except exceptions.RequestException as ex: diff --git a/magnum/conf/utils.py b/magnum/conf/utils.py index d7acb35b7e..2165f5a438 100644 --- a/magnum/conf/utils.py +++ b/magnum/conf/utils.py @@ -10,8 +10,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import itertools + from oslo_config import cfg +from magnum.i18n import _ # Default symbols to use for passwords. Avoids visually confusing characters. # ~6 bits per symbol @@ -31,12 +34,31 @@ utils_opts = [ help='Symbols to use for passwords') ] +periodic_opts = [ + cfg.IntOpt('service_down_time', + default=180, + help='Max interval size between periodic tasks execution in ' + 'seconds.'), +] + +urlfetch_opts = [ + cfg.IntOpt('max_manifest_size', + default=524288, + help=_('Maximum raw byte size of any manifest.')) +] + +ALL_OPTS = list(itertools.chain( + utils_opts, + periodic_opts, + urlfetch_opts +)) + def register_opts(conf): - conf.register_opts(utils_opts) + conf.register_opts(ALL_OPTS) def list_opts(): return { - "DEFAULT": utils_opts + "DEFAULT": ALL_OPTS }