Merge "Config options: centralize section "cells""

This commit is contained in:
Jenkins 2016-02-10 08:55:48 +00:00 committed by Gerrit Code Review
commit 3d80118593
13 changed files with 204 additions and 206 deletions

View File

@ -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__)

View File

@ -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__)

View File

@ -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 []

View File

@ -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:

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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)

178
nova/conf/cells.py Normal file
View File

@ -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,
}