From 28f74a8c9c0f954851ce71bcde9605850c17dbba Mon Sep 17 00:00:00 2001 From: Ramamani Yeleswarapu Date: Fri, 8 Apr 2016 16:05:09 -0700 Subject: [PATCH] Centralize config options - [virtualbox] Nova style refactor of config options in Ironic. Change-Id: I9c7b1ea0c4c35eaacc4655d605993297242f0c0a Partial-Bug: #1561100 --- ironic/conf/__init__.py | 2 ++ ironic/conf/opts.py | 3 +-- ironic/conf/virtualbox.py | 27 +++++++++++++++++++++++++++ ironic/drivers/modules/virtualbox.py | 10 +--------- 4 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 ironic/conf/virtualbox.py diff --git a/ironic/conf/__init__.py b/ironic/conf/__init__.py index c2192ecfd9..a8a57d11e8 100644 --- a/ironic/conf/__init__.py +++ b/ironic/conf/__init__.py @@ -32,6 +32,7 @@ from ironic.conf import seamicro from ironic.conf import snmp from ironic.conf import ssh from ironic.conf import swift +from ironic.conf import virtualbox CONF = cfg.CONF @@ -52,3 +53,4 @@ seamicro.register_opts(CONF) snmp.register_opts(CONF) ssh.register_opts(CONF) swift.register_opts(CONF) +virtualbox.register_opts(CONF) diff --git a/ironic/conf/opts.py b/ironic/conf/opts.py index 23c7156918..10755b30ac 100644 --- a/ironic/conf/opts.py +++ b/ironic/conf/opts.py @@ -33,7 +33,6 @@ import ironic.drivers.modules.deploy_utils import ironic.drivers.modules.image_cache import ironic.drivers.modules.iscsi_deploy import ironic.drivers.modules.pxe -import ironic.drivers.modules.virtualbox import ironic.netconf _default_opt_lists = [ @@ -85,7 +84,7 @@ _opts = [ ('snmp', ironic.conf.snmp.opts), ('ssh', ironic.conf.ssh.opts), ('swift', ironic.conf.swift.opts), - ('virtualbox', ironic.drivers.modules.virtualbox.opts), + ('virtualbox', ironic.conf.virtualbox.opts), ] diff --git a/ironic/conf/virtualbox.py b/ironic/conf/virtualbox.py new file mode 100644 index 0000000000..24a6193381 --- /dev/null +++ b/ironic/conf/virtualbox.py @@ -0,0 +1,27 @@ +# Copyright 2016 Intel Corporation +# +# 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.PortOpt('port', + default=18083, + help=_('Port on which VirtualBox web service is listening.')), +] + + +def register_opts(conf): + conf.register_opts(opts, group='virtualbox') diff --git a/ironic/drivers/modules/virtualbox.py b/ironic/drivers/modules/virtualbox.py index b58319d3c6..e8095232eb 100644 --- a/ironic/drivers/modules/virtualbox.py +++ b/ironic/drivers/modules/virtualbox.py @@ -14,7 +14,6 @@ VirtualBox Driver Modules """ -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import importutils @@ -26,6 +25,7 @@ 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 pyremotevbox = importutils.try_import('pyremotevbox') @@ -47,14 +47,6 @@ VIRTUALBOX_TO_IRONIC_POWER_MAPPING = { 'Error': states.ERROR } -opts = [ - cfg.PortOpt('port', - default=18083, - help=_('Port on which VirtualBox web service is listening.')), -] -CONF = cfg.CONF -CONF.register_opts(opts, group='virtualbox') - LOG = logging.getLogger(__name__) REQUIRED_PROPERTIES = {