def test_register_opt_default(self): self.fconf.register_opt(cfg.StrOpt('foo', default='bar')) self.assertEqual(self.fconf.foo, 'bar') self.assertEqual(self.fconf['foo'], 'bar') self.assertTrue('foo' in self.fconf) self.assertEqual(list(self.fconf), ['foo']) self.assertEqual(len(self.fconf), 1)
def test_register_opt_none_default(self): self.fconf.register_opt(cfg.StrOpt('foo')) self.assertIsNone(self.fconf.foo) self.assertIsNone(self.fconf['foo']) self.assertTrue('foo' in self.fconf) self.assertEqual(list(self.fconf), ['foo']) self.assertEqual(len(self.fconf), 1)
def test_blocked_opt(self): self.conf.register_opt(cfg.StrOpt('foo')) self.assertTrue('foo' in self.conf) self.assertEqual(len(self.conf), 1) self.assertIsNone(self.conf.foo) self.assertFalse('foo' in self.fconf) self.assertEqual(len(self.fconf), 0) self.assertRaises(cfg.NoSuchOptError, getattr, self.fconf, 'foo')
def test_register_grouped_opt_none_default(self): self.fconf.register_opt(cfg.StrOpt('foo'), group='blaa') self.assertIsNone(self.fconf.blaa.foo) self.assertIsNone(self.fconf['blaa']['foo']) self.assertTrue('blaa' in self.fconf) self.assertTrue('foo' in self.fconf.blaa) self.assertEqual(list(self.fconf), ['blaa']) self.assertEqual(list(self.fconf.blaa), ['foo']) self.assertEqual(len(self.fconf), 1) self.assertEqual(len(self.fconf.blaa), 1)
def test_register_group(self): group = cfg.OptGroup('blaa') self.fconf.register_group(group) self.fconf.register_opt(cfg.StrOpt('foo'), group=group) self.assertIsNone(self.fconf.blaa.foo) self.assertIsNone(self.fconf['blaa']['foo']) self.assertTrue('blaa' in self.fconf) self.assertTrue('foo' in self.fconf.blaa) self.assertEqual(list(self.fconf), ['blaa']) self.assertEqual(list(self.fconf.blaa), ['foo']) self.assertEqual(len(self.fconf), 1) self.assertEqual(len(self.fconf.blaa), 1)
def _get_olso_configs(): """Returns the essential config options to register.""" # NOTE(flaper87): Essential config should be # optional. Instead of doing try / except # at the top of this file, lets import cfg # here and assume that the caller of this # function already took care of this dependency. from essential.config import cfg return [ cfg.StrOpt('cache_url', default='memory://', help='URL to connect to the cache back end.') ]
cfg.IntOpt('backlog', default=4096, help=_("Number of backlog requests to configure " "the socket with")), cfg.IntOpt('tcp_keepidle', default=600, help=_("Sets the value of TCP_KEEPIDLE in seconds for each " "server socket. Not supported on OS X.")), cfg.IntOpt('retry_until_window', default=30, help=_("Number of seconds to keep retrying to listen")), cfg.BoolOpt('use_ssl', default=False, help=_('Enable SSL on the API server')), cfg.StrOpt('ssl_ca_file', default=None, help=_("CA certificate file to use to verify " "connecting clients")), cfg.StrOpt('ssl_cert_file', default=None, help=_("Certificate file to use when starting " "the server securely")), cfg.StrOpt('ssl_key_file', default=None, help=_("Private key file to use when starting " "the server securely")), ] CONF = cfg.CONF CONF.register_opts(socket_opts) LOG = logging.getLogger(__name__)
# Copyright (c) 2013 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from essential.config import cfg CONF = cfg.CONF opt = cfg.StrOpt('baz') CONF.register_opt(opt, group='qux')
# Copyright 2012 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from essential.config import cfg CONF = cfg.CONF opt = cfg.StrOpt('baa') CONF.register_opt(opt, group='baar')
import weakref from essential.config import cfg from essential import fileutils from essential.gettextutils import _, _LE, _LI from essential import log as logging LOG = logging.getLogger(__name__) util_opts = [ cfg.BoolOpt('disable_process_locking', default=False, help='Whether to disable inter-process locks'), cfg.StrOpt('lock_path', default=os.environ.get("ESSENTIAL_LOCK_PATH"), help=('Directory to use for lock files.')) ] CONF = cfg.CONF CONF.register_opts(util_opts) def set_defaults(lock_path): cfg.set_defaults(util_opts, lock_path=lock_path) class _FileLock(object): """Lock implementation which allows multiple locks, working around issues like bugs.debian.org/cgi-bin/bugreport.cgi?bug=632857 and does not require any cleanup. Since the lock is always held on a file
# Copyright 2014 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from essential.config import cfg from essential import gettextutils CONF = cfg.CONF # Note that this is using the Message class directly instead of using # gettextutils.enable_lazy() because this isolates the use of # the Message class to this one instance instead of turning it on # for all subsequent tests opt = cfg.StrOpt('i18n', default="i18n", help=gettextutils.Message('helpful message')) CONF.register_opt(opt, group='i18n')
# Copyright 2013 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from essential.config import cfg CONF = cfg.CONF opts = [ cfg.StrOpt('fblaa', default="fblaa"), # duplicated option cfg.StrOpt('fblaa', default="fblaa"), ] CONF.register_opts(opts)
default=False, help='Print debugging output (set logging level to ' 'DEBUG instead of default WARNING level).'), cfg.BoolOpt('verbose', short='v', default=False, help='Print more verbose output (set logging level to ' 'INFO instead of default WARNING level).'), ] logging_cli_opts = [ cfg.StrOpt('log-config-append', metavar='PATH', deprecated_name='log-config', help='The name of logging configuration file. It does not ' 'disable existing loggers, but just appends specified ' 'logging configuration to any other existing logging ' 'options. Please see the Python logging module ' 'documentation for details on logging configuration ' 'files.'), cfg.StrOpt('log-format', default=None, metavar='FORMAT', help='DEPRECATED. ' 'A logging.Formatter log message format string which may ' 'use any of the available logging.LogRecord attributes. ' 'This option is deprecated. Please use ' 'logging_context_format_string and ' 'logging_default_format_string instead.'), cfg.StrOpt('log-date-format', default=_DEFAULT_LOG_DATE_FORMAT,
A remote procedure call (rpc) abstraction. For some wrappers that add message versioning to rpc, see: rpc.dispatcher rpc.proxy """ from essential.config import cfg from essential import importutils from essential import log as logging LOG = logging.getLogger(__name__) rpc_opts = [ cfg.StrOpt('rpc_backend', default='%s.impl_kombu' % __package__, help="The messaging module to use, defaults to kombu."), cfg.IntOpt('rpc_thread_pool_size', default=64, help='Size of RPC thread pool'), cfg.IntOpt('rpc_conn_pool_size', default=30, help='Size of RPC connection pool'), cfg.IntOpt('rpc_response_timeout', default=60, help='Seconds to wait for a response from call or multicall'), cfg.IntOpt('rpc_cast_timeout', default=30, help='Seconds to wait before a cast expires (TTL). ' 'Only supported by impl_zmq.'), cfg.ListOpt('allowed_rpc_exception_modules',
# Copyright 2013 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from essential.config import cfg CONF = cfg.CONF opt = cfg.StrOpt('foo') CONF.register_opt(opt, group='fbar')
from essential.gettextutils import _, _LE, _LI from essential import importutils from essential import jsonutils from essential import log as logging from essential.rpc import amqp as rpc_amqp from essential.rpc import common as rpc_common qpid_codec = importutils.try_import("qpid.codec010") qpid_messaging = importutils.try_import("qpid.messaging") qpid_exceptions = importutils.try_import("qpid.messaging.exceptions") LOG = logging.getLogger(__name__) qpid_opts = [ cfg.StrOpt('qpid_hostname', default='localhost', help='Qpid broker hostname'), cfg.IntOpt('qpid_port', default=5672, help='Qpid broker port'), cfg.ListOpt('qpid_hosts', default=['$qpid_hostname:$qpid_port'], help='Qpid HA cluster host:port pairs'), cfg.StrOpt('qpid_username', default='', help='Username for qpid connection'), cfg.StrOpt('qpid_password', default='', help='Password for qpid connection', secret=True), cfg.StrOpt('qpid_sasl_mechanisms',
from essential.config import cfg from essential import context from essential.gettextutils import _, _LE from essential import importutils from essential import jsonutils from essential import log as logging from essential import timeutils LOG = logging.getLogger(__name__) notifier_opts = [ cfg.MultiStrOpt('notification_driver', default=[], help='Driver or drivers to handle sending notifications'), cfg.StrOpt('default_notification_level', default='INFO', help='Default notification level for outgoing notifications'), cfg.StrOpt('default_publisher_id', default=None, help='Default publisher_id for outgoing notifications'), ] CONF = cfg.CONF CONF.register_opts(notifier_opts) WARN = 'WARN' INFO = 'INFO' ERROR = 'ERROR' CRITICAL = 'CRITICAL' DEBUG = 'DEBUG'
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import copy from essential.config import cfg database_opts = [ cfg.StrOpt('sqlite_db', deprecated_group='DEFAULT', default='essential.sqlite', help='The file name to use with SQLite'), cfg.BoolOpt('sqlite_synchronous', deprecated_group='DEFAULT', default=True, help='If True, SQLite uses synchronous mode'), cfg.StrOpt('backend', default='sqlalchemy', deprecated_name='db_backend', deprecated_group='DEFAULT', help='The backend to use for db'), cfg.StrOpt('connection', help='The SQLAlchemy connection string used to connect to the ' 'database', secret=True, deprecated_opts=[cfg.DeprecatedOpt('sql_connection',
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import os import ssl from essential.config import cfg from essential.gettextutils import _ ssl_opts = [ cfg.StrOpt('ca_file', default=None, help="CA certificate file to use to verify " "connecting clients."), cfg.StrOpt('cert_file', default=None, help="Certificate file to use when starting " "the server securely."), cfg.StrOpt('key_file', default=None, help="Private key file to use when starting " "the server securely."), ] CONF = cfg.CONF CONF.register_opts(ssl_opts, "ssl")
# License for the specific language governing permissions and limitations # under the License. """ The MatchMaker classes should accept a Topic or Fanout exchange key and return keys for direct exchanges, per (approximate) AMQP parlance. """ from essential.config import cfg from essential import importutils from essential import log as logging from essential.rpc import matchmaker as mm_common redis = importutils.try_import('redis') matchmaker_redis_opts = [ cfg.StrOpt('host', default='127.0.0.1', help='Host to locate redis'), cfg.IntOpt('port', default=6379, help='Use this port to connect to redis host.'), cfg.StrOpt('password', default=None, help='Password for Redis server. (optional)'), ] CONF = cfg.CONF opt_group = cfg.OptGroup(name='matchmaker_redis', title='Options for Redis-based MatchMaker') CONF.register_group(opt_group) CONF.register_opts(matchmaker_redis_opts, opt_group) LOG = logging.getLogger(__name__)
import greenlet from essential.config import cfg from essential.gettextutils import _LI from essential import log as logging help_for_backdoor_port = ( "Acceptable values are 0, <port>, and <start>:<end>, where 0 results " "in listening on a random tcp port number; <port> results in listening " "on the specified port number (and not enabling backdoor if that port " "is in use); and <start>:<end> results in listening on the smallest " "unused port number within the specified range of port numbers. The " "chosen port is displayed in the service's log file.") eventlet_backdoor_opts = [ cfg.StrOpt('backdoor_port', default=None, help="Enable eventlet backdoor. %s" % help_for_backdoor_port) ] CONF = cfg.CONF CONF.register_opts(eventlet_backdoor_opts) LOG = logging.getLogger(__name__) class EventletBackdoorConfigValueError(Exception): def __init__(self, port_range, help_msg, ex): msg = ('Invalid backdoor_port configuration %(range)s: %(ex)s. ' '%(help)s' % { 'range': port_range, 'ex': ex, 'help': help_msg
# Copyright 2014 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from essential.config import cfg CONF = cfg.CONF # Use a unicode value that causes an exception if str() is used opt = cfg.StrOpt('unicode_opt', default="unicode_default", help=u'helpful message with unicode char: \xE7\x94\xB5') CONF.register_opt(opt, group='unicode_group')
# Copyright 2012 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from essential.config import cfg CONF = cfg.CONF opt = cfg.StrOpt('blaa') CONF.register_opt(opt)
""" import itertools import json from essential.config import cfg from essential.gettextutils import _LW from essential import log as logging from essential.rpc import matchmaker as mm matchmaker_opts = [ # Matchmaker ring file cfg.StrOpt('ringfile', deprecated_name='matchmaker_ringfile', deprecated_group='DEFAULT', default='/etc/essential/matchmaker_ring.json', help='Matchmaker ring file (JSON)'), ] CONF = cfg.CONF CONF.register_opts(matchmaker_opts, 'matchmaker_ring') LOG = logging.getLogger(__name__) class RingExchange(mm.Exchange): """Match Maker where hosts are loaded from a static JSON formatted file. __init__ takes optional ring dictionary argument, otherwise loads the ringfile from CONF.mathcmaker_ringfile. """
import kombu.entity import kombu.messaging import six from essential.config import cfg from essential import excutils from essential.gettextutils import _, _LE, _LI from essential import network_utils from essential.rpc import amqp as rpc_amqp from essential.rpc import common as rpc_common from essential import sslutils kombu_opts = [ cfg.StrOpt('kombu_ssl_version', default='', help='If SSL is enabled, the SSL version to use. Valid ' 'values are TLSv1, SSLv23 and SSLv3. SSLv2 might ' 'be available on some distributions.'), cfg.StrOpt('kombu_ssl_keyfile', default='', help='SSL key file (valid only if SSL enabled)'), cfg.StrOpt('kombu_ssl_certfile', default='', help='SSL cert file (valid only if SSL enabled)'), cfg.StrOpt('kombu_ssl_ca_certs', default='', help=('SSL certification authority file ' '(valid only if SSL enabled)')), cfg.StrOpt('rabbit_host', default='localhost', help='The RabbitMQ broker address where a single node is used'),
from essential import jsonutils from essential.rpc import common as rpc_common zmq = importutils.try_import('eventlet.green.zmq') # for convenience, are not modified. pformat = pprint.pformat Timeout = eventlet.timeout.Timeout LOG = rpc_common.LOG RemoteError = rpc_common.RemoteError RPCException = rpc_common.RPCException zmq_opts = [ cfg.StrOpt('rpc_zmq_bind_address', default='*', help='ZeroMQ bind address. Should be a wildcard (*), ' 'an ethernet interface, or IP. ' 'The "host" option should point or resolve to this ' 'address.'), # The module.Class to use for matchmaking. cfg.StrOpt( 'rpc_zmq_matchmaker', default=('essential.rpc.' 'matchmaker.MatchMakerLocalhost'), help='MatchMaker driver', ), # The following port is unassigned by IANA as of 2012-05-21 cfg.IntOpt('rpc_zmq_port', default=9501, help='ZeroMQ receiver listening port'),