Centralize config options - [cisco_ucs]

Nova style refactor of config options in Ironic.

Change-Id: I61e906e79a7c26b35e60a72ead9331b6b8f3ebe7
Partial-Bug: #1561100
This commit is contained in:
Ramamani Yeleswarapu 2016-04-04 16:01:45 -07:00
parent 921bca203f
commit 73c89c0407
4 changed files with 37 additions and 17 deletions

View File

@ -16,9 +16,11 @@
from oslo_config import cfg from oslo_config import cfg
from ironic.conf import cimc from ironic.conf import cimc
from ironic.conf import cisco_ucs
from ironic.conf import console from ironic.conf import console
CONF = cfg.CONF CONF = cfg.CONF
cimc.register_opts(CONF) cimc.register_opts(CONF)
cisco_ucs.register_opts(CONF)
console.register_opts(CONF) console.register_opts(CONF)

33
ironic/conf/cisco_ucs.py Normal file
View File

@ -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')

View File

@ -52,7 +52,6 @@ import ironic.drivers.modules.pxe
import ironic.drivers.modules.seamicro import ironic.drivers.modules.seamicro
import ironic.drivers.modules.snmp import ironic.drivers.modules.snmp
import ironic.drivers.modules.ssh import ironic.drivers.modules.ssh
import ironic.drivers.modules.ucs.power
import ironic.drivers.modules.virtualbox import ironic.drivers.modules.virtualbox
import ironic.netconf import ironic.netconf
@ -80,7 +79,7 @@ _opts = [
ironic.drivers.modules.amt.power.opts)), ironic.drivers.modules.amt.power.opts)),
('api', ironic.api.API_SERVICE_OPTS), ('api', ironic.api.API_SERVICE_OPTS),
('cimc', ironic.conf.cimc.opts), ('cimc', ironic.conf.cimc.opts),
('cisco_ucs', ironic.drivers.modules.ucs.power.opts), ('cisco_ucs', ironic.conf.cisco_ucs.opts),
('conductor', itertools.chain( ('conductor', itertools.chain(
ironic.conductor.base_manager.conductor_opts, ironic.conductor.base_manager.conductor_opts,
ironic.conductor.manager.conductor_opts)), ironic.conductor.manager.conductor_opts)),

View File

@ -17,7 +17,6 @@ Ironic Cisco UCSM interfaces.
Provides basic power control of servers managed by Cisco UCSM using PyUcs Sdk. 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_log import log as logging
from oslo_service import loopingcall from oslo_service import loopingcall
from oslo_utils import importutils from oslo_utils import importutils
@ -27,26 +26,13 @@ from ironic.common.i18n import _
from ironic.common.i18n import _LE from ironic.common.i18n import _LE
from ironic.common import states from ironic.common import states
from ironic.conductor import task_manager from ironic.conductor import task_manager
from ironic.conf import CONF
from ironic.drivers import base from ironic.drivers import base
from ironic.drivers.modules.ucs import helper as ucs_helper from ironic.drivers.modules.ucs import helper as ucs_helper
ucs_power = importutils.try_import('UcsSdk.utils.power') ucs_power = importutils.try_import('UcsSdk.utils.power')
ucs_error = importutils.try_import('UcsSdk.utils.exception') 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__) LOG = logging.getLogger(__name__)
UCS_TO_IRONIC_POWER_STATE = { UCS_TO_IRONIC_POWER_STATE = {