From 73c89c0407cec4735a2ffde43b64af2efa8cd0c1 Mon Sep 17 00:00:00 2001 From: Ramamani Yeleswarapu Date: Mon, 4 Apr 2016 16:01:45 -0700 Subject: [PATCH] Centralize config options - [cisco_ucs] Nova style refactor of config options in Ironic. Change-Id: I61e906e79a7c26b35e60a72ead9331b6b8f3ebe7 Partial-Bug: #1561100 --- ironic/conf/__init__.py | 2 ++ ironic/conf/cisco_ucs.py | 33 +++++++++++++++++++++++++++++ ironic/conf/opts.py | 3 +-- ironic/drivers/modules/ucs/power.py | 16 +------------- 4 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 ironic/conf/cisco_ucs.py diff --git a/ironic/conf/__init__.py b/ironic/conf/__init__.py index 7478c32ea9..069d3c1080 100644 --- a/ironic/conf/__init__.py +++ b/ironic/conf/__init__.py @@ -16,9 +16,11 @@ from oslo_config import cfg from ironic.conf import cimc +from ironic.conf import cisco_ucs from ironic.conf import console CONF = cfg.CONF cimc.register_opts(CONF) +cisco_ucs.register_opts(CONF) console.register_opts(CONF) diff --git a/ironic/conf/cisco_ucs.py b/ironic/conf/cisco_ucs.py new file mode 100644 index 0000000000..4705d4b0c7 --- /dev/null +++ b/ironic/conf/cisco_ucs.py @@ -0,0 +1,33 @@ +# 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 8fa22e0e6f..f405b49eeb 100644 --- a/ironic/conf/opts.py +++ b/ironic/conf/opts.py @@ -52,7 +52,6 @@ import ironic.drivers.modules.pxe import ironic.drivers.modules.seamicro import ironic.drivers.modules.snmp import ironic.drivers.modules.ssh -import ironic.drivers.modules.ucs.power import ironic.drivers.modules.virtualbox import ironic.netconf @@ -80,7 +79,7 @@ _opts = [ ironic.drivers.modules.amt.power.opts)), ('api', ironic.api.API_SERVICE_OPTS), ('cimc', ironic.conf.cimc.opts), - ('cisco_ucs', ironic.drivers.modules.ucs.power.opts), + ('cisco_ucs', ironic.conf.cisco_ucs.opts), ('conductor', itertools.chain( ironic.conductor.base_manager.conductor_opts, ironic.conductor.manager.conductor_opts)), diff --git a/ironic/drivers/modules/ucs/power.py b/ironic/drivers/modules/ucs/power.py index 8e1ffb310c..f819e8adae 100644 --- a/ironic/drivers/modules/ucs/power.py +++ b/ironic/drivers/modules/ucs/power.py @@ -17,7 +17,6 @@ Ironic Cisco UCSM interfaces. Provides basic power control of servers managed by Cisco UCSM using PyUcs Sdk. """ -from oslo_config import cfg from oslo_log import log as logging from oslo_service import loopingcall from oslo_utils import importutils @@ -27,26 +26,13 @@ from ironic.common.i18n import _ from ironic.common.i18n import _LE 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.ucs import helper as ucs_helper ucs_power = importutils.try_import('UcsSdk.utils.power') ucs_error = importutils.try_import('UcsSdk.utils.exception') -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')), -] - -CONF = cfg.CONF -CONF.register_opts(opts, group='cisco_ucs') - LOG = logging.getLogger(__name__) UCS_TO_IRONIC_POWER_STATE = {