Ensure Plugin config declarations are compatible with oslo-config's import_opt
method
Change-Id: I29bbffcff00576ddbef1ecd283a3fad65dd5fc84
This commit is contained in:
parent
f8df098d30
commit
e02a0df23a
@ -24,24 +24,24 @@ from moniker.context import MonikerContext
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
cfg.CONF.register_group(cfg.OptGroup(
|
||||
name='backend:bind9', title="Configuration for BIND9 Backend"
|
||||
))
|
||||
|
||||
cfg.CONF.register_opts([
|
||||
cfg.StrOpt('rndc-path', default='/usr/sbin/rndc',
|
||||
help='RNDC Path'),
|
||||
cfg.StrOpt('rndc-host', default='127.0.0.1', help='RNDC Host'),
|
||||
cfg.IntOpt('rndc-port', default=953, help='RNDC Port'),
|
||||
cfg.StrOpt('rndc-config-file', default=None,
|
||||
help='RNDC Config File'),
|
||||
cfg.StrOpt('rndc-key-file', default=None, help='RNDC Key File'),
|
||||
], group='backend:bind9')
|
||||
|
||||
|
||||
class Bind9Backend(base.Backend):
|
||||
__plugin_name__ = 'bind9'
|
||||
|
||||
@classmethod
|
||||
def get_opts(cls):
|
||||
opts = super(Bind9Backend, cls).get_opts()
|
||||
opts.extend([
|
||||
cfg.StrOpt('rndc-path', default='/usr/sbin/rndc',
|
||||
help='RNDC Path'),
|
||||
cfg.StrOpt('rndc-host', default='127.0.0.1', help='RNDC Host'),
|
||||
cfg.IntOpt('rndc-port', default=953, help='RNDC Port'),
|
||||
cfg.StrOpt('rndc-config-file', default=None,
|
||||
help='RNDC Config File'),
|
||||
cfg.StrOpt('rndc-key-file', default=None, help='RNDC Key File'),
|
||||
])
|
||||
return opts
|
||||
|
||||
def start(self):
|
||||
super(Bind9Backend, self).start()
|
||||
|
||||
|
@ -29,34 +29,34 @@ from moniker.sqlalchemy.session import get_engine
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
cfg.CONF.register_group(cfg.OptGroup(
|
||||
name='backend:mysqlbind9', title="Configuration for BIND9+MySQL Backend"
|
||||
))
|
||||
|
||||
cfg.CONF.register_opts([
|
||||
cfg.StrOpt('rndc-path',
|
||||
default='/usr/sbin/rndc', help='RNDC Path'),
|
||||
cfg.StrOpt('rndc-host', default='127.0.0.1', help='RNDC Host'),
|
||||
cfg.IntOpt('rndc-port', default=953, help='RNDC Port'),
|
||||
cfg.StrOpt('rndc-config-file',
|
||||
default=None, help='RNDC Config File'),
|
||||
cfg.StrOpt('rndc-key-file', default=None, help='RNDC Key File'),
|
||||
cfg.StrOpt('dns-server-type', default='master',
|
||||
help='slave or master DNS server?'),
|
||||
cfg.BoolOpt('write-database', default=True,
|
||||
help='Write to the DNS mysqlbind database?'),
|
||||
cfg.StrOpt('database-connection',
|
||||
default='mysql://dns:dns@localhost/dns',
|
||||
help='SQL Connection'),
|
||||
cfg.StrOpt('database-dns-table',
|
||||
default='dns_domains',
|
||||
help='DNS schema'),
|
||||
], group='backend:mysqlbind9')
|
||||
|
||||
|
||||
class MySQLBind9Backend(base.Backend):
|
||||
__plugin_name__ = 'mysqlbind9'
|
||||
|
||||
@classmethod
|
||||
def get_opts(cls):
|
||||
opts = super(MySQLBind9Backend, cls).get_opts()
|
||||
opts.extend([
|
||||
cfg.StrOpt('rndc-path',
|
||||
default='/usr/sbin/rndc', help='RNDC Path'),
|
||||
cfg.StrOpt('rndc-host', default='127.0.0.1', help='RNDC Host'),
|
||||
cfg.IntOpt('rndc-port', default=953, help='RNDC Port'),
|
||||
cfg.StrOpt('rndc-config-file',
|
||||
default=None, help='RNDC Config File'),
|
||||
cfg.StrOpt('rndc-key-file', default=None, help='RNDC Key File'),
|
||||
cfg.StrOpt('dns-server-type', default='master',
|
||||
help='slave or master DNS server?'),
|
||||
cfg.BoolOpt('write-database', default=True,
|
||||
help='Write to the DNS mysqlbind database?'),
|
||||
cfg.StrOpt('database-connection',
|
||||
default='mysql://dns:dns@localhost/dns',
|
||||
help='SQL Connection'),
|
||||
cfg.StrOpt('database-dns-table',
|
||||
default='dns_domains',
|
||||
help='DNS schema'),
|
||||
])
|
||||
return opts
|
||||
|
||||
def get_url_data(self):
|
||||
url = _parse_rfc1738_args(cfg.CONF[self.name].database_connection)
|
||||
return url.translate_connect_args()
|
||||
|
@ -25,7 +25,8 @@ LOG = logging.getLogger(__name__)
|
||||
REPOSITORY = os.path.abspath(os.path.join(os.path.dirname(__file__), '..',
|
||||
'storage', 'impl_sqlalchemy',
|
||||
'migrate_repo'))
|
||||
cfg.CONF.import_opt('database_connection', 'moniker.storage')
|
||||
cfg.CONF.import_opt('database_connection', 'moniker.storage.impl_sqlalchemy',
|
||||
group='storage:sqlalchemy')
|
||||
|
||||
|
||||
class InitCommand(Command):
|
||||
|
@ -68,10 +68,6 @@ class Handler(Plugin):
|
||||
def process_notification(self, event_type, payload):
|
||||
""" Processes a given notification """
|
||||
|
||||
@classmethod
|
||||
def get_opts(cls):
|
||||
return [cfg.StrOpt('domain_id', default=None)]
|
||||
|
||||
def get_domain(self, domain_id):
|
||||
"""
|
||||
Return the domain for this context
|
||||
|
@ -19,18 +19,21 @@ from moniker.notification_handler.base import BaseAddressHandler
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
cfg.CONF.register_group(cfg.OptGroup(
|
||||
name='handler:nova_fixed',
|
||||
title="Configuration for Nova Notification Handler"
|
||||
))
|
||||
|
||||
cfg.CONF.register_opts([
|
||||
cfg.ListOpt('notification-topics', default=['monitor']),
|
||||
cfg.StrOpt('control-exchange', default='nova'),
|
||||
cfg.StrOpt('domain_id', default=None),
|
||||
], group='handler:nova_fixed')
|
||||
|
||||
|
||||
class NovaFixedHandler(BaseAddressHandler):
|
||||
__plugin_name__ = 'nova_fixed'
|
||||
""" Handler for Nova's notifications """
|
||||
|
||||
@classmethod
|
||||
def get_opts(cls):
|
||||
opts = super(NovaFixedHandler, cls).get_opts()
|
||||
opts.extend([
|
||||
cfg.ListOpt('notification-topics', default=['monitor']),
|
||||
cfg.StrOpt('control-exchange', default='nova')])
|
||||
return opts
|
||||
__plugin_name__ = 'nova_fixed'
|
||||
|
||||
def get_exchange_topics(self):
|
||||
exchange = cfg.CONF[self.name].control_exchange
|
||||
|
@ -19,18 +19,21 @@ from moniker.notification_handler.base import BaseAddressHandler
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
cfg.CONF.register_group(cfg.OptGroup(
|
||||
name='handler:quantum_floatingip',
|
||||
title="Configuration for Quantum Notification Handler"
|
||||
))
|
||||
|
||||
cfg.CONF.register_opts([
|
||||
cfg.ListOpt('notification-topics', default=['monitor']),
|
||||
cfg.StrOpt('control-exchange', default='quantum'),
|
||||
cfg.StrOpt('domain_id', default=None),
|
||||
], group='handler:quantum_floatingip')
|
||||
|
||||
|
||||
class QuantumFloatingHandler(BaseAddressHandler):
|
||||
__plugin_name__ = 'quantum_floatingip'
|
||||
""" Handler for Quantum's notifications """
|
||||
|
||||
@classmethod
|
||||
def get_opts(cls):
|
||||
opts = super(QuantumFloatingHandler, cls).get_opts()
|
||||
opts.extend([
|
||||
cfg.ListOpt('notification-topics', default=['monitor']),
|
||||
cfg.StrOpt('control-exchange', default='quantum')])
|
||||
return opts
|
||||
__plugin_name__ = 'quantum_floatingip'
|
||||
|
||||
def get_exchange_topics(self):
|
||||
exchange = cfg.CONF[self.name].control_exchange
|
||||
|
@ -15,8 +15,6 @@
|
||||
# under the License.
|
||||
import abc
|
||||
from stevedore import driver
|
||||
|
||||
from moniker.openstack.common import cfg
|
||||
from moniker.openstack.common import log as logging
|
||||
|
||||
|
||||
@ -55,7 +53,6 @@ class Plugin(object):
|
||||
|
||||
LOG.debug('Looking for plugin %s in %s', name, ns)
|
||||
mgr = driver.DriverManager(ns, name)
|
||||
mgr.driver.register_opts()
|
||||
|
||||
return mgr.driver(*invoke_args, **invoke_kwds) if invoke_on_load \
|
||||
else mgr.driver
|
||||
@ -77,47 +74,6 @@ class Plugin(object):
|
||||
def get_plugin_type(cls):
|
||||
return cls.__plugin_type__
|
||||
|
||||
@classmethod
|
||||
def register_group_opts(cls, group_name=None, opts=None):
|
||||
"""
|
||||
Register a set of Options underneath a new Group or Section
|
||||
if you will.
|
||||
|
||||
:param group_name: Optional group name to register this under
|
||||
Default: ClassName to class_name
|
||||
:param opts: The options to register.
|
||||
"""
|
||||
group_name = group_name or cls.get_canonical_name()
|
||||
if not group_name:
|
||||
raise RuntimeError("Missing name")
|
||||
|
||||
# NOTE(zykes): Always register the group if not the init fails...
|
||||
group = cfg.OptGroup(
|
||||
name=group_name,
|
||||
title="Configuration for %s" % group_name)
|
||||
cfg.CONF.register_group(group)
|
||||
if opts:
|
||||
cfg.CONF.register_opts(opts, group=group)
|
||||
else:
|
||||
LOG.debug("No options for %s, skipping registration", group_name)
|
||||
|
||||
@classmethod
|
||||
def register_opts(cls):
|
||||
"""
|
||||
Register the options for this Plugin using the options from
|
||||
cls.get_opts() as a default
|
||||
"""
|
||||
opts = cls.get_opts()
|
||||
cls.register_group_opts(opts=opts)
|
||||
|
||||
@classmethod
|
||||
def get_opts(cls):
|
||||
"""
|
||||
Return a list of options for this plugin to be registered underneath
|
||||
it's section
|
||||
"""
|
||||
return []
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
Start this plugin
|
||||
|
@ -23,7 +23,11 @@ from moniker.sqlalchemy.session import get_session
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
SQL_OPTS = [
|
||||
cfg.CONF.register_group(cfg.OptGroup(
|
||||
name='storage:sqlalchemy', title="Configuration for SQLAlchemy Storage"
|
||||
))
|
||||
|
||||
cfg.CONF.register_opts([
|
||||
cfg.StrOpt('database_connection',
|
||||
default='sqlite:///$state_path/moniker.sqlite',
|
||||
help='The database driver to use'),
|
||||
@ -41,18 +45,12 @@ SQL_OPTS = [
|
||||
'(setting -1 implies an infinite retry count)'),
|
||||
cfg.IntOpt('retry_interval', default=10,
|
||||
help='interval between retries of opening a sql connection')
|
||||
]
|
||||
], group='storage:sqlalchemy')
|
||||
|
||||
|
||||
class SQLAlchemyStorage(base.StorageEngine):
|
||||
__plugin_name__ = 'sqlalchemy'
|
||||
|
||||
@classmethod
|
||||
def get_opts(cls):
|
||||
opts = super(SQLAlchemyStorage, cls).get_opts()
|
||||
opts.extend(SQL_OPTS)
|
||||
return opts
|
||||
|
||||
def get_connection(self):
|
||||
return Connection(self.name)
|
||||
|
||||
|
@ -25,9 +25,8 @@ from moniker.central import service as central_service
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
# NOTE(kiall): Awful kludge, to be removed in the next patchset
|
||||
from moniker.storage.impl_sqlalchemy import SQLAlchemyStorage
|
||||
SQLAlchemyStorage.register_opts()
|
||||
cfg.CONF.import_opt('database_connection', 'moniker.storage.impl_sqlalchemy',
|
||||
group='storage:sqlalchemy')
|
||||
|
||||
|
||||
class AssertMixin(object):
|
||||
|
Loading…
x
Reference in New Issue
Block a user