def test_define_list(self): flags.DEFINE_list('list', ['foo'], 'desc', flag_values=self.FLAGS) self.assert_(self.FLAGS['list']) self.assertEqual(self.FLAGS.list, ['foo']) argv = ['flags_test', '--list=a,b,c,d'] self.FLAGS(argv) self.assertEqual(self.FLAGS.list, ['a', 'b', 'c', 'd'])
'logging_context_format_string', '%(asctime)s %(levelname)s %(name)s ' '[%(request_id)s %(user_id)s ' '%(project_id)s] %(message)s', 'format string to use for log messages with context') flags.DEFINE_string('logging_default_format_string', '%(asctime)s %(levelname)s %(name)s [-] ' '%(message)s', 'format string to use for log messages without context') flags.DEFINE_string( 'logging_debug_format_suffix', 'from (pid=%(process)d) %(funcName)s' ' %(pathname)s:%(lineno)d', 'data to append to log format when level is DEBUG') flags.DEFINE_string('logging_exception_prefix', '(%(name)s): TRACE: ', 'prefix each line of exception output with this format') flags.DEFINE_list('default_log_levels', [ 'amqplib=WARN', 'sqlalchemy=WARN', 'boto=WARN', 'suds=INFO', 'eventlet.wsgi.server=WARN' ], 'list of logger=LEVEL pairs') flags.DEFINE_bool('use_syslog', False, 'output to syslog') flags.DEFINE_bool('publish_errors', False, 'publish error events') flags.DEFINE_string('logfile', None, 'output to named file') flags.DEFINE_bool('use_stderr', True, 'log to standard error') # A list of things we want to replicate from logging. # levels CRITICAL = logging.CRITICAL FATAL = logging.FATAL ERROR = logging.ERROR WARNING = logging.WARNING WARN = logging.WARN INFO = logging.INFO DEBUG = logging.DEBUG
from engine import crypto from engine import db from engine import exception from engine import flags from engine import log as logging from engine import utils from engine.auth import signer FLAGS = flags.FLAGS flags.DEFINE_bool('use_deprecated_auth', False, 'This flag must be set to use old style auth') flags.DEFINE_list('allowed_roles', ['cloudadmin', 'itsec', 'sysadmin', 'netadmin', 'developer'], 'Allowed roles for project') # NOTE(vish): a user with one of these roles will be a superuser and # have access to all api commands flags.DEFINE_list('superuser_roles', ['cloudadmin'], 'Roles that ignore authorization checking completely') # NOTE(vish): a user with one of these roles will have it for every # project, even if he or she is not a member of the project flags.DEFINE_list('global_roles', ['cloudadmin', 'itsec'], 'Roles that apply to all projects') flags.DEFINE_string('credentials_template', utils.abspath('auth/enginerc.template'), 'Template for creating users rc file') flags.DEFINE_string('vpn_client_template',
from engine import db from engine import flags from engine import exception from engine.scheduler import driver from engine.scheduler import chance FLAGS = flags.FLAGS flags.DEFINE_integer("max_cores", 16, "maximum number of instance cores to allow per host") flags.DEFINE_integer("max_gigabytes", 10000, "maximum number of volume gigabytes to allow per host") flags.DEFINE_integer("max_networks", 1000, "maximum number of networks to allow per host") flags.DEFINE_string('default_schedule_zone', None, 'zone to use when user doesnt specify one') flags.DEFINE_list('isolated_images', [], 'Images to run on isolated host') flags.DEFINE_list('isolated_hosts', [], 'Host reserved for specific images') flags.DEFINE_boolean('skip_isolated_core_check', True, 'Allow overcommitting vcpus on isolated hosts') class SimpleScheduler(chance.ChanceScheduler): """Implements Naive Scheduler that tries to find least loaded host.""" def _schedule_instance(self, context, instance_opts, *_args, **_kwargs): """Picks a host that is up and has the fewest running instances.""" elevated = context.elevated() availability_zone = instance_opts.get('availability_zone') zone, host = FLAGS.default_schedule_zone, None if availability_zone:
from engine import exception from engine import flags from engine import log as logging from engine import utils from engine.virt.disk import guestfs from engine.virt.disk import loop from engine.virt.disk import nbd LOG = logging.getLogger('engine.compute.disk') FLAGS = flags.FLAGS flags.DEFINE_integer('minimum_root_size', 1024 * 1024 * 1024 * 10, 'minimum size in bytes of root partition') flags.DEFINE_string('injected_network_template', utils.abspath('virt/interfaces.template'), 'Template file for injected network') flags.DEFINE_list('img_handlers', ['loop', 'nbd', 'guestfs'], 'Order of methods used to mount disk images') # NOTE(yamahata): DEFINE_list() doesn't work because the command may # include ','. For example, # mkfs.ext3 -O dir_index,extent -E stride=8,stripe-width=16 # --label %(fs_label)s %(target)s # # DEFINE_list() parses its argument by # [s.strip() for s in argument.split(self._token)] # where self._token = ',' # No escape nor exceptional handling for ','. # DEFINE_list() doesn't give us what we need. flags.DEFINE_multistring( 'virt_mkfs', [ 'windows=mkfs.ntfs --fast --label %(fs_label)s '
from engine import crypto from engine import db from engine import exception from engine import flags from engine import log as logging from engine import rpc from engine.scheduler import api from engine.scheduler import driver from engine.scheduler import filters from engine.scheduler import least_cost from engine.scheduler import scheduler_options from engine import utils FLAGS = flags.FLAGS flags.DEFINE_list( 'default_host_filters', ['InstanceTypeFilter'], 'Which filters to use for filtering hosts when not specified ' 'in the request.') LOG = logging.getLogger('engine.scheduler.distributed_scheduler') class InvalidBlob(exception.EngineException): message = _("Ill-formed or incorrectly routed 'blob' data sent " "to instance create request.") class DistributedScheduler(driver.Scheduler): """Scheduler that can work across any engine deployment, from simple deployments to multiple nested zones. """ def __init__(self, *args, **kwargs):
is decided upon by a set of objective-functions, called the 'cost-functions'. The WeightedHost contains a combined weight for each cost-function. The cost-function and weights are tabulated, and the host with the least cost is then selected for provisioning. """ from engine import flags from engine import log as logging from engine import exception LOG = logging.getLogger('engine.scheduler.least_cost') FLAGS = flags.FLAGS flags.DEFINE_list('least_cost_functions', ['engine.scheduler.least_cost.compute_fill_first_cost_fn'], 'Which cost functions the LeastCostScheduler should use.') # TODO(sirp): Once we have enough of these rules, we can break them out into a # cost_functions.py file (perhaps in a least_cost_scheduler directory) flags.DEFINE_float('noop_cost_fn_weight', 1.0, 'How much weight to give the noop cost function') flags.DEFINE_float('compute_fill_first_cost_fn_weight', 1.0, 'How much weight to give the fill-first cost function') class WeightedHost(object): """Reduced set of information about a host that has been weighed. This is an attempt to remove some of the ad-hoc dict structures previously used.""" def __init__(self, weight, host=None, blob=None, zone=None, hostinfo=None):