From 0791fa7c96b7ae6e568fa9fd3386c8975a55a9b3 Mon Sep 17 00:00:00 2001 From: Ramamani Yeleswarapu Date: Wed, 15 Jun 2016 11:51:28 -0700 Subject: [PATCH] Centralize Config Options - patch merge, cleanup Nova style refactor of config options in Ironic. - Merge cimc, cisco_ucs options into one file: conf/cisco_ucs.py - Remove unnecessary import_opts - Move [amt] group options to conf/amt.py - Renamed conf/cisco_ucs.py as conf/cisco.py - Removed netconf.py. Change-Id: I3c3f5d21de26a9d23ce766c24674f09999f610f5 Closes-Bug: #1561100 --- ironic/conf/__init__.py | 8 ++--- ironic/conf/amt.py | 48 ++++++++++++++++++++++++++++ ironic/conf/{cimc.py => cisco.py} | 20 ++++++++++-- ironic/conf/cisco_ucs.py | 33 ------------------- ironic/conf/opts.py | 11 +++---- ironic/db/sqlalchemy/api.py | 6 +--- ironic/drivers/modules/amt/common.py | 24 +------------- ironic/drivers/modules/amt/power.py | 16 +--------- ironic/drivers/modules/ilo/deploy.py | 3 -- ironic/drivers/modules/inspector.py | 2 -- ironic/drivers/modules/ipmitool.py | 10 +----- ironic/netconf.py | 0 12 files changed, 78 insertions(+), 103 deletions(-) create mode 100644 ironic/conf/amt.py rename ironic/conf/{cimc.py => cisco.py} (60%) delete mode 100644 ironic/conf/cisco_ucs.py delete mode 100644 ironic/netconf.py diff --git a/ironic/conf/__init__.py b/ironic/conf/__init__.py index 7164395fa0..546cc52531 100644 --- a/ironic/conf/__init__.py +++ b/ironic/conf/__init__.py @@ -16,10 +16,10 @@ from oslo_config import cfg from ironic.conf import agent +from ironic.conf import amt from ironic.conf import api from ironic.conf import audit -from ironic.conf import cimc -from ironic.conf import cisco_ucs +from ironic.conf import cisco from ironic.conf import conductor from ironic.conf import console from ironic.conf import database @@ -49,10 +49,10 @@ from ironic.conf import virtualbox CONF = cfg.CONF agent.register_opts(CONF) +amt.register_opts(CONF) api.register_opts(CONF) audit.register_opts(CONF) -cimc.register_opts(CONF) -cisco_ucs.register_opts(CONF) +cisco.register_opts(CONF) conductor.register_opts(CONF) console.register_opts(CONF) database.register_opts(CONF) diff --git a/ironic/conf/amt.py b/ironic/conf/amt.py new file mode 100644 index 0000000000..152727d531 --- /dev/null +++ b/ironic/conf/amt.py @@ -0,0 +1,48 @@ +# Copyright 2016 Intel Corporation +# Copyright (c) 2012 NTT DOCOMO, INC. +# All Rights Reserved. +# +# 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('protocol', + default='http', + choices=['http', 'https'], + help=_('Protocol used for AMT endpoint')), + cfg.IntOpt('awake_interval', + default=60, + min=0, + help=_('Time interval (in seconds) for successive awake call ' + 'to AMT interface, this depends on the IdleTimeout ' + 'setting on AMT interface. AMT Interface will go to ' + 'sleep after 60 seconds of inactivity by default. ' + 'IdleTimeout=0 means AMT will not go to sleep at all. ' + 'Setting awake_interval=0 will disable awake call.')), + cfg.IntOpt('max_attempts', + default=3, + help=_('Maximum number of times to attempt an AMT operation, ' + 'before failing')), + cfg.IntOpt('action_wait', + default=10, + help=_('Amount of time (in seconds) to wait, before retrying ' + 'an AMT operation')) +] + + +def register_opts(conf): + conf.register_opts(opts, group='amt') diff --git a/ironic/conf/cimc.py b/ironic/conf/cisco.py similarity index 60% rename from ironic/conf/cimc.py rename to ironic/conf/cisco.py index ba4c2547ab..f9cf5e58cb 100644 --- a/ironic/conf/cimc.py +++ b/ironic/conf/cisco.py @@ -17,7 +17,9 @@ from oslo_config import cfg from ironic.common.i18n import _ -opts = [ +# NOTE: options for CIMC (Cisco Integrated Management Controller), which talks +# to UCS (Unified Computing System) in standalone mode +cimc_opts = [ cfg.IntOpt('max_retry', default=6, help=_('Number of times a power operation needs to be ' @@ -28,6 +30,20 @@ opts = [ 'operations')), ] +# NOTE: options for UCSM (UCS Manager), which talks to UCS via a centralized +# management controller +ucsm_opts = [ + cfg.IntOpt('max_retry', + default=6, + help=_('Number of times a power operation needs to be ' + 'retried')), + cfg.IntOpt('action_interval', + default=5, + help=_('Amount of time in seconds to wait in between power ' + 'operations')), +] + def register_opts(conf): - conf.register_opts(opts, group='cimc') + conf.register_opts(cimc_opts, group='cimc') + conf.register_opts(ucsm_opts, group='cisco_ucs') diff --git a/ironic/conf/cisco_ucs.py b/ironic/conf/cisco_ucs.py deleted file mode 100644 index 4705d4b0c7..0000000000 --- a/ironic/conf/cisco_ucs.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2016 Intel Corporation -# Copyright 2015, Cisco Systems. -# -# 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.IntOpt('max_retry', - default=6, - help=_('Number of times a power operation needs to be ' - 'retried')), - cfg.IntOpt('action_interval', - default=5, - help=_('Amount of time in seconds to wait in between power ' - 'operations')), -] - - -def register_opts(conf): - conf.register_opts(opts, group='cisco_ucs') diff --git a/ironic/conf/opts.py b/ironic/conf/opts.py index c8df8bf0ce..ec998c4d9e 100644 --- a/ironic/conf/opts.py +++ b/ironic/conf/opts.py @@ -12,8 +12,7 @@ import itertools -import ironic.drivers.modules.amt.common -import ironic.drivers.modules.amt.power +import ironic.conf _default_opt_lists = [ ironic.conf.default.api_opts, @@ -32,13 +31,11 @@ _default_opt_lists = [ _opts = [ ('DEFAULT', itertools.chain(*_default_opt_lists)), ('agent', ironic.conf.agent.opts), - ('amt', itertools.chain( - ironic.drivers.modules.amt.common.opts, - ironic.drivers.modules.amt.power.opts)), + ('amt', ironic.conf.amt.opts), ('api', ironic.conf.api.opts), ('audit', ironic.conf.audit.opts), - ('cimc', ironic.conf.cimc.opts), - ('cisco_ucs', ironic.conf.cisco_ucs.opts), + ('cimc', ironic.conf.cisco.cimc_opts), + ('cisco_ucs', ironic.conf.cisco.ucsm_opts), ('conductor', ironic.conf.conductor.opts), ('console', ironic.conf.console.opts), ('database', ironic.conf.database.opts), diff --git a/ironic/db/sqlalchemy/api.py b/ironic/db/sqlalchemy/api.py index a8030dd87b..70105aee83 100644 --- a/ironic/db/sqlalchemy/api.py +++ b/ironic/db/sqlalchemy/api.py @@ -20,7 +20,6 @@ import collections import datetime import threading -from oslo_config import cfg from oslo_db import exception as db_exc from oslo_db.sqlalchemy import enginefacade from oslo_db.sqlalchemy import utils as db_utils @@ -37,13 +36,10 @@ from ironic.common.i18n import _ from ironic.common.i18n import _LW from ironic.common import states from ironic.common import utils +from ironic.conf import CONF from ironic.db import api from ironic.db.sqlalchemy import models -CONF = cfg.CONF -CONF.import_opt('heartbeat_timeout', - 'ironic.conductor.manager', - group='conductor') LOG = log.getLogger(__name__) diff --git a/ironic/drivers/modules/amt/common.py b/ironic/drivers/modules/amt/common.py index 831c1b0b3d..a5274c36a3 100644 --- a/ironic/drivers/modules/amt/common.py +++ b/ironic/drivers/modules/amt/common.py @@ -17,7 +17,6 @@ import time from xml import etree from oslo_concurrency import processutils -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import importutils import six @@ -27,6 +26,7 @@ from ironic.common import exception from ironic.common.i18n import _ from ironic.common.i18n import _LE from ironic.common import utils +from ironic.conf import CONF pywsman = importutils.try_import('pywsman') @@ -47,28 +47,6 @@ OPTIONAL_PROPERTIES = { COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy() COMMON_PROPERTIES.update(OPTIONAL_PROPERTIES) -opts = [ - cfg.StrOpt('protocol', - default='http', - choices=['http', 'https'], - help=_('Protocol used for AMT endpoint')), - cfg.IntOpt('awake_interval', - default=60, - min=0, - help=_('Time interval (in seconds) for successive awake call ' - 'to AMT interface, this depends on the IdleTimeout ' - 'setting on AMT interface. AMT Interface will go to ' - 'sleep after 60 seconds of inactivity by default. ' - 'IdleTimeout=0 means AMT will not go to sleep at all. ' - 'Setting awake_interval=0 will disable awake call.')), -] - -CONF = cfg.CONF -opt_group = cfg.OptGroup(name='amt', - title='Options for the AMT power driver') -CONF.register_group(opt_group) -CONF.register_opts(opts, opt_group) - # TODO(lintan): More boot devices are supported by AMT, but not useful # currently. Add them in the future. BOOT_DEVICES_MAPPING = { diff --git a/ironic/drivers/modules/amt/power.py b/ironic/drivers/modules/amt/power.py index d74a95671e..e5ae847002 100644 --- a/ironic/drivers/modules/amt/power.py +++ b/ironic/drivers/modules/amt/power.py @@ -16,7 +16,6 @@ AMT Power Driver """ import copy -from oslo_config import cfg from oslo_log import log as logging from oslo_service import loopingcall from oslo_utils import excutils @@ -29,26 +28,13 @@ from ironic.common.i18n import _LI from ironic.common.i18n import _LW from ironic.common import states from ironic.conductor import task_manager +from ironic.conf import CONF from ironic.drivers import base from ironic.drivers.modules.amt import common as amt_common from ironic.drivers.modules.amt import resource_uris pywsman = importutils.try_import('pywsman') -opts = [ - cfg.IntOpt('max_attempts', - default=3, - help=_('Maximum number of times to attempt an AMT operation, ' - 'before failing')), - cfg.IntOpt('action_wait', - default=10, - help=_('Amount of time (in seconds) to wait, before retrying ' - 'an AMT operation')) -] - -CONF = cfg.CONF -CONF.register_opts(opts, group='amt') - LOG = logging.getLogger(__name__) AMT_POWER_MAP = { diff --git a/ironic/drivers/modules/ilo/deploy.py b/ironic/drivers/modules/ilo/deploy.py index 3e6213abd2..7fd2f9dcf4 100644 --- a/ironic/drivers/modules/ilo/deploy.py +++ b/ironic/drivers/modules/ilo/deploy.py @@ -36,9 +36,6 @@ from ironic.drivers.modules import pxe LOG = logging.getLogger(__name__) -CONF.import_opt('pxe_append_params', 'ironic.drivers.modules.iscsi_deploy', - group='pxe') - def _prepare_agent_vmedia_boot(task): """Ejects virtual media devices and prepares for vmedia boot.""" diff --git a/ironic/drivers/modules/inspector.py b/ironic/drivers/modules/inspector.py index 59c5a31575..65c0b9aa7d 100644 --- a/ironic/drivers/modules/inspector.py +++ b/ironic/drivers/modules/inspector.py @@ -33,8 +33,6 @@ from ironic.drivers import base LOG = logging.getLogger(__name__) -CONF.import_opt('auth_strategy', 'ironic.api.app') - client = importutils.try_import('ironic_inspector_client') diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py index 950cd06bed..aaa3d8997b 100644 --- a/ironic/drivers/modules/ipmitool.py +++ b/ironic/drivers/modules/ipmitool.py @@ -39,7 +39,6 @@ import time from ironic_lib import metrics_utils from ironic_lib import utils as ironic_utils from oslo_concurrency import processutils -from oslo_config import cfg from oslo_log import log as logging from oslo_service import loopingcall from oslo_utils import excutils @@ -55,20 +54,13 @@ from ironic.common.i18n import _LW from ironic.common import states from ironic.common import utils from ironic.conductor import task_manager +from ironic.conf import CONF from ironic.drivers import base from ironic.drivers.modules import console_utils from ironic.drivers.modules import deploy_utils from ironic.drivers import utils as driver_utils -CONF = cfg.CONF -CONF.import_opt('retry_timeout', - 'ironic.drivers.modules.ipminative', - group='ipmi') -CONF.import_opt('min_command_interval', - 'ironic.drivers.modules.ipminative', - group='ipmi') - LOG = logging.getLogger(__name__) METRICS = metrics_utils.get_metrics_logger(__name__) diff --git a/ironic/netconf.py b/ironic/netconf.py deleted file mode 100644 index e69de29bb2..0000000000