From 3859af4596bd2fba6de0242e900ebd64ea0ae28a Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 21 Nov 2012 22:44:07 +0000 Subject: Move compute opts from nova.config A bunch of config options are declared in nova.config but only used in nova.compute.api or nova.compute.manager. Move them to the module which uses them. blueprint: scope-config-opts Change-Id: Id33182e9276f61e799305b6b743d1a1f34f25625 --- nova/api/openstack/compute/servers.py | 2 +- nova/compute/api.py | 29 ++++++++++++++++++---- nova/compute/manager.py | 28 +++++++++++++++++----- nova/config.py | 40 ------------------------------- nova/tests/image/fake.py | 2 +- nova/tests/integrated/test_api_samples.py | 2 +- 6 files changed, 49 insertions(+), 54 deletions(-) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index e386ee1c7..d360026dd 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -45,7 +45,7 @@ CONF = cfg.CONF CONF.import_opt('enable_instance_password', 'nova.config') CONF.import_opt('network_api_class', 'nova.config') CONF.import_opt('password_length', 'nova.config') -CONF.import_opt('reclaim_instance_interval', 'nova.config') +CONF.import_opt('reclaim_instance_interval', 'nova.compute.manager') def make_fault(elem): diff --git a/nova/compute/api.py b/nova/compute/api.py index 48068eca1..a9c465909 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -59,13 +59,32 @@ from nova import volume LOG = logging.getLogger(__name__) +compute_opts = [ + cfg.BoolOpt('allow_resize_to_same_host', + default=False, + help='Allow destination machine to match source for resize. ' + 'Useful when testing in single-host environments.'), + cfg.StrOpt('default_schedule_zone', + default=None, + help='availability zone to use when user doesn\'t specify one'), + cfg.ListOpt('non_inheritable_image_properties', + default=['cache_in_nova', + 'bittorrent'], + help='These are image properties which a snapshot should not' + ' inherit from an instance'), + cfg.StrOpt('null_kernel', + default='nokernel', + help='kernel image that indicates not to use a kernel, but to ' + 'use a raw disk image instead'), + cfg.StrOpt('security_group_handler', + default='nova.network.sg.NullSecurityGroupHandler', + help='The full class name of the security group handler class'), +] + + CONF = cfg.CONF -CONF.import_opt('allow_resize_to_same_host', 'nova.config') +CONF.register_opts(compute_opts) CONF.import_opt('compute_topic', 'nova.config') -CONF.import_opt('default_schedule_zone', 'nova.config') -CONF.import_opt('non_inheritable_image_properties', 'nova.config') -CONF.import_opt('null_kernel', 'nova.config') -CONF.import_opt('security_group_handler', 'nova.config') CONF.import_opt('consoleauth_topic', 'nova.consoleauth') MAX_USERDATA_SIZE = 65535 diff --git a/nova/compute/manager.py b/nova/compute/manager.py index eab4906b0..51916e4ee 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -139,23 +139,39 @@ compute_opts = [ cfg.BoolOpt('instance_usage_audit', default=False, help="Generate periodic compute.instance.exists notifications"), + cfg.IntOpt('bandwidth_poll_interval', + default=600, + help='interval to pull bandwidth usage info'), + cfg.BoolOpt('resume_guests_state_on_host_boot', + default=False, + help='Whether to start guests that were running before the ' + 'host rebooted'), + cfg.BoolOpt('start_guests_on_host_boot', + default=False, + help='Whether to restart guests when the host reboots'), + cfg.StrOpt('default_access_ip_network_name', + default=None, + 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.IntOpt('reclaim_instance_interval', + default=0, + help='Interval in seconds for reclaiming deleted instances'), ] CONF = cfg.CONF CONF.register_opts(compute_opts) -CONF.import_opt('allow_resize_to_same_host', 'nova.config') -CONF.import_opt('bandwidth_poll_interval', 'nova.config') +CONF.import_opt('allow_resize_to_same_host', 'nova.compute.api') CONF.import_opt('compute_driver', 'nova.config') CONF.import_opt('console_topic', 'nova.config') -CONF.import_opt('default_access_ip_network_name', 'nova.config') -CONF.import_opt('defer_iptables_apply', 'nova.config') CONF.import_opt('host', 'nova.config') CONF.import_opt('my_ip', 'nova.config') CONF.import_opt('network_manager', 'nova.config') CONF.import_opt('password_length', 'nova.config') CONF.import_opt('reclaim_instance_interval', 'nova.config') -CONF.import_opt('resume_guests_state_on_host_boot', 'nova.config') -CONF.import_opt('start_guests_on_host_boot', 'nova.config') CONF.import_opt('vpn_image_id', 'nova.config') CONF.import_opt('my_ip', 'nova.config') CONF.import_opt('state_path', 'nova.config') diff --git a/nova/config.py b/nova/config.py index 7cf1fc30f..ca707a4bb 100644 --- a/nova/config.py +++ b/nova/config.py @@ -184,10 +184,6 @@ global_opts = [ cfg.StrOpt('default_instance_type', default='m1.small', help='default instance type to use, testing only'), - cfg.StrOpt('null_kernel', - default='nokernel', - help='kernel image that indicates not to use a kernel, but to ' - 'use a raw disk image instead'), cfg.StrOpt('vpn_image_id', default='0', help='image id used when starting up a cloudpipe vpn server'), @@ -235,16 +231,6 @@ global_opts = [ default='month', help='time period to generate instance usages for. ' 'Time period must be hour, day, month or year'), - cfg.IntOpt('bandwidth_poll_interval', - default=600, - help='interval to pull bandwidth usage info'), - cfg.BoolOpt('start_guests_on_host_boot', - default=False, - help='Whether to restart guests when the host reboots'), - cfg.BoolOpt('resume_guests_state_on_host_boot', - default=False, - help='Whether to start guests that were running before the ' - 'host rebooted'), cfg.StrOpt('default_ephemeral_format', default=None, help='The default format an ephemeral_volume will be ' @@ -275,22 +261,12 @@ global_opts = [ 'nova.compute.api:nova.notifier.api.notify_decorator' ], help='List of modules/decorators to monkey patch'), - cfg.BoolOpt('allow_resize_to_same_host', - default=False, - help='Allow destination machine to match source for resize. ' - 'Useful when testing in single-host environments.'), - cfg.IntOpt('reclaim_instance_interval', - default=0, - help='Interval in seconds for reclaiming deleted instances'), cfg.IntOpt('zombie_instance_updated_at_window', default=172800, help='Number of seconds zombie instances are cleaned up.'), cfg.IntOpt('service_down_time', default=60, help='maximum time since last check-in for up service'), - cfg.StrOpt('default_schedule_zone', - default=None, - help='availability zone to use when user doesn\'t specify one'), cfg.ListOpt('isolated_images', default=[], help='Images to run on isolated host'), @@ -315,25 +291,9 @@ global_opts = [ cfg.StrOpt('volume_api_class', default='nova.volume.cinder.API', help='The full class name of the volume API class to use'), - cfg.StrOpt('security_group_handler', - default='nova.network.sg.NullSecurityGroupHandler', - help='The full class name of the security group handler class'), - cfg.StrOpt('default_access_ip_network_name', - default=None, - help='Name of network to use to set access ips for instances'), cfg.StrOpt('auth_strategy', default='noauth', help='The strategy to use for auth: noauth or keystone.'), - cfg.ListOpt('non_inheritable_image_properties', - default=['cache_in_nova', - 'bittorrent'], - help='These are image properties which a snapshot should not' - ' inherit from an instance'), - 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('compute_driver', help='Driver to use for controlling virtualization. Options ' 'include: libvirt.LibvirtDriver, xenapi.XenAPIDriver, ' diff --git a/nova/tests/image/fake.py b/nova/tests/image/fake.py index 20da3a883..9070a69d8 100644 --- a/nova/tests/image/fake.py +++ b/nova/tests/image/fake.py @@ -29,7 +29,7 @@ from nova.openstack.common import log as logging CONF = cfg.CONF -CONF.import_opt('null_kernel', 'nova.config') +CONF.import_opt('null_kernel', 'nova.compute.api') LOG = logging.getLogger(__name__) diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 5b1de9b7e..3a8488cd2 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -39,7 +39,7 @@ from nova.tests.image import fake from nova.tests.integrated import integrated_helpers CONF = cfg.CONF -CONF.import_opt('allow_resize_to_same_host', 'nova.config') +CONF.import_opt('allow_resize_to_same_host', 'nova.compute.api') CONF.import_opt('osapi_compute_extension', 'nova.config') CONF.import_opt('vpn_image_id', 'nova.config') LOG = logging.getLogger(__name__) -- cgit