Config options: Centralize compute options

This change moves the config options in nova/compute/
manager.py to a central location "nova/conf/compute.py".

Change-Id: Iac75f966571d1224fcd9487b110cb5a4eaa29219
Implements: blueprint centralize-config-options-newton
This commit is contained in:
Sujitha
2016-03-21 22:39:29 +00:00
parent 5538efa1fb
commit 8fc7d30600
16 changed files with 182 additions and 199 deletions

View File

@@ -35,6 +35,7 @@ from nova.api.openstack import wsgi
from nova import block_device
from nova import compute
from nova.compute import flavors
import nova.conf
from nova import exception
from nova.i18n import _
from nova import objects
@@ -51,9 +52,8 @@ server_opts = [
' password injection then the password returned will'
' not be correct'),
]
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.register_opts(server_opts)
CONF.import_opt('reclaim_instance_interval', 'nova.compute.manager')
LOG = logging.getLogger(__name__)

View File

@@ -17,7 +17,6 @@
import base64
import re
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging as messaging
from oslo_utils import strutils
@@ -37,6 +36,7 @@ from nova.api.openstack import wsgi
from nova.api import validation
from nova import compute
from nova.compute import flavors
import nova.conf
from nova import exception
from nova.i18n import _
from nova.i18n import _LW
@@ -47,10 +47,9 @@ from nova import utils
ALIAS = 'servers'
TAG_SEARCH_FILTERS = ('tags', 'tags-any', 'not-tags', 'not-tags-any')
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.import_opt('enable_instance_password',
'nova.api.openstack.compute.legacy_v2.servers')
CONF.import_opt('reclaim_instance_interval', 'nova.compute.manager')
CONF.import_opt('extensions_blacklist', 'nova.api.openstack',
group='osapi_v21')
CONF.import_opt('extensions_whitelist', 'nova.api.openstack',

View File

@@ -29,7 +29,6 @@ import base64
import contextlib
import functools
import inspect
import socket
import sys
import time
import traceback
@@ -41,7 +40,6 @@ from eventlet import greenthread
import eventlet.semaphore
import eventlet.timeout
from keystoneauth1 import exceptions as keystone_exception
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging as messaging
from oslo_serialization import jsonutils
@@ -67,7 +65,6 @@ from nova.compute import utils as compute_utils
from nova.compute import vm_states
from nova import conductor
import nova.conf
from nova.conf import paths
from nova import consoleauth
import nova.context
from nova import exception
@@ -100,170 +97,7 @@ from nova.virt import virtapi
from nova import volume
from nova.volume import encryptors
compute_opts = [
cfg.StrOpt('console_host',
default=socket.gethostname(),
help='Console proxy host to use to connect '
'to instances on this host.'),
cfg.StrOpt('default_access_ip_network_name',
help='Name of network to use to set access IPs for instances'),
cfg.BoolOpt('defer_iptables_apply',
default=False,
help='Whether to batch up the application of IPTables rules'
' during a host restart and apply all at the end of the'
' init phase'),
cfg.StrOpt('instances_path',
default=paths.state_path_def('instances'),
help='Where instances are stored on disk'),
cfg.BoolOpt('instance_usage_audit',
default=False,
help="Generate periodic compute.instance.exists"
" notifications"),
cfg.IntOpt('live_migration_retry_count',
default=30,
help="Number of 1 second retries needed in live_migration"),
cfg.BoolOpt('resume_guests_state_on_host_boot',
default=False,
help='Whether to start guests that were running before the '
'host rebooted'),
cfg.IntOpt('network_allocate_retries',
default=0,
help="Number of times to retry network allocation on failures"),
cfg.IntOpt('max_concurrent_builds',
default=10,
help='Maximum number of instance builds to run concurrently'),
cfg.IntOpt('max_concurrent_live_migrations',
default=1,
help='Maximum number of live migrations to run concurrently. '
'This limit is enforced to avoid outbound live migrations '
'overwhelming the host/network and causing failures. It '
'is not recommended that you change this unless you are '
'very sure that doing so is safe and stable in your '
'environment.'),
cfg.IntOpt('block_device_allocate_retries',
default=60,
help='Number of times to retry block device '
'allocation on failures.\n'
'Starting with Liberty, Cinder can use image volume '
'cache. This may help with block device allocation '
'performance. Look at the cinder '
'image_volume_cache_enabled configuration option.')
]
interval_opts = [
cfg.IntOpt('bandwidth_poll_interval',
default=600,
help='Interval to pull network bandwidth usage info. Not '
'supported on all hypervisors. Set to -1 to disable. '
'Setting this to 0 will run at the default rate.'),
cfg.IntOpt('sync_power_state_interval',
default=600,
help='Interval to sync power states between the database and '
'the hypervisor. Set to -1 to disable. '
'Setting this to 0 will run at the default rate.'),
cfg.IntOpt("heal_instance_info_cache_interval",
default=60,
help="Number of seconds between instance network information "
"cache updates"),
cfg.IntOpt('reclaim_instance_interval',
min=0,
default=0,
help='Interval in seconds for reclaiming deleted instances. '
'It takes effect only when value is greater than 0.'),
cfg.IntOpt('volume_usage_poll_interval',
default=0,
help='Interval in seconds for gathering volume usages'),
cfg.IntOpt('shelved_poll_interval',
default=3600,
help='Interval in seconds for polling shelved instances to '
'offload. Set to -1 to disable.'
'Setting this to 0 will run at the default rate.'),
cfg.IntOpt('shelved_offload_time',
default=0,
help='Time in seconds before a shelved instance is eligible '
'for removing from a host. -1 never offload, 0 offload '
'immediately when shelved'),
cfg.IntOpt('instance_delete_interval',
default=300,
help='Interval in seconds for retrying failed instance file '
'deletes. Set to -1 to disable. '
'Setting this to 0 will run at the default rate.'),
cfg.IntOpt('block_device_allocate_retries_interval',
default=3,
help='Waiting time interval (seconds) between block'
' device allocation retries on failures'),
cfg.IntOpt('scheduler_instance_sync_interval',
default=120,
help='Waiting time interval (seconds) between sending the '
'scheduler a list of current instance UUIDs to verify '
'that its view of instances is in sync with nova. If the '
'CONF option `scheduler_tracks_instance_changes` is '
'False, changing this option will have no effect.'),
cfg.IntOpt('update_resources_interval',
default=0,
help='Interval in seconds for updating compute resources. A '
'number less than 0 means to disable the task completely. '
'Leaving this at the default of 0 will cause this to run '
'at the default periodic interval. Setting it to any '
'positive value will cause it to run at approximately '
'that number of seconds.'),
]
timeout_opts = [
cfg.IntOpt("reboot_timeout",
default=0,
help="Automatically hard reboot an instance if it has been "
"stuck in a rebooting state longer than N seconds. "
"Set to 0 to disable."),
cfg.IntOpt("instance_build_timeout",
default=0,
help="Amount of time in seconds an instance can be in BUILD "
"before going into ERROR status. "
"Set to 0 to disable."),
cfg.IntOpt("rescue_timeout",
default=0,
help="Automatically unrescue an instance after N seconds. "
"Set to 0 to disable."),
cfg.IntOpt("resize_confirm_window",
default=0,
help="Automatically confirm resizes and cold migrations "
"after N seconds. Set to 0 to disable."),
cfg.IntOpt("shutdown_timeout",
default=60,
help="Total amount of time to wait in seconds for an instance "
"to perform a clean shutdown."),
]
running_deleted_opts = [
cfg.StrOpt("running_deleted_instance_action",
default="reap",
choices=('noop', 'log', 'shutdown', 'reap'),
help="Action to take if a running deleted instance is detected."
"Set to 'noop' to take no action."),
cfg.IntOpt("running_deleted_instance_poll_interval",
default=1800,
help="Number of seconds to wait between runs of the cleanup "
"task."),
cfg.IntOpt("running_deleted_instance_timeout",
default=0,
help="Number of seconds after being deleted when a running "
"instance should be considered eligible for cleanup."),
]
instance_cleaning_opts = [
cfg.IntOpt('maximum_instance_delete_attempts',
default=5,
help='The number of times to attempt to reap an instance\'s '
'files.'),
]
CONF = nova.conf.CONF
CONF.register_opts(compute_opts)
CONF.register_opts(interval_opts)
CONF.register_opts(timeout_opts)
CONF.register_opts(running_deleted_opts)
CONF.register_opts(instance_cleaning_opts)
CONF.import_opt('host', 'nova.netconf')
LOG = logging.getLogger(__name__)

View File

@@ -13,7 +13,6 @@
import itertools
import nova.compute.flavors
import nova.compute.manager
import nova.compute.monitors
import nova.compute.rpcapi
import nova.conf
@@ -24,11 +23,6 @@ def list_opts():
('DEFAULT',
itertools.chain(
nova.compute.flavors.flavor_opts,
nova.compute.manager.compute_opts,
nova.compute.manager.instance_cleaning_opts,
nova.compute.manager.interval_opts,
nova.compute.manager.running_deleted_opts,
nova.compute.manager.timeout_opts,
nova.compute.rpcapi.rpcapi_opts,
)),
]

View File

@@ -15,9 +15,12 @@
# under the License.
import itertools
import socket
from oslo_config import cfg
from nova.conf import paths
compute_opts = [
cfg.BoolOpt('allow_resize_to_same_host',
default=False,
@@ -126,11 +129,172 @@ allocation_ratio_opts = [
'and defaulted to 1.0'),
]
compute_manager_opts = [
cfg.StrOpt('console_host',
default=socket.gethostname(),
help='Console proxy host to use to connect '
'to instances on this host.'),
cfg.StrOpt('default_access_ip_network_name',
help='Name of network to use to set access IPs for instances'),
cfg.BoolOpt('defer_iptables_apply',
default=False,
help='Whether to batch up the application of IPTables rules'
' during a host restart and apply all at the end of the'
' init phase'),
cfg.StrOpt('instances_path',
default=paths.state_path_def('instances'),
help='Where instances are stored on disk'),
cfg.BoolOpt('instance_usage_audit',
default=False,
help="Generate periodic compute.instance.exists"
" notifications"),
cfg.IntOpt('live_migration_retry_count',
default=30,
help="Number of 1 second retries needed in live_migration"),
cfg.BoolOpt('resume_guests_state_on_host_boot',
default=False,
help='Whether to start guests that were running before the '
'host rebooted'),
cfg.IntOpt('network_allocate_retries',
default=0,
help="Number of times to retry network allocation on failures"),
cfg.IntOpt('max_concurrent_builds',
default=10,
help='Maximum number of instance builds to run concurrently'),
cfg.IntOpt('max_concurrent_live_migrations',
default=1,
help='Maximum number of live migrations to run concurrently. '
'This limit is enforced to avoid outbound live migrations '
'overwhelming the host/network and causing failures. It '
'is not recommended that you change this unless you are '
'very sure that doing so is safe and stable in your '
'environment.'),
cfg.IntOpt('block_device_allocate_retries',
default=60,
help='Number of times to retry block device '
'allocation on failures.\n'
'Starting with Liberty, Cinder can use image volume '
'cache. This may help with block device allocation '
'performance. Look at the cinder '
'image_volume_cache_enabled configuration option.')
]
interval_opts = [
cfg.IntOpt('bandwidth_poll_interval',
default=600,
help='Interval to pull network bandwidth usage info. Not '
'supported on all hypervisors. Set to -1 to disable. '
'Setting this to 0 will run at the default rate.'),
cfg.IntOpt('sync_power_state_interval',
default=600,
help='Interval to sync power states between the database and '
'the hypervisor. Set to -1 to disable. '
'Setting this to 0 will run at the default rate.'),
cfg.IntOpt("heal_instance_info_cache_interval",
default=60,
help="Number of seconds between instance network information "
"cache updates"),
cfg.IntOpt('reclaim_instance_interval',
min=0,
default=0,
help='Interval in seconds for reclaiming deleted instances. '
'It takes effect only when value is greater than 0.'),
cfg.IntOpt('volume_usage_poll_interval',
default=0,
help='Interval in seconds for gathering volume usages'),
cfg.IntOpt('shelved_poll_interval',
default=3600,
help='Interval in seconds for polling shelved instances to '
'offload. Set to -1 to disable.'
'Setting this to 0 will run at the default rate.'),
cfg.IntOpt('shelved_offload_time',
default=0,
help='Time in seconds before a shelved instance is eligible '
'for removing from a host. -1 never offload, 0 offload '
'immediately when shelved'),
cfg.IntOpt('instance_delete_interval',
default=300,
help='Interval in seconds for retrying failed instance file '
'deletes. Set to -1 to disable. '
'Setting this to 0 will run at the default rate.'),
cfg.IntOpt('block_device_allocate_retries_interval',
default=3,
help='Waiting time interval (seconds) between block'
' device allocation retries on failures'),
cfg.IntOpt('scheduler_instance_sync_interval',
default=120,
help='Waiting time interval (seconds) between sending the '
'scheduler a list of current instance UUIDs to verify '
'that its view of instances is in sync with nova. If the '
'CONF option `scheduler_tracks_instance_changes` is '
'False, changing this option will have no effect.'),
cfg.IntOpt('update_resources_interval',
default=0,
help='Interval in seconds for updating compute resources. A '
'number less than 0 means to disable the task completely. '
'Leaving this at the default of 0 will cause this to run '
'at the default periodic interval. Setting it to any '
'positive value will cause it to run at approximately '
'that number of seconds.'),
]
timeout_opts = [
cfg.IntOpt("reboot_timeout",
default=0,
help="Automatically hard reboot an instance if it has been "
"stuck in a rebooting state longer than N seconds. "
"Set to 0 to disable."),
cfg.IntOpt("instance_build_timeout",
default=0,
help="Amount of time in seconds an instance can be in BUILD "
"before going into ERROR status. "
"Set to 0 to disable."),
cfg.IntOpt("rescue_timeout",
default=0,
help="Automatically unrescue an instance after N seconds. "
"Set to 0 to disable."),
cfg.IntOpt("resize_confirm_window",
default=0,
help="Automatically confirm resizes after N seconds. "
"Set to 0 to disable."),
cfg.IntOpt("shutdown_timeout",
default=60,
help="Total amount of time to wait in seconds for an instance "
"to perform a clean shutdown."),
]
running_deleted_opts = [
cfg.StrOpt("running_deleted_instance_action",
default="reap",
choices=('noop', 'log', 'shutdown', 'reap'),
help="Action to take if a running deleted instance is detected."
"Set to 'noop' to take no action."),
cfg.IntOpt("running_deleted_instance_poll_interval",
default=1800,
help="Number of seconds to wait between runs of the cleanup "
"task."),
cfg.IntOpt("running_deleted_instance_timeout",
default=0,
help="Number of seconds after being deleted when a running "
"instance should be considered eligible for cleanup."),
]
instance_cleaning_opts = [
cfg.IntOpt('maximum_instance_delete_attempts',
default=5,
help='The number of times to attempt to reap an instance\'s '
'files.'),
]
ALL_OPTS = list(itertools.chain(
compute_opts,
resource_tracker_opts,
allocation_ratio_opts
))
allocation_ratio_opts,
compute_manager_opts,
interval_opts,
timeout_opts,
running_deleted_opts,
instance_cleaning_opts))
def register_opts(conf):

View File

@@ -13,12 +13,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
import nova.conf
from nova.tests.functional.api_sample_tests import test_servers
CONF = cfg.CONF
CONF.import_opt('shelved_offload_time', 'nova.compute.manager')
CONF = nova.conf.CONF
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.legacy_v2.extensions')

View File

@@ -100,7 +100,6 @@ QUOTAS = quota.QUOTAS
LOG = logging.getLogger(__name__)
CONF = nova.conf.CONF
CONF.import_opt('host', 'nova.netconf')
CONF.import_opt('live_migration_retry_count', 'nova.compute.manager')
FAKE_IMAGE_REF = uuids.image_ref

View File

@@ -12,20 +12,19 @@
import mock
from mox3 import mox
from oslo_config import cfg
from oslo_utils import fixture as utils_fixture
from oslo_utils import timeutils
from nova.compute import claims
from nova.compute import task_states
from nova.compute import vm_states
import nova.conf
from nova import db
from nova import objects
from nova.tests.unit.compute import test_compute
from nova.tests.unit.image import fake as fake_image
CONF = cfg.CONF
CONF.import_opt('shelved_offload_time', 'nova.compute.manager')
CONF = nova.conf.CONF
def _fake_resources():

View File

@@ -110,7 +110,6 @@ libvirt_guest.libvirt = fakelibvirt
CONF = nova.conf.CONF
CONF.import_opt('host', 'nova.netconf')
CONF.import_opt('my_ip', 'nova.netconf')
CONF.import_opt('instances_path', 'nova.compute.manager')
_fake_network_info = fake_network.fake_get_instance_nw_info

View File

@@ -23,7 +23,6 @@ from nova.i18n import _
from nova.virt.hyperv import constants
CONF = nova.conf.CONF
CONF.import_opt('instances_path', 'nova.compute.manager')
ERROR_INVALID_NAME = 123

View File

@@ -314,7 +314,6 @@ CONF = nova.conf.CONF
CONF.register_opts(libvirt_opts, 'libvirt')
CONF.import_opt('host', 'nova.netconf')
CONF.import_opt('my_ip', 'nova.netconf')
CONF.import_opt('live_migration_retry_count', 'nova.compute.manager')
CONF.import_opt('hw_disk_discard', 'nova.virt.libvirt.imagebackend',
group='libvirt')
CONF.import_opt('iscsi_use_multipath', 'nova.virt.libvirt.volume.iscsi',

View File

@@ -19,20 +19,19 @@ import uuid
from eventlet import greenthread
from lxml import etree
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
from nova.cloudpipe import pipelib
import nova.conf
from nova.i18n import _LI
from nova.i18n import _LW
import nova.virt.firewall as base_firewall
from nova.virt import netutils
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.import_opt('use_ipv6', 'nova.netconf')
CONF.import_opt('live_migration_retry_count', 'nova.compute.manager')
libvirt = None

View File

@@ -70,7 +70,6 @@ imagecache_opts = [
CONF = nova.conf.CONF
CONF.register_opts(imagecache_opts, 'libvirt')
CONF.import_opt('instances_path', 'nova.compute.manager')
def get_cache_fname(images, key):

View File

@@ -25,6 +25,7 @@ from oslo_log import log as logging
from oslo_utils import units
import six
import nova.conf
from nova import exception
from nova.i18n import _
from nova.i18n import _LW
@@ -41,9 +42,8 @@ lvm_opts = [
help='Size in MiB to wipe at start of old volumes. 0 => all'),
]
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.register_opts(lvm_opts, 'libvirt')
CONF.import_opt('instances_path', 'nova.compute.manager')
LOG = logging.getLogger(__name__)

View File

@@ -29,6 +29,7 @@ from oslo_log import log as logging
from nova.compute import arch
from nova.compute import vm_mode
import nova.conf
from nova.i18n import _
from nova.i18n import _LI
from nova import utils
@@ -44,9 +45,8 @@ libvirt_opts = [
'currently applies exclusively to qcow2 images'),
]
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.register_opts(libvirt_opts, 'libvirt')
CONF.import_opt('instances_path', 'nova.compute.manager')
LOG = logging.getLogger(__name__)
RESIZE_SNAPSHOT_NAME = 'nova-resize'

View File

@@ -29,6 +29,7 @@ if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")):
from nova import config
from nova import context
import nova.conf
from nova import db
from nova import exception
from oslo_utils import timeutils
@@ -45,11 +46,10 @@ cleaner_opts = [
cli_opt = cfg.StrOpt('command',
help='Cleaner command')
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.register_opts(cleaner_opts)
CONF.register_cli_opt(cli_opt)
CONF.import_opt('verbose', 'nova.openstack.common.log')
CONF.import_opt("resize_confirm_window", "nova.compute.manager")
ALLOWED_COMMANDS = ["list-vdis", "clean-vdis", "list-instances",