Config options: centralize imagebackend libvirt options (2)

The config options of the "nova.conf" section "libvirt" got
moved to the new central location "nova/conf/libvirt.py".
Subsequent patches will then move another options in libvirt section.
This is the second patch in a long-chain patchs.

Change-Id: I3e452172e366b87b373eff33c454472c6be8f1f2
Co-Authored-by: Markus Zoeller <mzoeller@de.ibm.com>
Implements: blueprint centralize-config-options-newton
This commit is contained in:
Hieu LE 2016-04-22 10:31:37 +07:00 committed by John Garbutt
parent 7d4ce9e73f
commit d39778d5ce
5 changed files with 35 additions and 38 deletions

View File

@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import itertools
from oslo_config import cfg
# Downtime period in milliseconds
@ -213,14 +215,45 @@ libvirt_general_opts = [
'kernel (usually 1-99)')
]
libvirt_imagebackend_opts = [
cfg.StrOpt('images_type',
default='default',
choices=('raw', 'qcow2', 'lvm', 'rbd', 'ploop', 'default'),
help='VM Images format. If default is specified, then'
' use_cow_images flag is used instead of this one.'),
cfg.StrOpt('images_volume_group',
help='LVM Volume Group that is used for VM images, when you'
' specify images_type=lvm.'),
cfg.BoolOpt('sparse_logical_volumes',
default=False,
help='Create sparse logical volumes (with virtualsize)'
' if this flag is set to True.'),
cfg.StrOpt('images_rbd_pool',
default='rbd',
help='The RADOS pool in which rbd volumes are stored'),
cfg.StrOpt('images_rbd_ceph_conf',
default='', # default determined by librados
help='Path to the ceph configuration file to use'),
cfg.StrOpt('hw_disk_discard',
choices=('ignore', 'unmap'),
help='Discard option for nova managed disks. Need'
' Libvirt(1.0.6) Qemu1.5 (raw format) Qemu1.6(qcow2'
' format)'),
]
ALL_OPTS = list(itertools.chain(
libvirt_general_opts,
libvirt_imagebackend_opts,
))
def register_opts(conf):
conf.register_group(libvirt_group)
conf.register_opts(libvirt_general_opts, group=libvirt_group)
conf.register_opts(ALL_OPTS, group=libvirt_group)
# TODO(hieulq): if not using group name, oslo config will generate duplicate
# config section. This need to be remove when completely move all libvirt
# options to this place.
def list_opts():
return {libvirt_group.name: libvirt_general_opts}
return {libvirt_group.name: ALL_OPTS}

View File

@ -42,10 +42,6 @@ def qemu_img_info(path, format=None):
"""Return an object containing the parsed output from qemu-img info."""
# TODO(mikal): this code should not be referring to a libvirt specific
# flag.
# NOTE(sirp): The config option import must go here to avoid an import
# cycle
CONF.import_opt('images_type', 'nova.virt.libvirt.imagebackend',
group='libvirt')
if not os.path.exists(path) and CONF.libvirt.images_type != 'rbd':
raise exception.DiskNotFound(location=path)

View File

@ -119,8 +119,6 @@ uefi_logged = False
LOG = logging.getLogger(__name__)
CONF = nova.conf.CONF
CONF.import_opt('hw_disk_discard', 'nova.virt.libvirt.imagebackend',
group='libvirt')
CONF.import_opt('iscsi_use_multipath', 'nova.virt.libvirt.volume.iscsi',
group='libvirt')

View File

@ -20,7 +20,6 @@ import functools
import os
import shutil
from oslo_config import cfg
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import excutils
@ -45,34 +44,7 @@ from nova.virt.libvirt.storage import lvm
from nova.virt.libvirt.storage import rbd_utils
from nova.virt.libvirt import utils as libvirt_utils
__imagebackend_opts = [
cfg.StrOpt('images_type',
default='default',
choices=('raw', 'qcow2', 'lvm', 'rbd', 'ploop', 'default'),
help='VM Images format. If default is specified, then'
' use_cow_images flag is used instead of this one.'),
cfg.StrOpt('images_volume_group',
help='LVM Volume Group that is used for VM images, when you'
' specify images_type=lvm.'),
cfg.BoolOpt('sparse_logical_volumes',
default=False,
help='Create sparse logical volumes (with virtualsize)'
' if this flag is set to True.'),
cfg.StrOpt('images_rbd_pool',
default='rbd',
help='The RADOS pool in which rbd volumes are stored'),
cfg.StrOpt('images_rbd_ceph_conf',
default='', # default determined by librados
help='Path to the ceph configuration file to use'),
cfg.StrOpt('hw_disk_discard',
choices=('ignore', 'unmap'),
help='Discard option for nova managed disks. Need'
' Libvirt(1.0.6) Qemu1.5 (raw format) Qemu1.6(qcow2'
' format)'),
]
CONF = nova.conf.CONF
CONF.register_opts(__imagebackend_opts, 'libvirt')
CONF.import_opt('rbd_user', 'nova.virt.libvirt.volume.net', group='libvirt')
CONF.import_opt('rbd_secret_uuid', 'nova.virt.libvirt.volume.net',
group='libvirt')

View File

@ -12,7 +12,6 @@
import itertools
import nova.virt.libvirt.imagebackend
import nova.virt.libvirt.imagecache
import nova.virt.libvirt.storage.lvm
import nova.virt.libvirt.utils
@ -39,7 +38,6 @@ def list_opts():
return [
('libvirt',
itertools.chain(
nova.virt.libvirt.imagebackend.__imagebackend_opts,
nova.virt.libvirt.imagecache.imagecache_opts,
nova.virt.libvirt.storage.lvm.lvm_opts,
nova.virt.libvirt.utils.libvirt_opts,