Centralize config options - [snmp]

Nova style refactor of config options in Ironic.

Change-Id: I2a803ced4080c5f3358b9ac939d4864151cca5b6
Partial-Bug: #1561100
This commit is contained in:
Ramamani Yeleswarapu 2016-04-08 15:27:59 -07:00
parent c6cb23655b
commit c3d8918f97
4 changed files with 45 additions and 19 deletions

View File

@ -29,6 +29,7 @@ from ironic.conf import irmc
from ironic.conf import keystone from ironic.conf import keystone
from ironic.conf import oneview from ironic.conf import oneview
from ironic.conf import seamicro from ironic.conf import seamicro
from ironic.conf import snmp
CONF = cfg.CONF CONF = cfg.CONF
@ -46,3 +47,4 @@ irmc.register_opts(CONF)
keystone.register_opts(CONF) keystone.register_opts(CONF)
oneview.register_opts(CONF) oneview.register_opts(CONF)
seamicro.register_opts(CONF) seamicro.register_opts(CONF)
snmp.register_opts(CONF)

View File

@ -34,7 +34,6 @@ import ironic.drivers.modules.deploy_utils
import ironic.drivers.modules.image_cache import ironic.drivers.modules.image_cache
import ironic.drivers.modules.iscsi_deploy import ironic.drivers.modules.iscsi_deploy
import ironic.drivers.modules.pxe import ironic.drivers.modules.pxe
import ironic.drivers.modules.snmp
import ironic.drivers.modules.ssh import ironic.drivers.modules.ssh
import ironic.drivers.modules.virtualbox import ironic.drivers.modules.virtualbox
import ironic.netconf import ironic.netconf
@ -85,7 +84,7 @@ _opts = [
ironic.drivers.modules.iscsi_deploy.pxe_opts, ironic.drivers.modules.iscsi_deploy.pxe_opts,
ironic.drivers.modules.pxe.pxe_opts)), ironic.drivers.modules.pxe.pxe_opts)),
('seamicro', ironic.conf.seamicro.opts), ('seamicro', ironic.conf.seamicro.opts),
('snmp', ironic.drivers.modules.snmp.opts), ('snmp', ironic.conf.snmp.opts),
('ssh', ironic.drivers.modules.ssh.libvirt_opts), ('ssh', ironic.drivers.modules.ssh.libvirt_opts),
('swift', ironic.common.swift.swift_opts), ('swift', ironic.common.swift.swift_opts),
('virtualbox', ironic.drivers.modules.virtualbox.opts), ('virtualbox', ironic.drivers.modules.virtualbox.opts),

41
ironic/conf/snmp.py Normal file
View File

@ -0,0 +1,41 @@
# Copyright 2016 Intel Corporation
# Copyright 2013,2014 Cray Inc
#
# Authors: David Hewson <dhewson@cray.com>
# Stig Telfer <stelfer@cray.com>
# Mark Goddard <mgoddard@cray.com>
#
# 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.IntOpt('power_timeout',
default=10,
help=_('Seconds to wait for power action to be completed')),
# NOTE(yuriyz): some of SNMP-enabled hardware have own options for pause
# between off and on. This option guarantees minimal value.
cfg.IntOpt('reboot_delay',
default=0,
min=0,
help=_('Time (in seconds) to sleep between when rebooting '
'(powering off and on again)'))
]
def register_opts(conf):
conf.register_opts(opts, group='snmp')

View File

@ -30,7 +30,6 @@ models.
import abc import abc
import time import time
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
@ -42,6 +41,7 @@ from ironic.common.i18n import _LW
from ironic.common import states from ironic.common import states
from ironic.common import utils from ironic.common import utils
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
pysnmp = importutils.try_import('pysnmp') pysnmp = importutils.try_import('pysnmp')
@ -54,24 +54,8 @@ else:
snmp_error = None snmp_error = None
rfc1902 = None rfc1902 = None
opts = [
cfg.IntOpt('power_timeout',
default=10,
help=_('Seconds to wait for power action to be completed')),
# NOTE(yuriyz): some of SNMP-enabled hardware have own options for pause
# between off and on. This option guarantees minimal value.
cfg.IntOpt('reboot_delay',
default=0,
min=0,
help=_('Time (in seconds) to sleep between when rebooting '
'(powering off and on again)'))
]
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
CONF = cfg.CONF
CONF.register_opts(opts, group='snmp')
SNMP_V1 = '1' SNMP_V1 = '1'
SNMP_V2C = '2c' SNMP_V2C = '2c'