config options: Centralise 'virt.disk' options

Add options from 'virt.disk'. These options are part of the
'DEFAULT' group but are included in the "nova.conf.virt" file in hope
that they can eventually be moved to their own group.

Change-Id: Ie69f5bef5f65c7ffe42adeff1defc8e86649bdba
Implements: bp centralize-config-options
This commit is contained in:
Stephen Finucane 2016-01-14 10:43:31 +00:00
parent cb072fc4e0
commit 5f70f1977d
4 changed files with 35 additions and 41 deletions

View File

@ -274,6 +274,35 @@ injected_network_template = cfg.StrOpt(
default=paths.basedir_def('nova/virt/interfaces.template'),
help='Template file for injected network')
# NOTE(yamahata): ListOpt won't work because the command may include a comma.
# For example:
#
# mkfs.ext4 -O dir_index,extent -E stride=8,stripe-width=16
# --label %(fs_label)s %(target)s
#
# list arguments are comma separated and there is no way to escape such
# commas.
virt_mkfs = cfg.MultiStrOpt(
'virt_mkfs',
default=[],
help='Name of the mkfs commands for ephemeral device. '
'The format is <os_type>=<mkfs command>')
resize_fs_using_block_device = cfg.BoolOpt(
'resize_fs_using_block_device',
default=False,
help='Attempt to resize the filesystem by accessing the '
'image over a block device. This is done by the host '
'and may not be necessary if the image contains a recent '
'version of cloud-init. Possible mechanisms require '
'the nbd driver (for qcow and raw), or loop (for raw).')
timeout_nbd = cfg.IntOpt(
'timeout_nbd',
default=10,
help='Amount of time, in seconds, to wait for NBD '
'device start up.')
ALL_OPTS = [vcpu_pin_set,
compute_driver,
default_ephemeral_format,
@ -284,7 +313,10 @@ ALL_OPTS = [vcpu_pin_set,
firewall_driver,
allow_same_net_traffic,
force_raw_images,
injected_network_template]
injected_network_template,
virt_mkfs,
resize_fs_using_block_device,
timeout_nbd]
def register_opts(conf):

View File

@ -31,7 +31,6 @@ if os.name != 'nt':
import crypt
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_log import log as logging
from oslo_serialization import jsonutils
@ -49,32 +48,7 @@ from nova.virt import images
LOG = logging.getLogger(__name__)
disk_opts = [
# NOTE(yamahata): ListOpt won't work because the command may include a
# comma. For example:
#
# mkfs.ext4 -O dir_index,extent -E stride=8,stripe-width=16
# --label %(fs_label)s %(target)s
#
# list arguments are comma separated and there is no way to
# escape such commas.
#
cfg.MultiStrOpt('virt_mkfs',
default=[],
help='Name of the mkfs commands for ephemeral device. '
'The format is <os_type>=<mkfs command>'),
cfg.BoolOpt('resize_fs_using_block_device',
default=False,
help='Attempt to resize the filesystem by accessing the '
'image over a block device. This is done by the host '
'and may not be necessary if the image contains a recent '
'version of cloud-init. Possible mechanisms require '
'the nbd driver (for qcow and raw), or loop (for raw).'),
]
CONF = nova.conf.CONF
CONF.register_opts(disk_opts)
_MKFS_COMMAND = {}
_DEFAULT_MKFS_COMMAND = None

View File

@ -18,24 +18,16 @@ import random
import re
import time
from oslo_config import cfg
from oslo_log import log as logging
import nova.conf
from nova.i18n import _, _LE, _LI, _LW
from nova import utils
from nova.virt.disk.mount import api
LOG = logging.getLogger(__name__)
nbd_opts = [
cfg.IntOpt('timeout_nbd',
default=10,
help='Amount of time, in seconds, to wait for NBD '
'device start up.'),
]
CONF = cfg.CONF
CONF.register_opts(nbd_opts)
CONF = nova.conf.CONF
NBD_DEVICE_RE = re.compile('nbd[0-9]+')

View File

@ -14,8 +14,6 @@ import itertools
import nova.conf
import nova.virt.configdrive
import nova.virt.disk.api
import nova.virt.disk.mount.nbd
import nova.virt.disk.vfs.guestfs
import nova.virt.hyperv.pathutils
import nova.virt.hyperv.vif
@ -51,8 +49,6 @@ def list_opts():
('DEFAULT',
itertools.chain(
nova.virt.configdrive.configdrive_opts,
nova.virt.disk.api.disk_opts,
nova.virt.disk.mount.nbd.nbd_opts,
nova.virt.imagecache.imagecache_opts,
)),
('guestfs', nova.virt.disk.vfs.guestfs.guestfs_opts),