diff options
author | Esra Celik <celik.esra@tubitak.gov.tr> | 2015-12-23 10:45:16 +0200 |
---|---|---|
committer | Esra Celik <celik.esra@tubitak.gov.tr> | 2016-01-27 16:10:42 +0200 |
commit | 2c10aefb621b09fe172aa37b2407afb994f3a248 (patch) | |
tree | 74ee0e03c2239c0a55ae3ec4808ee495da2e5f38 | |
parent | 70775d1783a6040bfbc58105d5f7297622fcfd31 (diff) | |
download | nova-2c10aefb621b09fe172aa37b2407afb994f3a248.tar.gz |
Config options: centralize section "cells"
This change moves all of the configuration options previously defined
in nova/cells to the new centralized nova/conf directory.
A subsequent patch will then improve the help texts.
Blueprint centralize-config-options
Change-Id: I7113fce099a1593ddc6c5da3e912a8ffa68b0925
-rw-r--r-- | nova/cells/manager.py | 21 | ||||
-rw-r--r-- | nova/cells/messaging.py | 16 | ||||
-rw-r--r-- | nova/cells/opts.py | 82 | ||||
-rw-r--r-- | nova/cells/rpc_driver.py | 18 | ||||
-rw-r--r-- | nova/cells/rpcapi.py | 9 | ||||
-rw-r--r-- | nova/cells/scheduler.py | 25 | ||||
-rw-r--r-- | nova/cells/state.py | 18 | ||||
-rw-r--r-- | nova/cells/utils.py | 6 | ||||
-rw-r--r-- | nova/cells/weights/mute_child.py | 13 | ||||
-rw-r--r-- | nova/cells/weights/ram_by_instance_type.py | 11 | ||||
-rw-r--r-- | nova/cells/weights/weight_offset.py | 11 | ||||
-rw-r--r-- | nova/conf/__init__.py | 4 | ||||
-rw-r--r-- | nova/conf/cells.py | 178 |
13 files changed, 205 insertions, 207 deletions
diff --git a/nova/cells/manager.py b/nova/cells/manager.py index a257e1c5b2..d335e549b5 100644 --- a/nova/cells/manager.py +++ b/nova/cells/manager.py @@ -19,7 +19,6 @@ Cells Service Manager import datetime import time -from oslo_config import cfg from oslo_log import log as logging import oslo_messaging from oslo_service import periodic_task @@ -31,6 +30,7 @@ from six.moves import range from nova.cells import messaging from nova.cells import state as cells_state from nova.cells import utils as cells_utils +import nova.conf from nova import context from nova import exception from nova.i18n import _LW @@ -39,23 +39,8 @@ from nova import objects from nova.objects import base as base_obj from nova.objects import instance as instance_obj -cell_manager_opts = [ - cfg.StrOpt('driver', - default='nova.cells.rpc_driver.CellsRPCDriver', - help='Cells communication driver to use'), - cfg.IntOpt("instance_updated_at_threshold", - default=3600, - help="Number of seconds after an instance was updated " - "or deleted to continue to update cells"), - cfg.IntOpt("instance_update_num_instances", - default=1, - help="Number of instances to update per periodic task run") -] - - -CONF = cfg.CONF -CONF.import_opt('name', 'nova.cells.opts', group='cells') -CONF.register_opts(cell_manager_opts, group='cells') + +CONF = nova.conf.CONF LOG = logging.getLogger(__name__) diff --git a/nova/cells/messaging.py b/nova/cells/messaging.py index 056454b25e..949e9401a7 100644 --- a/nova/cells/messaging.py +++ b/nova/cells/messaging.py @@ -31,7 +31,6 @@ import sys import traceback from eventlet import queue -from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging from oslo_serialization import jsonutils @@ -48,6 +47,7 @@ from nova import compute from nova.compute import rpcapi as compute_rpcapi from nova.compute import task_states from nova.compute import vm_states +import nova.conf from nova.consoleauth import rpcapi as consoleauth_rpcapi from nova import context from nova.db import base @@ -58,19 +58,7 @@ from nova.objects import base as objects_base from nova import rpc from nova import utils - -cell_messaging_opts = [ - cfg.IntOpt('max_hop_count', - default=10, - help='Maximum number of hops for cells routing.'), - cfg.StrOpt('scheduler', - default='nova.cells.scheduler.CellsScheduler', - help='Cells scheduler to use')] - -CONF = cfg.CONF -CONF.import_opt('name', 'nova.cells.opts', group='cells') -CONF.import_opt('call_timeout', 'nova.cells.opts', group='cells') -CONF.register_opts(cell_messaging_opts, group='cells') +CONF = nova.conf.CONF LOG = logging.getLogger(__name__) diff --git a/nova/cells/opts.py b/nova/cells/opts.py index 3a0ace4fb3..027524e8c8 100644 --- a/nova/cells/opts.py +++ b/nova/cells/opts.py @@ -15,57 +15,9 @@ """ Global cells config options """ +import nova.conf -import itertools - -from oslo_config import cfg -from oslo_utils import importutils - - -cells_opts = [ - cfg.BoolOpt('enable', - default=False, - help='Enable cell functionality'), - cfg.StrOpt('topic', - default='cells', - help='The topic cells nodes listen on'), - cfg.StrOpt('manager', - default='nova.cells.manager.CellsManager', - help='Manager for cells'), - cfg.StrOpt('name', - default='nova', - help='Name of this cell'), - cfg.ListOpt('capabilities', - default=['hypervisor=xenserver;kvm', 'os=linux;windows'], - help='Key/Multi-value list with the capabilities of the cell'), - cfg.IntOpt('call_timeout', - default=60, - help='Seconds to wait for response from a call to a cell.'), - cfg.FloatOpt('reserve_percent', - default=10.0, - help='Percentage of cell capacity to hold in reserve. ' - 'Affects both memory and disk utilization'), - cfg.StrOpt('cell_type', - default='compute', - choices=('api', 'compute'), - help='Type of cell'), - cfg.IntOpt("mute_child_interval", - default=300, - help='Number of seconds after which a lack of capability and ' - 'capacity updates signals the child cell is to be ' - 'treated as a mute.'), - cfg.IntOpt('bandwidth_update_interval', - default=600, - help='Seconds between bandwidth updates for cells.'), - cfg.IntOpt('instance_update_sync_database_limit', - default=100, - help='Number of instances to pull from the database at one ' - 'time for a sync. If there are more instances to update ' - 'the results will be paged through'), -] - -CONF = cfg.CONF -CONF.register_opts(cells_opts, group='cells') +CONF = nova.conf.CONF def get_cell_type(): @@ -77,32 +29,4 @@ def get_cell_type(): def list_opts(): - return [ - ('cells', - itertools.chain( - cells_opts, - importutils.import_module( - "nova.cells.manager").cell_manager_opts, - importutils.import_module( - "nova.cells.messaging").cell_messaging_opts, - importutils.import_module( - "nova.cells.rpc_driver").cell_rpc_driver_opts, - importutils.import_module( - "nova.cells.scheduler").cell_scheduler_opts, - importutils.import_module( - "nova.cells.state").cell_state_manager_opts, - importutils.import_module( - "nova.cells.weights.mute_child").mute_weigher_opts, - importutils.import_module( - "nova.cells.weights.ram_by_instance_type").ram_weigher_opts, - importutils.import_module( - "nova.cells.weights.weight_offset").weigher_opts - )), - ('upgrade_levels', - itertools.chain( - [importutils.import_module( - "nova.cells.rpc_driver").rpcapi_cap_opt], - [importutils.import_module( - "nova.cells.rpcapi").rpcapi_cap_opt], - )), - ] + return [] diff --git a/nova/cells/rpc_driver.py b/nova/cells/rpc_driver.py index 62209a30fb..898f135ca9 100644 --- a/nova/cells/rpc_driver.py +++ b/nova/cells/rpc_driver.py @@ -17,26 +17,14 @@ """ Cells RPC Communication Driver """ -from oslo_config import cfg import oslo_messaging as messaging from nova.cells import driver +import nova.conf from nova import rpc -cell_rpc_driver_opts = [ - cfg.StrOpt('rpc_driver_queue_base', - default='cells.intercell', - help="Base queue name to use when communicating between " - "cells. Various topics by message type will be " - "appended to this.")] -CONF = cfg.CONF -CONF.register_opts(cell_rpc_driver_opts, group='cells') -CONF.import_opt('call_timeout', 'nova.cells.opts', group='cells') - -rpcapi_cap_opt = cfg.StrOpt('intercell', - help='Set a version cap for messages sent between cells services') -CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels') +CONF = nova.conf.CONF class CellsRPCDriver(driver.BaseCellsDriver): @@ -133,7 +121,7 @@ class InterCellRPCAPI(object): """ transport_url = next_hop.db_info['transport_url'] if transport_url not in self.transports: - transport = messaging.get_transport(cfg.CONF, transport_url, + transport = messaging.get_transport(nova.conf.CONF, transport_url, rpc.TRANSPORT_ALIASES) self.transports[transport_url] = transport else: diff --git a/nova/cells/rpcapi.py b/nova/cells/rpcapi.py index ae27aacc93..d6d64df3ca 100644 --- a/nova/cells/rpcapi.py +++ b/nova/cells/rpcapi.py @@ -23,11 +23,11 @@ services. That communication is handled by the cells driver via the messaging module. """ -from oslo_config import cfg from oslo_log import log as logging import oslo_messaging as messaging from oslo_serialization import jsonutils +import nova.conf from nova import exception from nova.i18n import _LE from nova import objects @@ -35,13 +35,8 @@ from nova.objects import base as objects_base from nova import rpc LOG = logging.getLogger(__name__) -CONF = cfg.CONF -CONF.import_opt('enable', 'nova.cells.opts', group='cells') -CONF.import_opt('topic', 'nova.cells.opts', group='cells') -rpcapi_cap_opt = cfg.StrOpt('cells', - help='Set a version cap for messages sent to local cells services') -CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels') +CONF = nova.conf.CONF class CellsAPI(object): diff --git a/nova/cells/scheduler.py b/nova/cells/scheduler.py index f625cd7a89..f218df500f 100644 --- a/nova/cells/scheduler.py +++ b/nova/cells/scheduler.py @@ -19,7 +19,6 @@ Cells Scheduler import copy import time -from oslo_config import cfg from oslo_log import log as logging from six.moves import range @@ -29,6 +28,7 @@ from nova import compute from nova.compute import instance_actions from nova.compute import vm_states from nova import conductor +import nova.conf from nova.db import base from nova import exception from nova.i18n import _LE, _LI @@ -37,30 +37,9 @@ from nova.objects import base as obj_base from nova.scheduler import utils as scheduler_utils from nova import utils -cell_scheduler_opts = [ - cfg.ListOpt('scheduler_filter_classes', - default=['nova.cells.filters.all_filters'], - help='Filter classes the cells scheduler should use. ' - 'An entry of "nova.cells.filters.all_filters" ' - 'maps to all cells filters included with nova.'), - cfg.ListOpt('scheduler_weight_classes', - default=['nova.cells.weights.all_weighers'], - help='Weigher classes the cells scheduler should use. ' - 'An entry of "nova.cells.weights.all_weighers" ' - 'maps to all cell weighers included with nova.'), - cfg.IntOpt('scheduler_retries', - default=10, - help='How many retries when no cells are available.'), - cfg.IntOpt('scheduler_retry_delay', - default=2, - help='How often to retry in seconds when no cells are ' - 'available.') -] - LOG = logging.getLogger(__name__) -CONF = cfg.CONF -CONF.register_opts(cell_scheduler_opts, group='cells') +CONF = nova.conf.CONF class CellsScheduler(base.Base): diff --git a/nova/cells/state.py b/nova/cells/state.py index 0b77a0bce3..3e7a3fc4f4 100644 --- a/nova/cells/state.py +++ b/nova/cells/state.py @@ -31,6 +31,7 @@ from oslo_utils import units import six from nova.cells import rpc_driver +import nova.conf from nova import context from nova.db import base from nova import exception @@ -39,25 +40,10 @@ from nova import objects from nova import rpc from nova import utils -cell_state_manager_opts = [ - cfg.IntOpt('db_check_interval', - default=60, - help='Interval, in seconds, for getting fresh cell ' - 'information from the database.'), - cfg.StrOpt('cells_config', - help='Configuration file from which to read cells ' - 'configuration. If given, overrides reading cells ' - 'from the database.'), -] - LOG = logging.getLogger(__name__) -CONF = cfg.CONF -CONF.import_opt('name', 'nova.cells.opts', group='cells') -CONF.import_opt('reserve_percent', 'nova.cells.opts', group='cells') -CONF.import_opt('mute_child_interval', 'nova.cells.opts', group='cells') -CONF.register_opts(cell_state_manager_opts, group='cells') +CONF = nova.conf.CONF class CellState(object): diff --git a/nova/cells/utils.py b/nova/cells/utils.py index 1c33d31a67..e196470e13 100644 --- a/nova/cells/utils.py +++ b/nova/cells/utils.py @@ -19,9 +19,9 @@ Cells Utility Methods import random import sys -from oslo_config import cfg import six +import nova.conf from nova import objects from nova.objects import base as obj_base @@ -36,9 +36,7 @@ BLOCK_SYNC_FLAG = '!!' # Separator used between cell name and item _CELL_ITEM_SEP = '@' -CONF = cfg.CONF -CONF.import_opt('instance_update_sync_database_limit', 'nova.cells.opts', - group='cells') +CONF = nova.conf.CONF class ProxyObjectSerializer(obj_base.NovaObjectSerializer): diff --git a/nova/cells/weights/mute_child.py b/nova/cells/weights/mute_child.py index f004251f10..eaf62577f8 100644 --- a/nova/cells/weights/mute_child.py +++ b/nova/cells/weights/mute_child.py @@ -18,25 +18,16 @@ If a child cell hasn't sent capacity or capability updates in a while, downgrade its likelihood of being chosen for scheduling requests. """ -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import timeutils from nova.cells import weights +import nova.conf from nova.i18n import _LW LOG = logging.getLogger(__name__) -mute_weigher_opts = [ - cfg.FloatOpt('mute_weight_multiplier', - default=-10000.0, - help='Multiplier used to weigh mute children. (The value ' - 'should be negative.)'), -] - -CONF = cfg.CONF -CONF.import_opt('mute_child_interval', 'nova.cells.opts', group='cells') -CONF.register_opts(mute_weigher_opts, group='cells') +CONF = nova.conf.CONF class MuteChildWeigher(weights.BaseCellWeigher): diff --git a/nova/cells/weights/ram_by_instance_type.py b/nova/cells/weights/ram_by_instance_type.py index fb54edefb9..90052be0e6 100644 --- a/nova/cells/weights/ram_by_instance_type.py +++ b/nova/cells/weights/ram_by_instance_type.py @@ -16,19 +16,12 @@ """ Weigh cells by memory needed in a way that spreads instances. """ -from oslo_config import cfg from nova.cells import weights +import nova.conf -ram_weigher_opts = [ - cfg.FloatOpt('ram_weight_multiplier', - default=10.0, - help='Multiplier used for weighing ram. Negative ' - 'numbers mean to stack vs spread.'), -] -CONF = cfg.CONF -CONF.register_opts(ram_weigher_opts, group='cells') +CONF = nova.conf.CONF class RamByInstanceTypeWeigher(weights.BaseCellWeigher): diff --git a/nova/cells/weights/weight_offset.py b/nova/cells/weights/weight_offset.py index 01ff35ed1e..adbb0c5730 100644 --- a/nova/cells/weights/weight_offset.py +++ b/nova/cells/weights/weight_offset.py @@ -18,18 +18,11 @@ Weigh cells by their weight_offset in the DB. Cells with higher weight_offsets in the DB will be preferred. """ -from oslo_config import cfg - from nova.cells import weights +import nova.conf -weigher_opts = [ - cfg.FloatOpt('offset_weight_multiplier', - default=1.0, - help='Multiplier used to weigh offset weigher.'), -] -CONF = cfg.CONF -CONF.register_opts(weigher_opts, group='cells') +CONF = nova.conf.CONF class WeightOffsetWeigher(weights.BaseCellWeigher): diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index c02abb9a34..e353703d74 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -25,7 +25,7 @@ from oslo_config import cfg # from nova.conf import aws # from nova.conf import barbican # from nova.conf import base -# from nova.conf import cells +from nova.conf import cells from nova.conf import cert # from nova.conf import cinder # from nova.conf import cloudpipe @@ -85,7 +85,7 @@ CONF = cfg.CONF # aws.register_opts(CONF) # barbican.register_opts(CONF) # base.register_opts(CONF) -# cells.register_opts(CONF) +cells.register_opts(CONF) cert.register_opts(CONF) # cinder.register_opts(CONF) # cloudpipe.register_opts(CONF) diff --git a/nova/conf/cells.py b/nova/conf/cells.py new file mode 100644 index 0000000000..5669612944 --- /dev/null +++ b/nova/conf/cells.py @@ -0,0 +1,178 @@ +# 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 + + +cells_opts = [ + cfg.BoolOpt('enable', + default=False, + help='Enable cell functionality'), + cfg.StrOpt('topic', + default='cells', + help='The topic cells nodes listen on'), + cfg.StrOpt('manager', + default='nova.cells.manager.CellsManager', + help='Manager for cells'), + cfg.StrOpt('name', + default='nova', + help='Name of this cell'), + cfg.ListOpt('capabilities', + default=['hypervisor=xenserver;kvm', 'os=linux;windows'], + help='Key/Multi-value list with the capabilities of the cell'), + cfg.IntOpt('call_timeout', + default=60, + help='Seconds to wait for response from a call to a cell.'), + cfg.FloatOpt('reserve_percent', + default=10.0, + help='Percentage of cell capacity to hold in reserve. ' + 'Affects both memory and disk utilization'), + cfg.StrOpt('cell_type', + default='compute', + choices=('api', 'compute'), + help='Type of cell'), + cfg.IntOpt("mute_child_interval", + default=300, + help='Number of seconds after which a lack of capability and ' + 'capacity updates signals the child cell is to be ' + 'treated as a mute.'), + cfg.IntOpt('bandwidth_update_interval', + default=600, + help='Seconds between bandwidth updates for cells.'), + cfg.IntOpt('instance_update_sync_database_limit', + default=100, + help='Number of instances to pull from the database at one ' + 'time for a sync. If there are more instances to update ' + 'the results will be paged through'), +] + +mute_weigher_opts = [ + cfg.FloatOpt('mute_weight_multiplier', + default=-10000.0, + help='Multiplier used to weigh mute children. (The value ' + 'should be negative.)'), +] + +ram_weigher_opts = [ + cfg.FloatOpt('ram_weight_multiplier', + default=10.0, + help='Multiplier used for weighing ram. Negative ' + 'numbers mean to stack vs spread.'), +] + +weigher_opts = [ + cfg.FloatOpt('offset_weight_multiplier', + default=1.0, + help='Multiplier used to weigh offset weigher.'), +] + +cell_manager_opts = [ + cfg.StrOpt('driver', + default='nova.cells.rpc_driver.CellsRPCDriver', + help='Cells communication driver to use'), + cfg.IntOpt("instance_updated_at_threshold", + default=3600, + help="Number of seconds after an instance was updated " + "or deleted to continue to update cells"), + cfg.IntOpt("instance_update_num_instances", + default=1, + help="Number of instances to update per periodic task run") +] + +cell_messaging_opts = [ + cfg.IntOpt('max_hop_count', + default=10, + help='Maximum number of hops for cells routing.'), + cfg.StrOpt('scheduler', + default='nova.cells.scheduler.CellsScheduler', + help='Cells scheduler to use') +] + +cell_rpc_driver_opts = [ + cfg.StrOpt('rpc_driver_queue_base', + default='cells.intercell', + help="Base queue name to use when communicating between " + "cells. Various topics by message type will be " + "appended to this.") +] + +cell_scheduler_opts = [ + cfg.ListOpt('scheduler_filter_classes', + default=['nova.cells.filters.all_filters'], + help='Filter classes the cells scheduler should use. ' + 'An entry of "nova.cells.filters.all_filters" ' + 'maps to all cells filters included with nova.'), + cfg.ListOpt('scheduler_weight_classes', + default=['nova.cells.weights.all_weighers'], + help='Weigher classes the cells scheduler should use. ' + 'An entry of "nova.cells.weights.all_weighers" ' + 'maps to all cell weighers included with nova.'), + cfg.IntOpt('scheduler_retries', + default=10, + help='How many retries when no cells are available.'), + cfg.IntOpt('scheduler_retry_delay', + default=2, + help='How often to retry in seconds when no cells are ' + 'available.') +] + +cell_state_manager_opts = [ + cfg.IntOpt('db_check_interval', + default=60, + help='Interval, in seconds, for getting fresh cell ' + 'information from the database.'), + cfg.StrOpt('cells_config', + help='Configuration file from which to read cells ' + 'configuration. If given, overrides reading cells ' + 'from the database.') +] + + +rpcapi_cap_intercell_opt = cfg.StrOpt('intercell', + help='Set a version cap for messages sent between cells services') + + +rpcapi_cap_cells_opt = cfg.StrOpt('cells', + help='Set a version cap for messages sent to local cells services') + + +ALL_CELLS_OPTS = list(itertools.chain( + cells_opts, + mute_weigher_opts, + ram_weigher_opts, + weigher_opts, + cell_manager_opts, + cell_messaging_opts, + cell_rpc_driver_opts, + cell_scheduler_opts, + cell_state_manager_opts + )) + +ALL_RPCAPI_CAP_OPTS = [rpcapi_cap_intercell_opt, + rpcapi_cap_cells_opt] + + +def register_opts(conf): + conf.register_opts(ALL_CELLS_OPTS, group="cells") + conf.register_opts(ALL_RPCAPI_CAP_OPTS, group="upgrade_levels") + + +def list_opts(): + return { + 'cells': ALL_CELLS_OPTS, + 'upgrade_levels': ALL_RPCAPI_CAP_OPTS, + } |