From 424ab495e7ae103112def398b122b7cc528fb0a6 Mon Sep 17 00:00:00 2001 From: Anusha Unnam Date: Tue, 29 Mar 2016 22:23:09 +0000 Subject: [PATCH] Config options: Centralize xenapi driver options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The config options of "nova/virt/xenapi/driver.py" got moved to the new central location "nova/conf/xenserver.py” Change-Id: I87f6163c7a3b69ef8ede947132b771f32742781e Implements: blueprint centralize-config-options-newton --- nova/conf/xenserver.py | 54 +++++++++++++++++++++- nova/tests/unit/virt/xenapi/test_xenapi.py | 2 - nova/virt/opts.py | 3 -- nova/virt/xenapi/driver.py | 54 +--------------------- tools/xenserver/destroy_cached_images.py | 11 +---- 5 files changed, 57 insertions(+), 67 deletions(-) diff --git a/nova/conf/xenserver.py b/nova/conf/xenserver.py index 4a0a6a5bcaf5..175d50a1ea4a 100644 --- a/nova/conf/xenserver.py +++ b/nova/conf/xenserver.py @@ -288,10 +288,62 @@ xenapi_vm_utils_opts = [ 'ISO image creation'), ] + +xenapi_opts = [ + cfg.StrOpt('connection_url', + help='URL for connection to XenServer/Xen Cloud Platform. ' + 'A special value of unix://local can be used to connect ' + 'to the local unix socket. ' + 'Required if compute_driver=xenapi.XenAPIDriver'), + cfg.StrOpt('connection_username', + default='root', + help='Username for connection to XenServer/Xen Cloud Platform. ' + 'Used only if compute_driver=xenapi.XenAPIDriver'), + cfg.StrOpt('connection_password', + help='Password for connection to XenServer/Xen Cloud Platform. ' + 'Used only if compute_driver=xenapi.XenAPIDriver', + secret=True), + cfg.FloatOpt('vhd_coalesce_poll_interval', + default=5.0, + help='The interval used for polling of coalescing vhds. ' + 'Used only if compute_driver=xenapi.XenAPIDriver'), + cfg.BoolOpt('check_host', + default=True, + help='Ensure compute service is running on host XenAPI ' + 'connects to.'), + cfg.IntOpt('vhd_coalesce_max_attempts', + default=20, + help='Max number of times to poll for VHD to coalesce. ' + 'Used only if compute_driver=xenapi.XenAPIDriver'), + cfg.StrOpt('sr_base_path', + default='/var/run/sr-mount', + help='Base path to the storage repository'), + cfg.StrOpt('target_host', + help='The iSCSI Target Host'), + cfg.StrOpt('target_port', + default='3260', + help='The iSCSI Target Port, default is port 3260'), + cfg.StrOpt('iqn_prefix', + default='iqn.2010-10.org.openstack', + help='IQN Prefix'), + # NOTE(sirp): This is a work-around for a bug in Ubuntu Maverick, + # when we pull support for it, we should remove this + cfg.BoolOpt('remap_vbd_dev', + default=False, + help='Used to enable the remapping of VBD dev ' + '(Works around an issue in Ubuntu Maverick)'), + cfg.StrOpt('remap_vbd_dev_prefix', + default='sd', + help='Specify prefix to remap VBD dev to ' + '(ex. /dev/xvdb -> /dev/sdb)'), +] + + ALL_XENSERVER_OPTS = (xenapi_agent_opts + xenapi_session_opts + xenapi_torrent_opts + - xenapi_vm_utils_opts) + xenapi_vm_utils_opts + + xenapi_opts) def register_opts(conf): diff --git a/nova/tests/unit/virt/xenapi/test_xenapi.py b/nova/tests/unit/virt/xenapi/test_xenapi.py index 81ac9d27981a..9c0bfdf7a68f 100644 --- a/nova/tests/unit/virt/xenapi/test_xenapi.py +++ b/nova/tests/unit/virt/xenapi/test_xenapi.py @@ -75,8 +75,6 @@ LOG = logging.getLogger(__name__) CONF = nova.conf.CONF CONF.import_opt('host', 'nova.netconf') -CONF.import_opt('login_timeout', 'nova.virt.xenapi.client.session', - group="xenserver") IMAGE_MACHINE = '1' IMAGE_KERNEL = '2' diff --git a/nova/virt/opts.py b/nova/virt/opts.py index 9823eed33a64..6f6c37deeba4 100644 --- a/nova/virt/opts.py +++ b/nova/virt/opts.py @@ -38,8 +38,6 @@ import nova.virt.vmwareapi.vim_util import nova.virt.vmwareapi.vm_util import nova.virt.vmwareapi.vmops import nova.virt.xenapi.agent -import nova.virt.xenapi.client.session -import nova.virt.xenapi.driver import nova.virt.xenapi.pool import nova.virt.xenapi.vif import nova.virt.xenapi.vmops @@ -84,7 +82,6 @@ def list_opts(): ('xenserver', itertools.chain( [nova.virt.xenapi.vif.xenapi_ovs_integration_bridge_opt], - nova.virt.xenapi.driver.xenapi_opts, nova.virt.xenapi.pool.xenapi_pool_opts, nova.virt.xenapi.vmops.xenapi_vmops_opts, nova.virt.xenapi.volume_utils.xenapi_volume_utils_opts, diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py index 77483faba41d..c9c77dc69868 100644 --- a/nova/virt/xenapi/driver.py +++ b/nova/virt/xenapi/driver.py @@ -25,7 +25,6 @@ A driver for XenServer or Xen Cloud Platform. import math -from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils from oslo_utils import units @@ -33,6 +32,7 @@ from oslo_utils import versionutils import six import six.moves.urllib.parse as urlparse +import nova.conf from nova.i18n import _, _LE, _LW from nova.virt import driver from nova.virt.xenapi.client import session @@ -44,57 +44,7 @@ from nova.virt.xenapi import volumeops LOG = logging.getLogger(__name__) -xenapi_opts = [ - cfg.StrOpt('connection_url', - help='URL for connection to XenServer/Xen Cloud Platform. ' - 'A special value of unix://local can be used to connect ' - 'to the local unix socket. ' - 'Required if compute_driver=xenapi.XenAPIDriver'), - cfg.StrOpt('connection_username', - default='root', - help='Username for connection to XenServer/Xen Cloud Platform. ' - 'Used only if compute_driver=xenapi.XenAPIDriver'), - cfg.StrOpt('connection_password', - help='Password for connection to XenServer/Xen Cloud Platform. ' - 'Used only if compute_driver=xenapi.XenAPIDriver', - secret=True), - cfg.FloatOpt('vhd_coalesce_poll_interval', - default=5.0, - help='The interval used for polling of coalescing vhds. ' - 'Used only if compute_driver=xenapi.XenAPIDriver'), - cfg.BoolOpt('check_host', - default=True, - help='Ensure compute service is running on host XenAPI ' - 'connects to.'), - cfg.IntOpt('vhd_coalesce_max_attempts', - default=20, - help='Max number of times to poll for VHD to coalesce. ' - 'Used only if compute_driver=xenapi.XenAPIDriver'), - cfg.StrOpt('sr_base_path', - default='/var/run/sr-mount', - help='Base path to the storage repository'), - cfg.StrOpt('target_host', - help='The iSCSI Target Host'), - cfg.StrOpt('target_port', - default='3260', - help='The iSCSI Target Port, default is port 3260'), - cfg.StrOpt('iqn_prefix', - default='iqn.2010-10.org.openstack', - help='IQN Prefix'), - # NOTE(sirp): This is a work-around for a bug in Ubuntu Maverick, - # when we pull support for it, we should remove this - cfg.BoolOpt('remap_vbd_dev', - default=False, - help='Used to enable the remapping of VBD dev ' - '(Works around an issue in Ubuntu Maverick)'), - cfg.StrOpt('remap_vbd_dev_prefix', - default='sd', - help='Specify prefix to remap VBD dev to ' - '(ex. /dev/xvdb -> /dev/sdb)'), - ] - -CONF = cfg.CONF -CONF.register_opts(xenapi_opts, 'xenserver') +CONF = nova.conf.CONF CONF.import_opt('host', 'nova.netconf') OVERHEAD_BASE = 3 diff --git a/tools/xenserver/destroy_cached_images.py b/tools/xenserver/destroy_cached_images.py index 4b7df3579220..8e32d6463033 100644 --- a/tools/xenserver/destroy_cached_images.py +++ b/tools/xenserver/destroy_cached_images.py @@ -27,6 +27,7 @@ POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')): sys.path.insert(0, POSSIBLE_TOPDIR) +import nova.conf from nova import config from nova import utils from nova.virt.xenapi.client import session @@ -42,17 +43,9 @@ destroy_opts = [ help='Don\'t actually delete the VDIs.') ] -CONF = cfg.CONF +CONF = nova.conf.CONF CONF.register_cli_opts(destroy_opts) -CONF.import_opt('connection_url', 'nova.virt.xenapi.driver', - group='xenserver') -CONF.import_opt('connection_username', 'nova.virt.xenapi.driver', - group='xenserver') -CONF.import_opt('connection_password', 'nova.virt.xenapi.driver', - group='xenserver') - - def main(): config.parse_args(sys.argv) utils.monkey_patch()