From 5dbdd6ed2bdcb6e52189e824b3526dde109be017 Mon Sep 17 00:00:00 2001 From: EdLeafe Date: Mon, 16 Nov 2015 11:08:22 -0600 Subject: [PATCH] Config options: centralize section "scheduler" This change moves all of the configuration options previously defined in nova/scheduler to the new centralized nova/conf/scheduler directory. A subsequent patch will then improve the help texts. Blueprint centralize-config-options Change-Id: I08d50e873f71601a26ce768feac635243d0570f4 --- nova/cmd/scheduler.py | 5 +- nova/conf/__init__.py | 2 + nova/conf/scheduler.py | 252 ++++++++++++++++++ nova/scheduler/driver.py | 11 +- nova/scheduler/filter_scheduler.py | 19 +- .../aggregate_image_properties_isolation.py | 13 +- nova/scheduler/filters/disk_filter.py | 8 +- nova/scheduler/filters/io_ops_filter.py | 12 +- .../filters/isolated_hosts_filter.py | 18 +- .../scheduler/filters/num_instances_filter.py | 9 +- nova/scheduler/filters/trusted_filter.py | 28 +- nova/scheduler/host_manager.py | 34 +-- nova/scheduler/ironic_host_manager.py | 26 +- nova/scheduler/manager.py | 17 +- nova/scheduler/opts.py | 50 +--- nova/scheduler/rpcapi.py | 15 +- nova/scheduler/scheduler_options.py | 10 +- nova/scheduler/utils.py | 13 +- nova/scheduler/weights/io_ops.py | 14 +- nova/scheduler/weights/metrics.py | 36 +-- nova/scheduler/weights/ram.py | 13 +- nova/tests/unit/conf_fixture.py | 1 - 22 files changed, 295 insertions(+), 311 deletions(-) create mode 100644 nova/conf/scheduler.py diff --git a/nova/cmd/scheduler.py b/nova/cmd/scheduler.py index fa166e1db56f..2de61871b5b8 100644 --- a/nova/cmd/scheduler.py +++ b/nova/cmd/scheduler.py @@ -18,16 +18,15 @@ import sys -from oslo_config import cfg from oslo_log import log as logging +import nova.conf from nova import config from nova import objects from nova import service from nova import utils -CONF = cfg.CONF -CONF.import_opt('scheduler_topic', 'nova.scheduler.rpcapi') +CONF = nova.conf.CONF def main(): diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index 33426f4aa20e..d134d0af6465 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -19,8 +19,10 @@ from oslo_config import cfg +from nova.conf import scheduler from nova.conf import serial_console CONF = cfg.CONF +scheduler.register_opts(CONF) serial_console.register_opts(CONF) diff --git a/nova/conf/scheduler.py b/nova/conf/scheduler.py new file mode 100644 index 000000000000..0f0db26785ed --- /dev/null +++ b/nova/conf/scheduler.py @@ -0,0 +1,252 @@ +# Copyright 2015 OpenStack Foundation +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import itertools + +from oslo_config import cfg + + +host_subset_size_opt = cfg.IntOpt("scheduler_host_subset_size", + default=1, + help="New instances will be scheduled on a host chosen randomly from " + "a subset of the N best hosts. This property defines the subset " + "size that a host is chosen from. A value of 1 chooses the first " + "host returned by the weighing functions. This value must be at " + "least 1. Any value less than 1 will be ignored, and 1 will be " + "used instead") + +bm_default_filter_opt = cfg.ListOpt("baremetal_scheduler_default_filters", + default=[ + "RetryFilter", + "AvailabilityZoneFilter", + "ComputeFilter", + "ComputeCapabilitiesFilter", + "ImagePropertiesFilter", + "ExactRamFilter", + "ExactDiskFilter", + "ExactCoreFilter", + ], + help="Which filter class names to use for filtering baremetal hosts " + "when not specified in the request.") + +use_bm_filters_opt = cfg.BoolOpt("scheduler_use_baremetal_filters", + default=False, + help="Flag to decide whether to use " + "baremetal_scheduler_default_filters or not.") + +host_mgr_avail_filt_opt = cfg.MultiStrOpt("scheduler_available_filters", + default=["nova.scheduler.filters.all_filters"], + help="Filter classes available to the scheduler which may be " + "specified more than once. An entry of " + "'nova.scheduler.filters.all_filters' maps to all filters " + "included with nova.") + +host_mgr_default_filt_opt = cfg.ListOpt("scheduler_default_filters", + default=[ + "RetryFilter", + "AvailabilityZoneFilter", + "RamFilter", + "DiskFilter", + "ComputeFilter", + "ComputeCapabilitiesFilter", + "ImagePropertiesFilter", + "ServerGroupAntiAffinityFilter", + "ServerGroupAffinityFilter", + ], + help="Which filter class names to use for filtering hosts when not " + "specified in the request.") + +host_mgr_sched_wgt_cls_opt = cfg.ListOpt("scheduler_weight_classes", + default=["nova.scheduler.weights.all_weighers"], + help="Which weight class names to use for weighing hosts") + +host_mgr_tracks_inst_chg_opt = cfg.BoolOpt("scheduler_tracks_instance_changes", + default=True, + help="Determines if the Scheduler tracks changes to instances to help " + "with its filtering decisions.") + +rpc_sched_topic_opt = cfg.StrOpt("scheduler_topic", + default="scheduler", + help="The topic scheduler nodes listen on") + +# This option specifies an option group, so register separately +rpcapi_cap_opt = cfg.StrOpt("scheduler", + help="Set a version cap for messages sent to scheduler services") + +scheduler_json_config_location_opt = cfg.StrOpt( + "scheduler_json_config_location", + default="", + help="Absolute path to scheduler configuration JSON file.") + +sched_driver_host_mgr_opt = cfg.StrOpt("scheduler_host_manager", + default="nova.scheduler.host_manager.HostManager", + help="The scheduler host manager class to use") + +driver_opt = cfg.StrOpt("scheduler_driver", + default="nova.scheduler.filter_scheduler.FilterScheduler", + help="Default driver to use for the scheduler") + +driver_period_opt = cfg.IntOpt("scheduler_driver_task_period", + default=60, + help="How often (in seconds) to run periodic tasks in the scheduler " + "driver of your choice. Please note this is likely to interact " + "with the value of service_down_time, but exactly how they " + "interact will depend on your choice of scheduler driver.") + +disk_allocation_ratio_opt = cfg.FloatOpt("disk_allocation_ratio", + default=1.0, + help="Virtual disk to physical disk allocation ratio") + +isolated_img_opt = cfg.ListOpt("isolated_images", + default=[], + help="Images to run on isolated host") + +isolated_host_opt = cfg.ListOpt("isolated_hosts", + default=[], + help="Host reserved for specific images") + +restrict_iso_host_img_opt = cfg.BoolOpt( + "restrict_isolated_hosts_to_isolated_images", + default=True, + help="Whether to force isolated hosts to run only isolated images") + +# These opts are registered as a separate OptGroup +trusted_opts = [ + cfg.StrOpt("attestation_server", + help="Attestation server HTTP"), + cfg.StrOpt("attestation_server_ca_file", + help="Attestation server Cert file for Identity verification"), + cfg.StrOpt("attestation_port", + default="8443", + help="Attestation server port"), + cfg.StrOpt("attestation_api_url", + default="/OpenAttestationWebServices/V1.0", + help="Attestation web API URL"), + cfg.StrOpt("attestation_auth_blob", + help="Attestation authorization blob - must change"), + cfg.IntOpt("attestation_auth_timeout", + default=60, + help="Attestation status cache valid period length"), + cfg.BoolOpt("attestation_insecure_ssl", + default=False, + help="Disable SSL cert verification for Attestation service") +] + +max_io_ops_per_host_opt = cfg.IntOpt("max_io_ops_per_host", + default=8, + help="Tells filters to ignore hosts that have this many or more " + "instances currently in build, resize, snapshot, migrate, rescue " + "or unshelve task states") + +agg_img_prop_iso_namespace_opt = cfg.StrOpt( + "aggregate_image_properties_isolation_namespace", + help="Force the filter to consider only keys matching the given " + "namespace.") + +agg_img_prop_iso_separator_opt = cfg.StrOpt( + "aggregate_image_properties_isolation_separator", + default=".", + help="The separator used between the namespace and keys") + +max_instances_per_host_opt = cfg.IntOpt("max_instances_per_host", + default=50, + help="Ignore hosts that have too many instances") + +ram_weight_mult_opt = cfg.FloatOpt("ram_weight_multiplier", + default=1.0, + help="Multiplier used for weighing ram. Negative numbers mean to " + "stack vs spread.") + +io_ops_weight_mult_opt = cfg.FloatOpt("io_ops_weight_multiplier", + default=-1.0, + help="Multiplier used for weighing host io ops. Negative numbers mean " + "a preference to choose light workload compute hosts.") + +# These opts are registered as a separate OptGroup +metrics_weight_opts = [ + cfg.FloatOpt("weight_multiplier", + default=1.0, + help="Multiplier used for weighing metrics."), + cfg.ListOpt("weight_setting", + default=[], + help="How the metrics are going to be weighed. This should be in " + "the form of '=, =, ...', " + "where is one of the metrics to be weighed, and " + " is the corresponding ratio. So for " + "'name1=1.0, name2=-1.0' The final weight would be " + "name1.value * 1.0 + name2.value * -1.0."), + cfg.BoolOpt("required", + default=True, + help="How to treat the unavailable metrics. When a metric is NOT " + "available for a host, if it is set to be True, it would " + "raise an exception, so it is recommended to use the " + "scheduler filter MetricFilter to filter out those hosts. If " + "it is set to be False, the unavailable metric would be " + "treated as a negative factor in weighing process, the " + "returned value would be set by the option " + "weight_of_unavailable."), + cfg.FloatOpt("weight_of_unavailable", + default=float(-10000.0), + help="The final weight value to be returned if required is set to " + "False and any one of the metrics set by weight_setting is " + "unavailable."), +] + +scheduler_max_att_opt = cfg.IntOpt("scheduler_max_attempts", + default=3, + help="Maximum number of attempts to schedule an instance") + + +SIMPLE_OPTS = [host_subset_size_opt, + bm_default_filter_opt, + use_bm_filters_opt, + host_mgr_avail_filt_opt, + host_mgr_default_filt_opt, + host_mgr_sched_wgt_cls_opt, + host_mgr_tracks_inst_chg_opt, + rpc_sched_topic_opt, + sched_driver_host_mgr_opt, + driver_opt, + driver_period_opt, + scheduler_json_config_location_opt, + disk_allocation_ratio_opt, + isolated_img_opt, + isolated_host_opt, + restrict_iso_host_img_opt, + max_io_ops_per_host_opt, + agg_img_prop_iso_namespace_opt, + agg_img_prop_iso_separator_opt, + max_instances_per_host_opt, + ram_weight_mult_opt, + io_ops_weight_mult_opt, + scheduler_max_att_opt, + ] + +ALL_OPTS = itertools.chain( + SIMPLE_OPTS, + [rpcapi_cap_opt], + trusted_opts, + metrics_weight_opts, + ) + + +def register_opts(conf): + conf.register_opts(SIMPLE_OPTS) + conf.register_opt(rpcapi_cap_opt, "upgrade_levels") + trust_group = cfg.OptGroup(name="trusted_computing", + title="Trust parameters") + conf.register_group(trust_group) + conf.register_opts(trusted_opts, group=trust_group) + conf.register_opts(metrics_weight_opts, group="metrics") diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index fd313e1b055e..12e078da9e17 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -21,21 +21,14 @@ Scheduler base class that all Schedulers should inherit from import abc -from oslo_config import cfg from oslo_utils import importutils import six +import nova.conf from nova import objects from nova import servicegroup -scheduler_driver_opts = [ - cfg.StrOpt('scheduler_host_manager', - default='nova.scheduler.host_manager.HostManager', - help='The scheduler host manager class to use'), - ] - -CONF = cfg.CONF -CONF.register_opts(scheduler_driver_opts) +CONF = nova.conf.CONF @six.add_metaclass(abc.ABCMeta) diff --git a/nova/scheduler/filter_scheduler.py b/nova/scheduler/filter_scheduler.py index 9e470cd49bb9..0408fa49776a 100644 --- a/nova/scheduler/filter_scheduler.py +++ b/nova/scheduler/filter_scheduler.py @@ -21,10 +21,10 @@ Weighing Functions. import random -from oslo_config import cfg from oslo_log import log as logging from six.moves import range +import nova.conf from nova import exception from nova.i18n import _ from nova import objects @@ -33,25 +33,10 @@ from nova.scheduler import driver from nova.scheduler import scheduler_options -CONF = cfg.CONF +CONF = nova.conf.CONF LOG = logging.getLogger(__name__) -filter_scheduler_opts = [ - cfg.IntOpt('scheduler_host_subset_size', - default=1, - help='New instances will be scheduled on a host chosen ' - 'randomly from a subset of the N best hosts. This ' - 'property defines the subset size that a host is ' - 'chosen from. A value of 1 chooses the ' - 'first host returned by the weighing functions. ' - 'This value must be at least 1. Any value less than 1 ' - 'will be ignored, and 1 will be used instead') -] - -CONF.register_opts(filter_scheduler_opts) - - class FilterScheduler(driver.Scheduler): """Scheduler that can be used for filtering and weighing.""" def __init__(self, *args, **kwargs): diff --git a/nova/scheduler/filters/aggregate_image_properties_isolation.py b/nova/scheduler/filters/aggregate_image_properties_isolation.py index af13d268f854..bf83c6b50290 100644 --- a/nova/scheduler/filters/aggregate_image_properties_isolation.py +++ b/nova/scheduler/filters/aggregate_image_properties_isolation.py @@ -13,23 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_log import log as logging import six +import nova.conf from nova.scheduler import filters from nova.scheduler.filters import utils -opts = [ - cfg.StrOpt('aggregate_image_properties_isolation_namespace', - help='Force the filter to consider only keys matching ' - 'the given namespace.'), - cfg.StrOpt('aggregate_image_properties_isolation_separator', - default=".", - help='The separator used between the namespace and keys'), -] -CONF = cfg.CONF -CONF.register_opts(opts) +CONF = nova.conf.CONF LOG = logging.getLogger(__name__) diff --git a/nova/scheduler/filters/disk_filter.py b/nova/scheduler/filters/disk_filter.py index e623616733a0..e55ba00319d6 100644 --- a/nova/scheduler/filters/disk_filter.py +++ b/nova/scheduler/filters/disk_filter.py @@ -13,20 +13,16 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_log import log as logging +import nova.conf from nova.i18n import _LW from nova.scheduler import filters from nova.scheduler.filters import utils LOG = logging.getLogger(__name__) -disk_allocation_ratio_opt = cfg.FloatOpt("disk_allocation_ratio", default=1.0, - help="Virtual disk to physical disk allocation ratio") - -CONF = cfg.CONF -CONF.register_opt(disk_allocation_ratio_opt) +CONF = nova.conf.CONF class DiskFilter(filters.BaseHostFilter): diff --git a/nova/scheduler/filters/io_ops_filter.py b/nova/scheduler/filters/io_ops_filter.py index 5fca44c42fbb..00e832e4a356 100644 --- a/nova/scheduler/filters/io_ops_filter.py +++ b/nova/scheduler/filters/io_ops_filter.py @@ -13,24 +13,16 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_log import log as logging +import nova.conf from nova.i18n import _LW from nova.scheduler import filters from nova.scheduler.filters import utils LOG = logging.getLogger(__name__) -max_io_ops_per_host_opt = cfg.IntOpt("max_io_ops_per_host", - default=8, - help="Tells filters to ignore hosts that have " - "this many or more instances currently in " - "build, resize, snapshot, migrate, rescue or unshelve " - "task states") - -CONF = cfg.CONF -CONF.register_opt(max_io_ops_per_host_opt) +CONF = nova.conf.CONF class IoOpsFilter(filters.BaseHostFilter): diff --git a/nova/scheduler/filters/isolated_hosts_filter.py b/nova/scheduler/filters/isolated_hosts_filter.py index 5b93634f70b2..cb2781ea4b03 100644 --- a/nova/scheduler/filters/isolated_hosts_filter.py +++ b/nova/scheduler/filters/isolated_hosts_filter.py @@ -13,24 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg - +import nova.conf from nova.scheduler import filters -isolated_opts = [ - cfg.ListOpt('isolated_images', - default=[], - help='Images to run on isolated host'), - cfg.ListOpt('isolated_hosts', - default=[], - help='Host reserved for specific images'), - cfg.BoolOpt('restrict_isolated_hosts_to_isolated_images', - default=True, - help='Whether to force isolated hosts to run only isolated ' - 'images'), -] -CONF = cfg.CONF -CONF.register_opts(isolated_opts) +CONF = nova.conf.CONF class IsolatedHostsFilter(filters.BaseHostFilter): diff --git a/nova/scheduler/filters/num_instances_filter.py b/nova/scheduler/filters/num_instances_filter.py index aa9856e585be..298bff1b8e95 100644 --- a/nova/scheduler/filters/num_instances_filter.py +++ b/nova/scheduler/filters/num_instances_filter.py @@ -13,21 +13,16 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_log import log as logging +import nova.conf from nova.i18n import _LW from nova.scheduler import filters from nova.scheduler.filters import utils LOG = logging.getLogger(__name__) -max_instances_per_host_opt = cfg.IntOpt("max_instances_per_host", - default=50, - help="Ignore hosts that have too many instances") - -CONF = cfg.CONF -CONF.register_opt(max_instances_per_host_opt) +CONF = nova.conf.CONF class NumInstancesFilter(filters.BaseHostFilter): diff --git a/nova/scheduler/filters/trusted_filter.py b/nova/scheduler/filters/trusted_filter.py index b9acad6da59f..251ffcead117 100644 --- a/nova/scheduler/filters/trusted_filter.py +++ b/nova/scheduler/filters/trusted_filter.py @@ -43,12 +43,12 @@ the Open Attestation project at: https://github.com/OpenAttestation/OpenAttestation """ -from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils from oslo_utils import timeutils import requests +import nova.conf from nova import context from nova.i18n import _LW from nova import objects @@ -56,31 +56,7 @@ from nova.scheduler import filters LOG = logging.getLogger(__name__) -trusted_opts = [ - cfg.StrOpt('attestation_server', - help='Attestation server HTTP'), - cfg.StrOpt('attestation_server_ca_file', - help='Attestation server Cert file for Identity verification'), - cfg.StrOpt('attestation_port', - default='8443', - help='Attestation server port'), - cfg.StrOpt('attestation_api_url', - default='/OpenAttestationWebServices/V1.0', - help='Attestation web API URL'), - cfg.StrOpt('attestation_auth_blob', - help='Attestation authorization blob - must change'), - cfg.IntOpt('attestation_auth_timeout', - default=60, - help='Attestation status cache valid period length'), - cfg.BoolOpt('attestation_insecure_ssl', - default=False, - help='Disable SSL cert verification for Attestation service') -] - -CONF = cfg.CONF -trust_group = cfg.OptGroup(name='trusted_computing', title='Trust parameters') -CONF.register_group(trust_group) -CONF.register_opts(trusted_opts, group=trust_group) +CONF = nova.conf.CONF class AttestationService(object): diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py index 7c8d31818a4f..b383672cff97 100644 --- a/nova/scheduler/host_manager.py +++ b/nova/scheduler/host_manager.py @@ -27,11 +27,11 @@ except ImportError: import iso8601 -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import timeutils import six +import nova.conf from nova import context as context_module from nova import exception from nova.i18n import _LI, _LW @@ -42,38 +42,8 @@ from nova.scheduler import weights from nova import utils from nova.virt import hardware -host_manager_opts = [ - cfg.MultiStrOpt('scheduler_available_filters', - default=['nova.scheduler.filters.all_filters'], - help='Filter classes available to the scheduler which may ' - 'be specified more than once. An entry of ' - '"nova.scheduler.filters.all_filters" ' - 'maps to all filters included with nova.'), - cfg.ListOpt('scheduler_default_filters', - default=[ - 'RetryFilter', - 'AvailabilityZoneFilter', - 'RamFilter', - 'DiskFilter', - 'ComputeFilter', - 'ComputeCapabilitiesFilter', - 'ImagePropertiesFilter', - 'ServerGroupAntiAffinityFilter', - 'ServerGroupAffinityFilter', - ], - help='Which filter class names to use for filtering hosts ' - 'when not specified in the request.'), - cfg.ListOpt('scheduler_weight_classes', - default=['nova.scheduler.weights.all_weighers'], - help='Which weight class names to use for weighing hosts'), - cfg.BoolOpt('scheduler_tracks_instance_changes', - default=True, - help='Determines if the Scheduler tracks changes to instances ' - 'to help with its filtering decisions.'), -] -CONF = cfg.CONF -CONF.register_opts(host_manager_opts) +CONF = nova.conf.CONF LOG = logging.getLogger(__name__) HOST_INSTANCE_SEMAPHORE = "host_instance" diff --git a/nova/scheduler/ironic_host_manager.py b/nova/scheduler/ironic_host_manager.py index 4e6c08713d6b..1b881372ae11 100644 --- a/nova/scheduler/ironic_host_manager.py +++ b/nova/scheduler/ironic_host_manager.py @@ -21,35 +21,13 @@ This host manager will consume all cpu's, disk space, and ram from a host / node as it is supporting Baremetal hosts, which can not be subdivided into multiple instances. """ -from oslo_config import cfg from oslo_log import log as logging from nova.compute import hv_type +import nova.conf from nova.scheduler import host_manager -host_manager_opts = [ - cfg.ListOpt('baremetal_scheduler_default_filters', - default=[ - 'RetryFilter', - 'AvailabilityZoneFilter', - 'ComputeFilter', - 'ComputeCapabilitiesFilter', - 'ImagePropertiesFilter', - 'ExactRamFilter', - 'ExactDiskFilter', - 'ExactCoreFilter', - ], - help='Which filter class names to use for filtering ' - 'baremetal hosts when not specified in the request.'), - cfg.BoolOpt('scheduler_use_baremetal_filters', - default=False, - help='Flag to decide whether to use ' - 'baremetal_scheduler_default_filters or not.'), - - ] - -CONF = cfg.CONF -CONF.register_opts(host_manager_opts) +CONF = nova.conf.CONF LOG = logging.getLogger(__name__) diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index c29ed5e92bb9..68807b25c3ab 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -19,13 +19,13 @@ Scheduler Service """ -from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging from oslo_serialization import jsonutils from oslo_service import periodic_task from oslo_utils import importutils +import nova.conf from nova import exception from nova import manager from nova import quota @@ -33,20 +33,7 @@ from nova import quota LOG = logging.getLogger(__name__) -scheduler_driver_opts = [ - cfg.StrOpt('scheduler_driver', - default='nova.scheduler.filter_scheduler.FilterScheduler', - help='Default driver to use for the scheduler'), - cfg.IntOpt('scheduler_driver_task_period', - default=60, - help='How often (in seconds) to run periodic tasks in ' - 'the scheduler driver of your choice. ' - 'Please note this is likely to interact with the value ' - 'of service_down_time, but exactly how they interact ' - 'will depend on your choice of scheduler driver.'), -] -CONF = cfg.CONF -CONF.register_opts(scheduler_driver_opts) +CONF = nova.conf.CONF QUOTAS = quota.QUOTAS diff --git a/nova/scheduler/opts.py b/nova/scheduler/opts.py index b633cadb5198..3ca4c62358de 100644 --- a/nova/scheduler/opts.py +++ b/nova/scheduler/opts.py @@ -10,56 +10,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -import itertools - -import nova.scheduler.driver -import nova.scheduler.filter_scheduler -import nova.scheduler.filters.aggregate_image_properties_isolation -import nova.scheduler.filters.core_filter -import nova.scheduler.filters.disk_filter -import nova.scheduler.filters.io_ops_filter -import nova.scheduler.filters.isolated_hosts_filter -import nova.scheduler.filters.num_instances_filter -import nova.scheduler.filters.ram_filter -import nova.scheduler.filters.trusted_filter -import nova.scheduler.host_manager -import nova.scheduler.ironic_host_manager -import nova.scheduler.manager -import nova.scheduler.rpcapi -import nova.scheduler.scheduler_options -import nova.scheduler.utils -import nova.scheduler.weights.io_ops -import nova.scheduler.weights.metrics -import nova.scheduler.weights.ram +import nova.conf.scheduler def list_opts(): return [ ('DEFAULT', - itertools.chain( - [nova.scheduler.filters.disk_filter.disk_allocation_ratio_opt], - [nova.scheduler.filters.io_ops_filter.max_io_ops_per_host_opt], - [nova.scheduler.filters.num_instances_filter. - max_instances_per_host_opt], - [nova.scheduler.scheduler_options. - scheduler_json_config_location_opt], - nova.scheduler.driver.scheduler_driver_opts, - nova.scheduler.filter_scheduler.filter_scheduler_opts, - nova.scheduler.filters.aggregate_image_properties_isolation.opts, - nova.scheduler.filters.isolated_hosts_filter.isolated_opts, - nova.scheduler.host_manager.host_manager_opts, - nova.scheduler.ironic_host_manager.host_manager_opts, - nova.scheduler.manager.scheduler_driver_opts, - nova.scheduler.rpcapi.rpcapi_opts, - nova.scheduler.utils.scheduler_opts, - nova.scheduler.weights.io_ops.io_ops_weight_opts, - nova.scheduler.weights.ram.ram_weight_opts, - )), - ('metrics', nova.scheduler.weights.metrics.metrics_weight_opts), + nova.conf.scheduler.SIMPLE_OPTS), + ('metrics', nova.conf.scheduler.metrics_weight_opts), ('trusted_computing', - nova.scheduler.filters.trusted_filter.trusted_opts), + nova.conf.scheduler.trusted_opts), ('upgrade_levels', - itertools.chain( - [nova.scheduler.rpcapi.rpcapi_cap_opt], - )), + [nova.conf.scheduler.rpcapi_cap_opt]), ] diff --git a/nova/scheduler/rpcapi.py b/nova/scheduler/rpcapi.py index fb8ab1945972..0f4e5d99da1e 100644 --- a/nova/scheduler/rpcapi.py +++ b/nova/scheduler/rpcapi.py @@ -16,24 +16,13 @@ Client side of the scheduler manager RPC API. """ -from oslo_config import cfg import oslo_messaging as messaging +import nova.conf from nova.objects import base as objects_base from nova import rpc -rpcapi_opts = [ - cfg.StrOpt('scheduler_topic', - default='scheduler', - help='The topic scheduler nodes listen on'), -] - -CONF = cfg.CONF -CONF.register_opts(rpcapi_opts) - -rpcapi_cap_opt = cfg.StrOpt('scheduler', - help='Set a version cap for messages sent to scheduler services') -CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels') +CONF = nova.conf.CONF class SchedulerAPI(object): diff --git a/nova/scheduler/scheduler_options.py b/nova/scheduler/scheduler_options.py index 67222b15826b..a2ce218ea9f6 100644 --- a/nova/scheduler/scheduler_options.py +++ b/nova/scheduler/scheduler_options.py @@ -23,22 +23,16 @@ dynamic configuration. import datetime import os -from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils from oslo_utils import excutils from oslo_utils import timeutils +import nova.conf from nova.i18n import _LE -scheduler_json_config_location_opt = cfg.StrOpt( - 'scheduler_json_config_location', - default='', - help='Absolute path to scheduler configuration JSON file.') - -CONF = cfg.CONF -CONF.register_opt(scheduler_json_config_location_opt) +CONF = nova.conf.CONF LOG = logging.getLogger(__name__) diff --git a/nova/scheduler/utils.py b/nova/scheduler/utils.py index eb9402c7090a..c91cdb8a3ad8 100644 --- a/nova/scheduler/utils.py +++ b/nova/scheduler/utils.py @@ -18,13 +18,13 @@ import collections import functools import sys -from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging from oslo_serialization import jsonutils from nova.compute import flavors from nova.compute import utils as compute_utils +import nova.conf from nova import exception from nova.i18n import _, _LE, _LW from nova import objects @@ -35,16 +35,7 @@ from nova import rpc LOG = logging.getLogger(__name__) -scheduler_opts = [ - cfg.IntOpt('scheduler_max_attempts', - default=3, - help='Maximum number of attempts to schedule an instance'), - ] - -CONF = cfg.CONF -CONF.register_opts(scheduler_opts) - -CONF.import_opt('scheduler_default_filters', 'nova.scheduler.host_manager') +CONF = nova.conf.CONF GroupDetails = collections.namedtuple('GroupDetails', ['hosts', 'policies']) diff --git a/nova/scheduler/weights/io_ops.py b/nova/scheduler/weights/io_ops.py index 40b36b613009..2a27e1c5797c 100644 --- a/nova/scheduler/weights/io_ops.py +++ b/nova/scheduler/weights/io_ops.py @@ -21,20 +21,10 @@ option to a positive number and the weighing has the opposite effect of the default. """ -from oslo_config import cfg - +import nova.conf from nova.scheduler import weights -io_ops_weight_opts = [ - cfg.FloatOpt('io_ops_weight_multiplier', - default=-1.0, - help='Multiplier used for weighing host io ops. Negative ' - 'numbers mean a preference to choose light workload ' - 'compute hosts.'), -] - -CONF = cfg.CONF -CONF.register_opts(io_ops_weight_opts) +CONF = nova.conf.CONF class IoOpsWeigher(weights.BaseHostWeigher): diff --git a/nova/scheduler/weights/metrics.py b/nova/scheduler/weights/metrics.py index ca5355129614..43305c1b82fc 100644 --- a/nova/scheduler/weights/metrics.py +++ b/nova/scheduler/weights/metrics.py @@ -26,45 +26,13 @@ in the configuration file as the followings: The final weight would be name1.value * 1.0 + name2.value * -1.0. """ -from oslo_config import cfg - +import nova.conf from nova import exception from nova.scheduler import utils from nova.scheduler import weights -metrics_weight_opts = [ - cfg.FloatOpt('weight_multiplier', - default=1.0, - help='Multiplier used for weighing metrics.'), - cfg.ListOpt('weight_setting', - default=[], - help='How the metrics are going to be weighed. This ' - 'should be in the form of "=, ' - '=, ...", where is one ' - 'of the metrics to be weighed, and is ' - 'the corresponding ratio. So for "name1=1.0, ' - 'name2=-1.0" The final weight would be ' - 'name1.value * 1.0 + name2.value * -1.0.'), - cfg.BoolOpt('required', - default=True, - help='How to treat the unavailable metrics. When a ' - 'metric is NOT available for a host, if it is set ' - 'to be True, it would raise an exception, so it ' - 'is recommended to use the scheduler filter ' - 'MetricFilter to filter out those hosts. If it is ' - 'set to be False, the unavailable metric would be ' - 'treated as a negative factor in weighing ' - 'process, the returned value would be set by ' - 'the option weight_of_unavailable.'), - cfg.FloatOpt('weight_of_unavailable', - default=float(-10000.0), - help='The final weight value to be returned if ' - 'required is set to False and any one of the ' - 'metrics set by weight_setting is unavailable.'), -] -CONF = cfg.CONF -CONF.register_opts(metrics_weight_opts, group='metrics') +CONF = nova.conf.CONF class MetricsWeigher(weights.BaseHostWeigher): diff --git a/nova/scheduler/weights/ram.py b/nova/scheduler/weights/ram.py index 740a3d2843c5..c46ec8458e5c 100644 --- a/nova/scheduler/weights/ram.py +++ b/nova/scheduler/weights/ram.py @@ -20,19 +20,10 @@ stacking, you can set the 'ram_weight_multiplier' option to a negative number and the weighing has the opposite effect of the default. """ -from oslo_config import cfg - +import nova.conf from nova.scheduler import weights -ram_weight_opts = [ - cfg.FloatOpt('ram_weight_multiplier', - default=1.0, - help='Multiplier used for weighing ram. Negative ' - 'numbers mean to stack vs spread.'), -] - -CONF = cfg.CONF -CONF.register_opts(ram_weight_opts) +CONF = nova.conf.CONF class RAMWeigher(weights.BaseHostWeigher): diff --git a/nova/tests/unit/conf_fixture.py b/nova/tests/unit/conf_fixture.py index 3cbd828da3fc..c7f37b9b8615 100644 --- a/nova/tests/unit/conf_fixture.py +++ b/nova/tests/unit/conf_fixture.py @@ -25,7 +25,6 @@ from nova.tests.unit import utils CONF = cfg.CONF CONF.import_opt('use_ipv6', 'nova.netconf') CONF.import_opt('host', 'nova.netconf') -CONF.import_opt('scheduler_driver', 'nova.scheduler.manager') CONF.import_opt('fake_network', 'nova.network.linux_net') CONF.import_opt('network_size', 'nova.network.manager') CONF.import_opt('num_networks', 'nova.network.manager')