diff --git a/nova/api/openstack/compute/legacy_v2/servers.py b/nova/api/openstack/compute/legacy_v2/servers.py index 47a6db362a..5a81a97b31 100644 --- a/nova/api/openstack/compute/legacy_v2/servers.py +++ b/nova/api/openstack/compute/legacy_v2/servers.py @@ -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__) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index c34dffda9b..eb8e03e2ab 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -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', diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 1261a4bcc6..680d4da24d 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -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__) diff --git a/nova/compute/opts.py b/nova/compute/opts.py index 9b47886425..55f8b93f49 100644 --- a/nova/compute/opts.py +++ b/nova/compute/opts.py @@ -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, )), ] diff --git a/nova/conf/compute.py b/nova/conf/compute.py index f89b6af046..be2aadd9ec 100644 --- a/nova/conf/compute.py +++ b/nova/conf/compute.py @@ -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): diff --git a/nova/tests/functional/api_sample_tests/test_shelve.py b/nova/tests/functional/api_sample_tests/test_shelve.py index f43b425a4a..6db8825395 100644 --- a/nova/tests/functional/api_sample_tests/test_shelve.py +++ b/nova/tests/functional/api_sample_tests/test_shelve.py @@ -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') diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index cbfc136be9..0535ac8ddd 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -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 diff --git a/nova/tests/unit/compute/test_shelve.py b/nova/tests/unit/compute/test_shelve.py index eb2547b82f..27d18bbd81 100644 --- a/nova/tests/unit/compute/test_shelve.py +++ b/nova/tests/unit/compute/test_shelve.py @@ -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(): diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index c842a0fd8c..62a129dd54 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -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 diff --git a/nova/virt/hyperv/pathutils.py b/nova/virt/hyperv/pathutils.py index d97a8b7ca6..0d526cb241 100644 --- a/nova/virt/hyperv/pathutils.py +++ b/nova/virt/hyperv/pathutils.py @@ -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 diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 3cb30c5a96..c4c12cafe5 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -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', diff --git a/nova/virt/libvirt/firewall.py b/nova/virt/libvirt/firewall.py index 884272786a..70df45ea79 100644 --- a/nova/virt/libvirt/firewall.py +++ b/nova/virt/libvirt/firewall.py @@ -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 diff --git a/nova/virt/libvirt/imagecache.py b/nova/virt/libvirt/imagecache.py index 5d2e06efd4..0a953a7853 100644 --- a/nova/virt/libvirt/imagecache.py +++ b/nova/virt/libvirt/imagecache.py @@ -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): diff --git a/nova/virt/libvirt/storage/lvm.py b/nova/virt/libvirt/storage/lvm.py index e7a9c60721..52c6270ed0 100644 --- a/nova/virt/libvirt/storage/lvm.py +++ b/nova/virt/libvirt/storage/lvm.py @@ -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__) diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py index 1925cdadd6..14280e8aa3 100644 --- a/nova/virt/libvirt/utils.py +++ b/nova/virt/libvirt/utils.py @@ -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' diff --git a/tools/xenserver/vm_vdi_cleaner.py b/tools/xenserver/vm_vdi_cleaner.py index 10ca0da8d2..ef5787aa6f 100755 --- a/tools/xenserver/vm_vdi_cleaner.py +++ b/tools/xenserver/vm_vdi_cleaner.py @@ -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",