import random
+from oslo.config import cfg
+
from cinder import exception
-from cinder import flags
from cinder.scheduler import driver
-FLAGS = flags.FLAGS
+CONF = cfg.CONF
class ChanceScheduler(driver.Scheduler):
def schedule_create_volume(self, context, request_spec, filter_properties):
"""Picks a host that is up at random."""
- topic = FLAGS.volume_topic
+ topic = CONF.volume_topic
host = self._schedule(context, topic, request_spec,
filter_properties=filter_properties)
volume_id = request_spec['volume_id']
from oslo.config import cfg
from cinder import db
-from cinder import flags
from cinder.openstack.common import importutils
from cinder.openstack.common import timeutils
from cinder import utils
from cinder.volume import rpcapi as volume_rpcapi
+
scheduler_driver_opts = [
cfg.StrOpt('scheduler_host_manager',
default='cinder.scheduler.host_manager.HostManager',
help='Maximum number of attempts to schedule an volume'),
]
-FLAGS = flags.FLAGS
-FLAGS.register_opts(scheduler_driver_opts)
+CONF = cfg.CONF
+CONF.register_opts(scheduler_driver_opts)
def volume_update_db(context, volume_id, host):
def __init__(self):
self.host_manager = importutils.import_object(
- FLAGS.scheduler_host_manager)
+ CONF.scheduler_host_manager)
self.volume_rpcapi = volume_rpcapi.VolumeAPI()
def get_host_list(self):
Weighing Functions.
"""
-import operator
+from oslo.config import cfg
from cinder import exception
-from cinder import flags
-from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging
from cinder.scheduler import driver
from cinder.scheduler import scheduler_options
-
-FLAGS = flags.FLAGS
+CONF = cfg.CONF
LOG = logging.getLogger(__name__)
hosts.append(host)
def _max_attempts(self):
- max_attempts = FLAGS.scheduler_max_attempts
+ max_attempts = CONF.scheduler_max_attempts
if max_attempts < 1:
msg = _("Invalid value for 'scheduler_max_attempts', "
"must be >=1")
from cinder import db
from cinder import exception
-from cinder import flags
from cinder.openstack.common import log as logging
from cinder.openstack.common.scheduler import filters
from cinder.openstack.common.scheduler import weights
from cinder.openstack.common import timeutils
from cinder import utils
+
host_manager_opts = [
cfg.ListOpt('scheduler_default_filters',
default=[
help='Which weigher class names to use for weighing hosts.')
]
-FLAGS = flags.FLAGS
-FLAGS.register_opts(host_manager_opts)
+CONF = cfg.CONF
+CONF.register_opts(host_manager_opts)
LOG = logging.getLogger(__name__)
of acceptable filters.
"""
if filter_cls_names is None:
- filter_cls_names = FLAGS.scheduler_default_filters
+ filter_cls_names = CONF.scheduler_default_filters
if not isinstance(filter_cls_names, (list, tuple)):
filter_cls_names = [filter_cls_names]
good_filters = []
of acceptable weighers.
"""
if weight_cls_names is None:
- weight_cls_names = FLAGS.scheduler_default_weighers
+ weight_cls_names = CONF.scheduler_default_weighers
if not isinstance(weight_cls_names, (list, tuple)):
weight_cls_names = [weight_cls_names]
"""
# Get resource usage across the available volume nodes:
- topic = FLAGS.volume_topic
+ topic = CONF.volume_topic
volume_services = db.service_get_all_by_topic(context, topic)
for service in volume_services:
host = service['host']
from cinder import context
from cinder import db
from cinder import exception
-from cinder import flags
from cinder import manager
from cinder.openstack.common import excutils
from cinder.openstack.common import importutils
from cinder.openstack.common.notifier import api as notifier
from cinder.volume import rpcapi as volume_rpcapi
-LOG = logging.getLogger(__name__)
scheduler_driver_opt = cfg.StrOpt('scheduler_driver',
default='cinder.scheduler.filter_scheduler.'
'FilterScheduler',
help='Default scheduler driver to use')
-FLAGS = flags.FLAGS
-FLAGS.register_opt(scheduler_driver_opt)
+CONF = cfg.CONF
+CONF.register_opt(scheduler_driver_opt)
+
+LOG = logging.getLogger(__name__)
class SchedulerManager(manager.Manager):
def __init__(self, scheduler_driver=None, service_name=None,
*args, **kwargs):
if not scheduler_driver:
- scheduler_driver = FLAGS.scheduler_driver
+ scheduler_driver = CONF.scheduler_driver
self.driver = importutils.import_object(scheduler_driver)
super(SchedulerManager, self).__init__(*args, **kwargs)
Client side of the scheduler manager RPC API.
"""
-from cinder import flags
+from oslo.config import cfg
+
from cinder.openstack.common import jsonutils
import cinder.openstack.common.rpc.proxy
-FLAGS = flags.FLAGS
+CONF = cfg.CONF
class SchedulerAPI(cinder.openstack.common.rpc.proxy.RpcProxy):
def __init__(self):
super(SchedulerAPI, self).__init__(
- topic=FLAGS.scheduler_topic,
+ topic=CONF.scheduler_topic,
default_version=self.RPC_API_VERSION)
def create_volume(self, ctxt, topic, volume_id, snapshot_id=None,
from oslo.config import cfg
-from cinder import flags
from cinder.openstack.common import log as logging
from cinder.openstack.common import timeutils
+
scheduler_json_config_location_opt = cfg.StrOpt(
'scheduler_json_config_location',
default='',
help='Absolute path to scheduler configuration JSON file.')
-FLAGS = flags.FLAGS
-FLAGS.register_opt(scheduler_json_config_location_opt)
+
+CONF = cfg.CONF
+CONF.register_opt(scheduler_json_config_location_opt)
LOG = logging.getLogger(__name__)
def get_configuration(self, filename=None):
"""Check the json file for changes and load it if needed."""
if not filename:
- filename = FLAGS.scheduler_json_config_location
+ filename = CONF.scheduler_json_config_location
if not filename:
return self.data
if self.last_checked:
from cinder import db
from cinder import exception
-from cinder import flags
from cinder.scheduler import chance
from cinder.scheduler import driver
from cinder import utils
+
simple_scheduler_opts = [
cfg.IntOpt("max_gigabytes",
default=10000,
help="maximum number of volume gigabytes to allow per host"), ]
-FLAGS = flags.FLAGS
-FLAGS.register_opts(simple_scheduler_opts)
+CONF = cfg.CONF
+CONF.register_opts(simple_scheduler_opts)
class SimpleScheduler(chance.ChanceScheduler):
if availability_zone:
zone, _x, host = availability_zone.partition(':')
if host and context.is_admin:
- topic = FLAGS.volume_topic
+ topic = CONF.volume_topic
service = db.service_get_by_args(elevated, host, topic)
if not utils.service_is_up(service):
raise exception.WillNotSchedule(host=host)
if service['availability_zone'] == zone]
for result in results:
(service, volume_gigabytes) = result
- if volume_gigabytes + volume_size > FLAGS.max_gigabytes:
+ if volume_gigabytes + volume_size > CONF.max_gigabytes:
msg = _("Not enough allocatable volume gigabytes remaining")
raise exception.NoValidHost(reason=msg)
if utils.service_is_up(service) and not service['disabled']:
number and the weighing has the opposite effect of the default.
"""
+
import math
from oslo.config import cfg
-from cinder import flags
from cinder.openstack.common.scheduler import weights
+
capacity_weight_opts = [
- cfg.FloatOpt('capacity_weight_multiplier',
- default=1.0,
- help='Multiplier used for weighing volume capacity. '
- 'Negative numbers mean to stack vs spread.'),
+ cfg.FloatOpt('capacity_weight_multiplier',
+ default=1.0,
+ help='Multiplier used for weighing volume capacity. '
+ 'Negative numbers mean to stack vs spread.'),
]
-FLAGS = flags.FLAGS
-FLAGS.register_opts(capacity_weight_opts)
+CONF = cfg.CONF
+CONF.register_opts(capacity_weight_opts)
class CapacityWeigher(weights.BaseHostWeigher):
def _weight_multiplier(self):
"""Override the weight multiplier."""
- return FLAGS.capacity_weight_multiplier
+ return CONF.capacity_weight_multiplier
def _weigh_object(self, host_state, weight_properties):
"""Higher weights win. We want spreading to be the default."""
# License for the specific language governing permissions and limitations
# under the License.
+
import contextlib
import mox
import os
from cinder.volume import configuration as conf
import cinder.volume.drivers.rbd as driver
+
LOG = logging.getLogger(__name__)
RADOS Block Device Driver
"""
+
from __future__ import absolute_import
import json
rados = None
rbd = None
+
LOG = logging.getLogger(__name__)
rbd_opts = [