Centralize config option: urlfetch and periodic
Centralize config option of urlfetch and periodic section. Replace oslo_config cfg to magnum.conf. Clean up some oslo_config import_opt and use magnum.conf. Finish Implements: blueprint centralize-config-magnum Change-Id: I11fb85159b260865beae9686734ca102ebc3154b
This commit is contained in:
parent
08a48895c4
commit
3a6a7cd8d5
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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',
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user