Centralize config options - [database]

Nova style refactor of config options in Ironic.

Change-Id: Ic5e2148565edf926c4279b44e9f262a46847b4d0
Partial-Bug: #1561100
This commit is contained in:
Ramamani Yeleswarapu 2016-04-05 09:35:56 -07:00
parent c0743e42b7
commit f38565e751
4 changed files with 35 additions and 15 deletions

View File

@ -19,6 +19,7 @@ from ironic.conf import cimc
from ironic.conf import cisco_ucs
from ironic.conf import conductor
from ironic.conf import console
from ironic.conf import database
CONF = cfg.CONF
@ -26,3 +27,4 @@ cimc.register_opts(CONF)
cisco_ucs.register_opts(CONF)
conductor.register_opts(CONF)
console.register_opts(CONF)
database.register_opts(CONF)

28
ironic/conf/database.py Normal file
View File

@ -0,0 +1,28 @@
# Copyright 2016 Intel Corporation
# Copyright 2013 Hewlett-Packard Development Company, L.P.
#
# 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 oslo_config import cfg
from ironic.common.i18n import _
opts = [
cfg.StrOpt('mysql_engine',
default='InnoDB',
help=_('MySQL engine to use.'))
]
def register_opts(conf):
conf.register_opts(opts, group='database')

View File

@ -26,7 +26,6 @@ import ironic.common.paths
import ironic.common.service
import ironic.common.swift
import ironic.common.utils
import ironic.db.sqlalchemy.models
import ironic.dhcp.neutron
import ironic.drivers.modules.agent
import ironic.drivers.modules.agent_base_vendor
@ -80,7 +79,7 @@ _opts = [
('cisco_ucs', ironic.conf.cisco_ucs.opts),
('conductor', ironic.conf.conductor.opts),
('console', ironic.conf.console.opts),
('database', ironic.db.sqlalchemy.models.sql_opts),
('database', ironic.conf.database.opts),
('deploy', ironic.drivers.modules.deploy_utils.deploy_opts),
('dhcp', ironic.common.dhcp_factory.dhcp_provider_opts),
('glance', itertools.chain(

View File

@ -18,7 +18,6 @@
SQLAlchemy models for baremetal data.
"""
from oslo_config import cfg
from oslo_db import options as db_options
from oslo_db.sqlalchemy import models
from oslo_db.sqlalchemy import types as db_types
@ -29,27 +28,19 @@ from sqlalchemy import schema, String, Text
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import orm
from ironic.common.i18n import _
from ironic.common import paths
sql_opts = [
cfg.StrOpt('mysql_engine',
default='InnoDB',
help=_('MySQL engine to use.'))
]
from ironic.conf import CONF
_DEFAULT_SQL_CONNECTION = 'sqlite:///' + paths.state_path_def('ironic.sqlite')
cfg.CONF.register_opts(sql_opts, 'database')
db_options.set_defaults(cfg.CONF, _DEFAULT_SQL_CONNECTION, 'ironic.sqlite')
db_options.set_defaults(CONF, _DEFAULT_SQL_CONNECTION, 'ironic.sqlite')
def table_args():
engine_name = urlparse.urlparse(cfg.CONF.database.connection).scheme
engine_name = urlparse.urlparse(CONF.database.connection).scheme
if engine_name == 'mysql':
return {'mysql_engine': cfg.CONF.database.mysql_engine,
return {'mysql_engine': CONF.database.mysql_engine,
'mysql_charset': "utf8"}
return None