From 8caaf3572eacf2db65bd37e9cac99ef153a071a9 Mon Sep 17 00:00:00 2001 From: Hemanth Makkapati Date: Tue, 29 Mar 2016 11:50:02 -0500 Subject: [PATCH] config options: centralize xenserver vm_utils opts Moves configuration options under nova/virt/xenapi/vm_utils.py to nova/conf/xenserver.py. bp centralize-config-options-newton Change-Id: I2da39474c23466b5755e75667edfd7fc9ea134d2 --- nova/conf/xenserver.py | 68 ++++++++++++++++++++++++++++++++---- nova/virt/opts.py | 2 -- nova/virt/xenapi/vm_utils.py | 59 ------------------------------- 3 files changed, 62 insertions(+), 67 deletions(-) diff --git a/nova/conf/xenserver.py b/nova/conf/xenserver.py index 24116a0ef3c7..4a0a6a5bcaf5 100644 --- a/nova/conf/xenserver.py +++ b/nova/conf/xenserver.py @@ -13,9 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import itertools - from oslo_config import cfg +from oslo_utils import units xenserver_group = cfg.OptGroup('xenserver', title='Xenserver Options') @@ -232,10 +231,67 @@ xenapi_torrent_opts = [ ] -ALL_XENSERVER_OPTS = list(itertools.chain( - xenapi_agent_opts, - xenapi_session_opts, - xenapi_torrent_opts)) +xenapi_vm_utils_opts = [ + cfg.StrOpt('cache_images', + default='all', + choices=('all', 'some', 'none'), + help='Cache glance images locally. `all` will cache all' + ' images, `some` will only cache images that have the' + ' image_property `cache_in_nova=True`, and `none` turns' + ' off caching entirely'), + cfg.IntOpt('image_compression_level', + min=1, + max=9, + help='Compression level for images, e.g., 9 for gzip -9.' + ' Range is 1-9, 9 being most compressed but most CPU' + ' intensive on dom0.'), + cfg.StrOpt('default_os_type', + default='linux', + help='Default OS type'), + cfg.IntOpt('block_device_creation_timeout', + default=10, + help='Time to wait for a block device to be created'), + cfg.IntOpt('max_kernel_ramdisk_size', + default=16 * units.Mi, + help='Maximum size in bytes of kernel or ramdisk images'), + cfg.StrOpt('sr_matching_filter', + default='default-sr:true', + help='Filter for finding the SR to be used to install guest ' + 'instances on. To use the Local Storage in default ' + 'XenServer/XCP installations set this flag to ' + 'other-config:i18n-key=local-storage. To select an SR ' + 'with a different matching criteria, you could set it to ' + 'other-config:my_favorite_sr=true. On the other hand, to ' + 'fall back on the Default SR, as displayed by XenCenter, ' + 'set this flag to: default-sr:true'), + cfg.BoolOpt('sparse_copy', + default=True, + help='Whether to use sparse_copy for copying data on a ' + 'resize down (False will use standard dd). This speeds ' + 'up resizes down considerably since large runs of zeros ' + 'won\'t have to be rsynced'), + cfg.IntOpt('num_vbd_unplug_retries', + default=10, + help='Maximum number of retries to unplug VBD. if <=0, ' + 'should try once and no retry'), + cfg.StrOpt('torrent_images', + default='none', + choices=('all', 'some', 'none'), + help='Whether or not to download images via Bit Torrent.'), + cfg.StrOpt('ipxe_network_name', + help='Name of network to use for booting iPXE ISOs'), + cfg.StrOpt('ipxe_boot_menu_url', + help='URL to the iPXE boot menu'), + cfg.StrOpt('ipxe_mkisofs_cmd', + default='mkisofs', + help='Name and optionally path of the tool used for ' + 'ISO image creation'), + ] + +ALL_XENSERVER_OPTS = (xenapi_agent_opts + + xenapi_session_opts + + xenapi_torrent_opts + + xenapi_vm_utils_opts) def register_opts(conf): diff --git a/nova/virt/opts.py b/nova/virt/opts.py index bccaea9c1248..9823eed33a64 100644 --- a/nova/virt/opts.py +++ b/nova/virt/opts.py @@ -42,7 +42,6 @@ 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.vm_utils import nova.virt.xenapi.vmops import nova.virt.xenapi.volume_utils @@ -87,7 +86,6 @@ def list_opts(): [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.vm_utils.xenapi_vm_utils_opts, nova.virt.xenapi.vmops.xenapi_vmops_opts, nova.virt.xenapi.volume_utils.xenapi_volume_utils_opts, )), diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 8920d596de84..5ed5aa05aaf2 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -29,7 +29,6 @@ from xml.parsers import expat from eventlet import greenthread from oslo_concurrency import processutils -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import importutils @@ -62,65 +61,7 @@ from nova.virt.xenapi.image import utils as image_utils LOG = logging.getLogger(__name__) -xenapi_vm_utils_opts = [ - cfg.StrOpt('cache_images', - default='all', - choices=('all', 'some', 'none'), - help='Cache glance images locally. `all` will cache all' - ' images, `some` will only cache images that have the' - ' image_property `cache_in_nova=True`, and `none` turns' - ' off caching entirely'), - cfg.IntOpt('image_compression_level', - min=1, - max=9, - help='Compression level for images, e.g., 9 for gzip -9.' - ' Range is 1-9, 9 being most compressed but most CPU' - ' intensive on dom0.'), - cfg.StrOpt('default_os_type', - default='linux', - help='Default OS type'), - cfg.IntOpt('block_device_creation_timeout', - default=10, - help='Time to wait for a block device to be created'), - cfg.IntOpt('max_kernel_ramdisk_size', - default=16 * units.Mi, - help='Maximum size in bytes of kernel or ramdisk images'), - cfg.StrOpt('sr_matching_filter', - default='default-sr:true', - help='Filter for finding the SR to be used to install guest ' - 'instances on. To use the Local Storage in default ' - 'XenServer/XCP installations set this flag to ' - 'other-config:i18n-key=local-storage. To select an SR ' - 'with a different matching criteria, you could set it to ' - 'other-config:my_favorite_sr=true. On the other hand, to ' - 'fall back on the Default SR, as displayed by XenCenter, ' - 'set this flag to: default-sr:true'), - cfg.BoolOpt('sparse_copy', - default=True, - help='Whether to use sparse_copy for copying data on a ' - 'resize down (False will use standard dd). This speeds ' - 'up resizes down considerably since large runs of zeros ' - 'won\'t have to be rsynced'), - cfg.IntOpt('num_vbd_unplug_retries', - default=10, - help='Maximum number of retries to unplug VBD. if <=0, ' - 'should try once and no retry'), - cfg.StrOpt('torrent_images', - default='none', - choices=('all', 'some', 'none'), - help='Whether or not to download images via Bit Torrent.'), - cfg.StrOpt('ipxe_network_name', - help='Name of network to use for booting iPXE ISOs'), - cfg.StrOpt('ipxe_boot_menu_url', - help='URL to the iPXE boot menu'), - cfg.StrOpt('ipxe_mkisofs_cmd', - default='mkisofs', - help='Name and optionally path of the tool used for ' - 'ISO image creation'), - ] - CONF = nova.conf.CONF -CONF.register_opts(xenapi_vm_utils_opts, 'xenserver') CONF.import_opt('use_ipv6', 'nova.netconf') XENAPI_POWER_STATE = {