Remove the last of the gflags shim layer
Make FLAGS a ConfigOpts instance and fix up all the places where we expected FlagValues behaviour. Change-Id: I8f96f42e0d8d30ba6b362d29861e717cf0fa9e89
This commit is contained in:
parent
5ad971810a
commit
d1888a3359
@ -55,7 +55,7 @@ delete_exchange_opt = \
|
||||
help='delete nova exchange too.')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(delete_exchange_opt)
|
||||
FLAGS.register_cli_opt(delete_exchange_opt)
|
||||
|
||||
|
||||
def delete_exchange(exch):
|
||||
|
@ -57,7 +57,7 @@ direct_api_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(direct_api_opts)
|
||||
FLAGS.register_cli_opts(direct_api_opts)
|
||||
|
||||
|
||||
# An example of an API that only exposes read-only methods.
|
||||
|
@ -2201,7 +2201,7 @@ class ConfigCommands(object):
|
||||
pass
|
||||
|
||||
def list(self):
|
||||
for key, value in FLAGS.FlagValuesDict().iteritems():
|
||||
for key, value in FLAGS.iteritems():
|
||||
if value is not None:
|
||||
print '%s = %s' % (key, value)
|
||||
|
||||
|
@ -34,7 +34,7 @@ use_forwarded_for_opt = cfg.BoolOpt('use_forwarded_for',
|
||||
'Only enable this if you have a sanitizing proxy.')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(use_forwarded_for_opt)
|
||||
FLAGS.register_opt(use_forwarded_for_opt)
|
||||
|
||||
|
||||
class InjectContext(wsgi.Middleware):
|
||||
|
@ -59,7 +59,7 @@ ec2_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(ec2_opts)
|
||||
FLAGS.register_opts(ec2_opts)
|
||||
|
||||
flags.DECLARE('use_forwarded_for', 'nova.api.auth')
|
||||
|
||||
|
@ -44,7 +44,7 @@ allow_instance_snapshots_opt = \
|
||||
help='Permit instance snapshot operations.')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(allow_instance_snapshots_opt)
|
||||
FLAGS.register_opt(allow_instance_snapshots_opt)
|
||||
|
||||
|
||||
class APIRouter(nova.api.openstack.APIRouter):
|
||||
|
@ -88,7 +88,7 @@ ldap_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(ldap_opts)
|
||||
FLAGS.register_opts(ldap_opts)
|
||||
|
||||
LOG = logging.getLogger("nova.ldapdriver")
|
||||
|
||||
@ -573,7 +573,7 @@ class LdapDriver(object):
|
||||
def __role_to_dn(self, role, project_id=None):
|
||||
"""Convert role to corresponding dn"""
|
||||
if project_id is None:
|
||||
return FLAGS.__getitem__("ldap_%s" % role).value
|
||||
return FLAGS["ldap_%s" % role]
|
||||
else:
|
||||
project_dn = self.__project_to_dn(project_id)
|
||||
return 'cn=%s,%s' % (role, project_dn)
|
||||
|
@ -92,7 +92,7 @@ auth_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(auth_opts)
|
||||
FLAGS.register_opts(auth_opts)
|
||||
|
||||
flags.DECLARE('osapi_compute_listen_port', 'nova.service')
|
||||
|
||||
|
@ -53,7 +53,7 @@ cloudpipe_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(cloudpipe_opts)
|
||||
FLAGS.register_opts(cloudpipe_opts)
|
||||
|
||||
|
||||
LOG = logging.getLogger('nova.cloudpipe')
|
||||
|
@ -55,7 +55,7 @@ find_host_timeout_opt = cfg.StrOpt('find_host_timeout',
|
||||
help='Timeout after NN seconds when looking for a host.')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(find_host_timeout_opt)
|
||||
FLAGS.register_opt(find_host_timeout_opt)
|
||||
flags.DECLARE('enable_zone_routing', 'nova.scheduler.api')
|
||||
flags.DECLARE('consoleauth_topic', 'nova.consoleauth')
|
||||
|
||||
|
@ -119,7 +119,7 @@ compute_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(compute_opts)
|
||||
FLAGS.register_opts(compute_opts)
|
||||
|
||||
LOG = logging.getLogger('nova.compute.manager')
|
||||
|
||||
|
@ -41,7 +41,7 @@ console_manager_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(console_manager_opts)
|
||||
FLAGS.register_opts(console_manager_opts)
|
||||
|
||||
|
||||
class ConsoleProxyManager(manager.Manager):
|
||||
|
@ -36,7 +36,7 @@ vmrc_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(vmrc_opts)
|
||||
FLAGS.register_opts(vmrc_opts)
|
||||
|
||||
|
||||
class VMRCConsole(object):
|
||||
|
@ -39,7 +39,7 @@ vmrc_manager_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(vmrc_manager_opts)
|
||||
FLAGS.register_opts(vmrc_manager_opts)
|
||||
|
||||
|
||||
class ConsoleVMRCManager(manager.Manager):
|
||||
|
@ -50,7 +50,7 @@ xvp_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(xvp_opts)
|
||||
FLAGS.register_opts(xvp_opts)
|
||||
|
||||
|
||||
class XVPConsoleProxy(object):
|
||||
|
@ -27,4 +27,4 @@ consoleauth_topic_opt = cfg.StrOpt('consoleauth_topic',
|
||||
help='the topic console auth proxy nodes listen on')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(consoleauth_topic_opt)
|
||||
FLAGS.register_opt(consoleauth_topic_opt)
|
||||
|
@ -41,7 +41,7 @@ consoleauth_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(consoleauth_opts)
|
||||
FLAGS.register_opts(consoleauth_opts)
|
||||
|
||||
|
||||
class ConsoleAuthManager(manager.Manager):
|
||||
|
@ -76,7 +76,7 @@ crypto_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(crypto_opts)
|
||||
FLAGS.register_opts(crypto_opts)
|
||||
|
||||
|
||||
def ca_folder(project_id=None):
|
||||
|
@ -71,9 +71,9 @@ db_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(db_opts)
|
||||
FLAGS.register_opts(db_opts)
|
||||
|
||||
IMPL = utils.LazyPluggable(FLAGS['db_backend'],
|
||||
IMPL = utils.LazyPluggable('db_backend',
|
||||
sqlalchemy='nova.db.sqlalchemy.api')
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ db_driver_opt = cfg.StrOpt('db_driver',
|
||||
help='driver to use for database access')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(db_driver_opt)
|
||||
FLAGS.register_opt(db_driver_opt)
|
||||
|
||||
|
||||
class Base(object):
|
||||
|
@ -18,15 +18,10 @@
|
||||
|
||||
"""Database setup and migration commands."""
|
||||
|
||||
from nova import flags
|
||||
from nova import utils
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
flags.DECLARE('db_backend', 'nova.db')
|
||||
|
||||
|
||||
IMPL = utils.LazyPluggable(FLAGS['db_backend'],
|
||||
IMPL = utils.LazyPluggable('db_backend',
|
||||
sqlalchemy='nova.db.sqlalchemy.migration')
|
||||
|
||||
|
||||
|
100
nova/flags.py
100
nova/flags.py
@ -3,7 +3,7 @@
|
||||
# Copyright 2010 United States Government as represented by the
|
||||
# Administrator of the National Aeronautics and Space Administration.
|
||||
# All Rights Reserved.
|
||||
# Copyright 2011 Red Hat, Inc.
|
||||
# Copyright 2012 Red Hat, Inc.
|
||||
#
|
||||
# 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
|
||||
@ -30,97 +30,21 @@ import os
|
||||
import socket
|
||||
import sys
|
||||
|
||||
import gflags
|
||||
|
||||
from nova.compat import flagfile
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
|
||||
class FlagValues(object):
|
||||
class Flag:
|
||||
def __init__(self, name, value, update_default=None):
|
||||
self.name = name
|
||||
self.value = value
|
||||
self._update_default = update_default
|
||||
class NovaConfigOpts(cfg.ConfigOpts):
|
||||
|
||||
def SetDefault(self, default):
|
||||
if self._update_default:
|
||||
self._update_default(self.name, default)
|
||||
|
||||
def __init__(self):
|
||||
self._conf = cfg.ConfigOpts()
|
||||
self._conf.disable_interspersed_args()
|
||||
self.Reset()
|
||||
|
||||
def _parse(self):
|
||||
if self._extra is not None:
|
||||
return
|
||||
|
||||
with flagfile.handle_flagfiles_managed(self._args) as args:
|
||||
self._extra = self._conf(args)
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NovaConfigOpts, self).__init__(*args, **kwargs)
|
||||
self.disable_interspersed_args()
|
||||
|
||||
def __call__(self, argv):
|
||||
self.Reset()
|
||||
self._args = argv[1:]
|
||||
self._parse()
|
||||
return [argv[0]] + self._extra
|
||||
with flagfile.handle_flagfiles_managed(argv[1:]) as args:
|
||||
return argv[:1] + super(NovaConfigOpts, self).__call__(args)
|
||||
|
||||
def __getattr__(self, name):
|
||||
self._parse()
|
||||
return getattr(self._conf, name)
|
||||
|
||||
def get(self, name, default):
|
||||
value = getattr(self, name)
|
||||
if value is not None: # value might be '0' or ""
|
||||
return value
|
||||
else:
|
||||
return default
|
||||
|
||||
def __contains__(self, name):
|
||||
self._parse()
|
||||
return hasattr(self._conf, name)
|
||||
|
||||
def _update_default(self, name, default):
|
||||
self._conf.set_default(name, default)
|
||||
|
||||
def __iter__(self):
|
||||
return self._conf.iterkeys()
|
||||
|
||||
def __getitem__(self, name):
|
||||
self._parse()
|
||||
if not self.__contains__(name):
|
||||
return None
|
||||
return self.Flag(name, getattr(self, name), self._update_default)
|
||||
|
||||
def Reset(self):
|
||||
self._conf.reset()
|
||||
self._args = []
|
||||
self._extra = None
|
||||
|
||||
def ParseNewFlags(self):
|
||||
pass
|
||||
|
||||
def FlagValuesDict(self):
|
||||
self._parse()
|
||||
ret = {}
|
||||
for name in self._conf:
|
||||
ret[name] = getattr(self, name)
|
||||
return ret
|
||||
|
||||
def add_option(self, opt):
|
||||
self._conf.register_opt(opt)
|
||||
|
||||
def add_options(self, opts):
|
||||
self._conf.register_opts(opts)
|
||||
|
||||
def add_cli_option(self, opt):
|
||||
self._conf.register_cli_opt(opt)
|
||||
|
||||
def add_cli_options(self, opts):
|
||||
self._conf.register_cli_opts(opts)
|
||||
|
||||
|
||||
FLAGS = FlagValues()
|
||||
FLAGS = NovaConfigOpts()
|
||||
|
||||
|
||||
class UnrecognizedFlag(Exception):
|
||||
@ -191,9 +115,9 @@ debug_opts = [
|
||||
help='use a fake rabbit'),
|
||||
]
|
||||
|
||||
FLAGS.add_cli_options(log_opts)
|
||||
FLAGS.add_cli_options(core_opts)
|
||||
FLAGS.add_cli_options(debug_opts)
|
||||
FLAGS.register_cli_opts(log_opts)
|
||||
FLAGS.register_cli_opts(core_opts)
|
||||
FLAGS.register_cli_opts(debug_opts)
|
||||
|
||||
global_opts = [
|
||||
cfg.StrOpt('my_ip',
|
||||
@ -523,4 +447,4 @@ global_opts = [
|
||||
help='Host reserved for specific images'),
|
||||
]
|
||||
|
||||
FLAGS.add_options(global_opts)
|
||||
FLAGS.register_opts(global_opts)
|
||||
|
@ -55,7 +55,7 @@ s3_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(s3_opts)
|
||||
FLAGS.register_opts(s3_opts)
|
||||
|
||||
|
||||
class S3ImageService(object):
|
||||
|
@ -24,12 +24,12 @@ ipv6_backend_opt = cfg.StrOpt('ipv6_backend',
|
||||
help='Backend to use for IPv6 generation')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(ipv6_backend_opt)
|
||||
FLAGS.register_opt(ipv6_backend_opt)
|
||||
|
||||
|
||||
def reset_backend():
|
||||
global IMPL
|
||||
IMPL = utils.LazyPluggable(FLAGS['ipv6_backend'],
|
||||
IMPL = utils.LazyPluggable('ipv6_backend',
|
||||
rfc2462='nova.ipv6.rfc2462',
|
||||
account_identifier='nova.ipv6.account_identifier')
|
||||
|
||||
|
@ -82,7 +82,7 @@ log_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(log_opts)
|
||||
FLAGS.register_opts(log_opts)
|
||||
|
||||
# A list of things we want to replicate from logging.
|
||||
# levels
|
||||
|
@ -64,7 +64,7 @@ ldap_dns_opts = [
|
||||
'Statement of Authority'),
|
||||
]
|
||||
|
||||
flags.FLAGS.add_options(ldap_dns_opts)
|
||||
flags.FLAGS.register_opts(ldap_dns_opts)
|
||||
|
||||
|
||||
def utf8(instring):
|
||||
|
@ -87,7 +87,7 @@ linux_net_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(linux_net_opts)
|
||||
FLAGS.register_opts(linux_net_opts)
|
||||
|
||||
|
||||
binary_name = os.path.basename(inspect.stack()[-1][1])
|
||||
|
@ -162,7 +162,7 @@ network_opts = [
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(network_opts)
|
||||
FLAGS.register_opts(network_opts)
|
||||
|
||||
|
||||
class AddressAlreadyAllocated(exception.Error):
|
||||
|
@ -56,7 +56,7 @@ quantum_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(quantum_opts)
|
||||
FLAGS.register_opts(quantum_opts)
|
||||
|
||||
|
||||
class QuantumManager(manager.FloatingIP, manager.FlatManager):
|
||||
|
@ -35,7 +35,7 @@ melange_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(melange_opts)
|
||||
FLAGS.register_opts(melange_opts)
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
json_content_type = {'Content-type': "application/json"}
|
||||
|
@ -36,7 +36,7 @@ quantum_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(quantum_opts)
|
||||
FLAGS.register_opts(quantum_opts)
|
||||
|
||||
|
||||
class QuantumClientConnection(object):
|
||||
|
@ -33,7 +33,7 @@ notifier_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(notifier_opts)
|
||||
FLAGS.register_opts(notifier_opts)
|
||||
|
||||
WARN = 'WARN'
|
||||
INFO = 'INFO'
|
||||
|
@ -25,7 +25,7 @@ list_notifier_drivers_opt = cfg.MultiStrOpt('list_notifier_drivers',
|
||||
help='List of drivers to send notifications')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(list_notifier_drivers_opt)
|
||||
FLAGS.register_opt(list_notifier_drivers_opt)
|
||||
|
||||
LOG = logging.getLogger('nova.notifier.list_notifier')
|
||||
|
||||
|
@ -26,7 +26,7 @@ notification_topic_opt = cfg.StrOpt('notification_topic',
|
||||
help='RabbitMQ topic used for Nova notifications')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(notification_topic_opt)
|
||||
FLAGS.register_opt(notification_topic_opt)
|
||||
|
||||
|
||||
def notify(message):
|
||||
|
@ -55,7 +55,7 @@ buckets_path_opt = cfg.StrOpt('buckets_path', default='$state_path/buckets',
|
||||
help='path to s3 buckets')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(buckets_path_opt)
|
||||
FLAGS.register_opt(buckets_path_opt)
|
||||
|
||||
|
||||
def get_wsgi_server():
|
||||
|
@ -34,7 +34,7 @@ policy_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(policy_opts)
|
||||
FLAGS.register_opts(policy_opts)
|
||||
|
||||
_POLICY_PATH = None
|
||||
_POLICY_CACHE = {}
|
||||
|
@ -57,7 +57,7 @@ quota_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(quota_opts)
|
||||
FLAGS.register_opts(quota_opts)
|
||||
|
||||
|
||||
def _get_default_quotas():
|
||||
|
@ -28,7 +28,7 @@ rpc_backend_opt = cfg.StrOpt('rpc_backend',
|
||||
help="The messaging module to use, defaults to kombu.")
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(rpc_backend_opt)
|
||||
FLAGS.register_opt(rpc_backend_opt)
|
||||
|
||||
|
||||
def create_connection(new=True):
|
||||
|
@ -39,7 +39,7 @@ rpc_opts = [
|
||||
help='Seconds to wait for a response from call or multicall'),
|
||||
]
|
||||
|
||||
flags.FLAGS.add_options(rpc_opts)
|
||||
flags.FLAGS.register_opts(rpc_opts)
|
||||
|
||||
|
||||
class RemoteError(exception.NovaException):
|
||||
|
@ -78,7 +78,7 @@ qpid_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(qpid_opts)
|
||||
FLAGS.register_opts(qpid_opts)
|
||||
|
||||
|
||||
class ConsumerBase(object):
|
||||
|
@ -38,7 +38,7 @@ enable_zone_routing_opt = cfg.BoolOpt('enable_zone_routing',
|
||||
help='When True, routing to child zones will occur.')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(enable_zone_routing_opt)
|
||||
FLAGS.register_opt(enable_zone_routing_opt)
|
||||
|
||||
LOG = logging.getLogger('nova.scheduler.api')
|
||||
|
||||
|
@ -48,7 +48,7 @@ scheduler_driver_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(scheduler_driver_opts)
|
||||
FLAGS.register_opts(scheduler_driver_opts)
|
||||
|
||||
flags.DECLARE('instances_path', 'nova.compute.manager')
|
||||
|
||||
|
@ -28,7 +28,7 @@ cpu_allocation_ratio_opt = cfg.FloatOpt('cpu_allocation_ratio',
|
||||
help='Virtual CPU to Physical CPU allocation ratio')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(cpu_allocation_ratio_opt)
|
||||
FLAGS.register_opt(cpu_allocation_ratio_opt)
|
||||
|
||||
|
||||
class CoreFilter(abstract_filter.AbstractHostFilter):
|
||||
|
@ -26,7 +26,7 @@ ram_allocation_ratio_opt = cfg.FloatOpt("ram_allocation_ratio",
|
||||
help="virtual ram to physical ram allocation ratio")
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(ram_allocation_ratio_opt)
|
||||
FLAGS.register_opt(ram_allocation_ratio_opt)
|
||||
|
||||
|
||||
class RamFilter(abstract_filter.AbstractHostFilter):
|
||||
|
@ -47,7 +47,7 @@ host_manager_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(host_manager_opts)
|
||||
FLAGS.register_opts(host_manager_opts)
|
||||
|
||||
LOG = logging.getLogger('nova.scheduler.host_manager')
|
||||
|
||||
|
@ -44,7 +44,7 @@ least_cost_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(least_cost_opts)
|
||||
FLAGS.register_opts(least_cost_opts)
|
||||
|
||||
# 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)
|
||||
|
@ -41,7 +41,7 @@ scheduler_driver_opt = cfg.StrOpt('scheduler_driver',
|
||||
help='Default driver to use for the scheduler')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(scheduler_driver_opt)
|
||||
FLAGS.register_opt(scheduler_driver_opt)
|
||||
|
||||
|
||||
class SchedulerManager(manager.Manager):
|
||||
|
@ -37,7 +37,7 @@ multi_scheduler_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(multi_scheduler_opts)
|
||||
FLAGS.register_opts(multi_scheduler_opts)
|
||||
|
||||
# A mapping of methods to topics so we can figure out which driver to use.
|
||||
_METHOD_MAP = {'run_instance': 'compute',
|
||||
|
@ -35,7 +35,7 @@ scheduler_json_config_location_opt = cfg.StrOpt(
|
||||
help='Absolute path to scheduler configuration JSON file.')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(scheduler_json_config_location_opt)
|
||||
FLAGS.register_opt(scheduler_json_config_location_opt)
|
||||
|
||||
LOG = logging.getLogger('nova.scheduler.scheduler_options')
|
||||
|
||||
|
@ -46,7 +46,7 @@ simple_scheduler_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(simple_scheduler_opts)
|
||||
FLAGS.register_opts(simple_scheduler_opts)
|
||||
|
||||
|
||||
class SimpleScheduler(chance.ChanceScheduler):
|
||||
|
@ -48,7 +48,7 @@ vsa_scheduler_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(vsa_scheduler_opts)
|
||||
FLAGS.register_opts(vsa_scheduler_opts)
|
||||
|
||||
|
||||
def BYTES_TO_GB(bytes):
|
||||
|
@ -40,7 +40,7 @@ zone_manager_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(zone_manager_opts)
|
||||
FLAGS.register_opts(zone_manager_opts)
|
||||
|
||||
LOG = logging.getLogger('nova.scheduler.zone_manager')
|
||||
|
||||
|
@ -76,7 +76,7 @@ service_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(service_opts)
|
||||
FLAGS.register_opts(service_opts)
|
||||
|
||||
|
||||
class Launcher(object):
|
||||
|
13
nova/test.py
13
nova/test.py
@ -53,7 +53,7 @@ test_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(test_opts)
|
||||
FLAGS.register_opts(test_opts)
|
||||
|
||||
LOG = log.getLogger('nova.tests')
|
||||
|
||||
@ -134,7 +134,7 @@ class TestCase(unittest.TestCase):
|
||||
self.stubs = stubout.StubOutForTesting()
|
||||
self.injected = []
|
||||
self._services = []
|
||||
self._original_flags = FLAGS.FlagValuesDict()
|
||||
self._overridden_opts = []
|
||||
|
||||
def tearDown(self):
|
||||
"""Runs after each test method to tear down test environment."""
|
||||
@ -176,7 +176,8 @@ class TestCase(unittest.TestCase):
|
||||
def flags(self, **kw):
|
||||
"""Override flag variables for a test."""
|
||||
for k, v in kw.iteritems():
|
||||
setattr(FLAGS, k, v)
|
||||
FLAGS.set_override(k, v)
|
||||
self._overridden_opts.append(k)
|
||||
|
||||
def reset_flags(self):
|
||||
"""Resets all flag variables for the test.
|
||||
@ -184,9 +185,9 @@ class TestCase(unittest.TestCase):
|
||||
Runs after each test.
|
||||
|
||||
"""
|
||||
FLAGS.Reset()
|
||||
for k, v in self._original_flags.iteritems():
|
||||
setattr(FLAGS, k, v)
|
||||
for k in self._overridden_opts:
|
||||
FLAGS.set_override(k, None)
|
||||
self._overridden_opts = []
|
||||
|
||||
def start_service(self, name, host=None, **kwargs):
|
||||
host = host and host or uuid.uuid4().hex
|
||||
|
@ -73,7 +73,9 @@ reldir = os.path.join(os.path.dirname(__file__), '..', '..')
|
||||
absdir = os.path.abspath(reldir)
|
||||
sys.path.insert(0, absdir)
|
||||
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
|
||||
class _AnsiColorizer(object):
|
||||
@ -341,18 +343,15 @@ class NovaTestRunner(core.TextTestRunner):
|
||||
|
||||
|
||||
def run():
|
||||
flags.FLAGS.register_cli_opt(cfg.BoolOpt('hide-elapsed', default=False))
|
||||
argv = flags.FLAGS(sys.argv)
|
||||
logging.setup()
|
||||
|
||||
# If any argument looks like a test name but doesn't have "nova.tests" in
|
||||
# front of it, automatically add that so we don't have to type as much
|
||||
show_elapsed = True
|
||||
argv = []
|
||||
for x in sys.argv:
|
||||
if x.startswith('test_'):
|
||||
argv.append('nova.tests.%s' % x)
|
||||
elif x.startswith('--hide-elapsed'):
|
||||
show_elapsed = False
|
||||
else:
|
||||
argv.append(x)
|
||||
for i, arg in enumerate(argv):
|
||||
if arg.startswith('test_'):
|
||||
argv[i] = append('nova.tests.%s' % arg)
|
||||
|
||||
testdir = os.path.abspath(os.path.join("nova", "tests"))
|
||||
c = config.Config(stream=sys.stdout,
|
||||
@ -364,7 +363,7 @@ def run():
|
||||
runner = NovaTestRunner(stream=c.stream,
|
||||
verbosity=c.verbosity,
|
||||
config=c,
|
||||
show_elapsed=show_elapsed)
|
||||
show_elapsed=not flags.FLAGS.hide_elapsed)
|
||||
sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
|
||||
|
||||
|
||||
|
@ -31,7 +31,6 @@ from nova.tests.api.openstack import fakes
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.verbose = True
|
||||
|
||||
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
|
||||
|
@ -25,7 +25,6 @@ from nova.tests.api.openstack import fakes
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.verbose = True
|
||||
|
||||
|
||||
UUID1 = '70f6db34-de8d-4fbd-aafb-4065bdfa6114'
|
||||
|
@ -189,7 +189,7 @@ class ImageMetaDataTest(test.TestCase):
|
||||
self.controller.create, req, '123', data)
|
||||
|
||||
def test_too_many_metadata_items_on_put(self):
|
||||
FLAGS.quota_metadata_items = 1
|
||||
self.flags(quota_metadata_items=1)
|
||||
req = fakes.HTTPRequest.blank('/v2/fake/images/123/metadata/blah')
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"blah": "blah"}}
|
||||
|
@ -47,8 +47,8 @@ fake_domains = [{'status': 1, 'name': 'instance-00000001',
|
||||
class DomainReadWriteTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.flags(baremetal_driver='fake')
|
||||
super(DomainReadWriteTestCase, self).setUp()
|
||||
self.flags(baremetal_driver='fake')
|
||||
|
||||
def test_read_domain_with_empty_list(self):
|
||||
"""Read a file that contains no domains"""
|
||||
@ -143,8 +143,8 @@ class DomainReadWriteTestCase(test.TestCase):
|
||||
class BareMetalDomTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.flags(baremetal_driver='fake')
|
||||
super(BareMetalDomTestCase, self).setUp()
|
||||
self.flags(baremetal_driver='fake')
|
||||
# Stub out utils.execute
|
||||
self.stubs = stubout.StubOutForTesting()
|
||||
fake_utils.stub_out_utils_execute(self.stubs)
|
||||
@ -263,8 +263,8 @@ class ProxyBareMetalTestCase(test.TestCase):
|
||||
'instance_type_id': '5'} # m1.small
|
||||
|
||||
def setUp(self):
|
||||
self.flags(baremetal_driver='fake')
|
||||
super(ProxyBareMetalTestCase, self).setUp()
|
||||
self.flags(baremetal_driver='fake')
|
||||
self.context = context.get_admin_context()
|
||||
fake_utils.stub_out_utils_execute(self.stubs)
|
||||
|
||||
|
@ -20,4 +20,4 @@ from nova import flags
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(cfg.IntOpt('answer', default=42, help='test flag'))
|
||||
FLAGS.register_opt(cfg.IntOpt('answer', default=42, help='test flag'))
|
||||
|
@ -21,25 +21,25 @@ from nova import flags
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
flags.DECLARE('volume_driver', 'nova.volume.manager')
|
||||
FLAGS['volume_driver'].SetDefault('nova.volume.driver.FakeISCSIDriver')
|
||||
FLAGS['connection_type'].SetDefault('fake')
|
||||
FLAGS['fake_rabbit'].SetDefault(True)
|
||||
FLAGS['rpc_backend'].SetDefault('nova.rpc.impl_fake')
|
||||
FLAGS.set_default('volume_driver', 'nova.volume.driver.FakeISCSIDriver')
|
||||
FLAGS.set_default('connection_type', 'fake')
|
||||
FLAGS.set_default('fake_rabbit', True)
|
||||
FLAGS.set_default('rpc_backend', 'nova.rpc.impl_fake')
|
||||
flags.DECLARE('auth_driver', 'nova.auth.manager')
|
||||
FLAGS['auth_driver'].SetDefault('nova.auth.dbdriver.DbDriver')
|
||||
FLAGS.set_default('auth_driver', 'nova.auth.dbdriver.DbDriver')
|
||||
flags.DECLARE('network_size', 'nova.network.manager')
|
||||
flags.DECLARE('num_networks', 'nova.network.manager')
|
||||
flags.DECLARE('fake_network', 'nova.network.manager')
|
||||
FLAGS['network_size'].SetDefault(8)
|
||||
FLAGS['num_networks'].SetDefault(2)
|
||||
FLAGS['fake_network'].SetDefault(True)
|
||||
FLAGS['image_service'].SetDefault('nova.image.fake.FakeImageService')
|
||||
FLAGS.set_default('network_size', 8)
|
||||
FLAGS.set_default('num_networks', 2)
|
||||
FLAGS.set_default('fake_network', True)
|
||||
FLAGS.set_default('image_service', 'nova.image.fake.FakeImageService')
|
||||
flags.DECLARE('iscsi_num_targets', 'nova.volume.driver')
|
||||
FLAGS['iscsi_num_targets'].SetDefault(8)
|
||||
FLAGS['verbose'].SetDefault(True)
|
||||
FLAGS['sqlite_db'].SetDefault("tests.sqlite")
|
||||
FLAGS['use_ipv6'].SetDefault(True)
|
||||
FLAGS['flat_network_bridge'].SetDefault('br100')
|
||||
FLAGS['sqlite_synchronous'].SetDefault(False)
|
||||
FLAGS.set_default('iscsi_num_targets', 8)
|
||||
FLAGS.set_default('verbose', True)
|
||||
FLAGS.set_default('sqlite_db', "tests.sqlite")
|
||||
FLAGS.set_default('use_ipv6', True)
|
||||
FLAGS.set_default('flat_network_bridge', 'br100')
|
||||
FLAGS.set_default('sqlite_synchronous', False)
|
||||
flags.DECLARE('policy_file', 'nova.policy')
|
||||
FLAGS['policy_file'].SetDefault('nova/tests/policy.json')
|
||||
FLAGS.set_default('policy_file', 'nova/tests/policy.json')
|
||||
|
@ -20,4 +20,4 @@ from nova import flags
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(cfg.IntOpt('runtime_answer', default=54, help='test flag'))
|
||||
FLAGS.register_opt(cfg.IntOpt('runtime_answer', default=54, help='test flag'))
|
||||
|
@ -898,7 +898,7 @@ class ComputeTestCase(BaseTestCase):
|
||||
vpn=False).\
|
||||
AndRaise(quantum_client.QuantumServerException())
|
||||
|
||||
FLAGS.stub_network = False
|
||||
self.flags(stub_network=False)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
|
@ -42,16 +42,14 @@ class ConsoleauthTestCase(test.TestCase):
|
||||
super(ConsoleauthTestCase, self).setUp()
|
||||
self.manager = utils.import_object(FLAGS.consoleauth_manager)
|
||||
self.context = context.get_admin_context()
|
||||
self.old_ttl = FLAGS.console_token_ttl
|
||||
|
||||
def tearDown(self):
|
||||
super(ConsoleauthTestCase, self).tearDown()
|
||||
FLAGS.console_token_ttl = self.old_ttl
|
||||
|
||||
def test_tokens_expire(self):
|
||||
"""Test that tokens expire correctly."""
|
||||
token = 'mytok'
|
||||
FLAGS.console_token_ttl = 1
|
||||
self.flags(console_token_ttl=1)
|
||||
self.manager.authorize_console(self.context, token, 'novnc',
|
||||
'127.0.0.1', 'host', '')
|
||||
self.assertTrue(self.manager.check_token(self.context, token))
|
||||
|
@ -17,7 +17,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import exceptions
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
@ -26,88 +25,18 @@ from nova.openstack.common import cfg
|
||||
from nova import test
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(cfg.StrOpt('flags_unittest',
|
||||
default='foo',
|
||||
help='for testing purposes only'))
|
||||
|
||||
test_opts = [
|
||||
cfg.StrOpt('string', default='default', help='desc'),
|
||||
cfg.IntOpt('int', default=1, help='desc'),
|
||||
cfg.BoolOpt('false', default=False, help='desc'),
|
||||
cfg.BoolOpt('true', default=True, help='desc'),
|
||||
]
|
||||
|
||||
float_opt = cfg.FloatOpt('float', default=6.66, help='desc')
|
||||
multistr_opt = cfg.MultiStrOpt('multi', default=['blaa'], help='desc')
|
||||
list_opt = cfg.ListOpt('list', default=['foo'], help='desc')
|
||||
FLAGS.register_opt(cfg.StrOpt('flags_unittest',
|
||||
default='foo',
|
||||
help='for testing purposes only'))
|
||||
|
||||
|
||||
class FlagsTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(FlagsTestCase, self).setUp()
|
||||
self.FLAGS = flags.FlagValues()
|
||||
self.FLAGS = flags.NovaConfigOpts()
|
||||
self.global_FLAGS = flags.FLAGS
|
||||
|
||||
def test_define(self):
|
||||
self.FLAGS.add_cli_options(test_opts)
|
||||
|
||||
self.assert_(self.FLAGS['string'])
|
||||
self.assert_(self.FLAGS['int'])
|
||||
self.assert_(self.FLAGS['false'])
|
||||
self.assert_(self.FLAGS['true'])
|
||||
self.assertEqual(self.FLAGS.string, 'default')
|
||||
self.assertEqual(self.FLAGS.int, 1)
|
||||
self.assertEqual(self.FLAGS.false, False)
|
||||
self.assertEqual(self.FLAGS.true, True)
|
||||
|
||||
argv = ['flags_test',
|
||||
'--string', 'foo',
|
||||
'--int', '2',
|
||||
'--false',
|
||||
'--notrue']
|
||||
|
||||
self.FLAGS(argv)
|
||||
self.assertEqual(self.FLAGS.string, 'foo')
|
||||
self.assertEqual(self.FLAGS.int, 2)
|
||||
self.assertEqual(self.FLAGS.false, True)
|
||||
self.assertEqual(self.FLAGS.true, False)
|
||||
|
||||
def test_define_float(self):
|
||||
self.FLAGS.add_cli_options(test_opts)
|
||||
self.FLAGS.add_option(float_opt)
|
||||
self.assertEqual(self.FLAGS.float, 6.66)
|
||||
|
||||
def test_define_multistring(self):
|
||||
self.FLAGS.add_cli_option(multistr_opt)
|
||||
|
||||
self.assert_(self.FLAGS['multi'])
|
||||
self.assertEqual(self.FLAGS.multi, ['blaa'])
|
||||
|
||||
argv = ['flags_test', '--multi', 'foo', '--multi', 'bar']
|
||||
self.FLAGS(argv)
|
||||
|
||||
self.assertEqual(self.FLAGS.multi, ['foo', 'bar'])
|
||||
|
||||
def test_define_list(self):
|
||||
self.FLAGS.add_cli_option(list_opt)
|
||||
|
||||
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'])
|
||||
|
||||
def test_error(self):
|
||||
self.FLAGS.add_cli_option(float_opt)
|
||||
|
||||
self.assertEqual(self.FLAGS.float, 6.66)
|
||||
|
||||
argv = ['flags_test', '--float=foo']
|
||||
self.assertRaises(exceptions.SystemExit, self.FLAGS, argv)
|
||||
|
||||
def test_declare(self):
|
||||
self.assert_('answer' not in self.global_FLAGS)
|
||||
flags.DECLARE('answer', 'nova.tests.declare_flags')
|
||||
@ -115,7 +44,7 @@ class FlagsTestCase(test.TestCase):
|
||||
self.assertEqual(self.global_FLAGS.answer, 42)
|
||||
|
||||
# Make sure we don't overwrite anything
|
||||
self.global_FLAGS.answer = 256
|
||||
self.global_FLAGS.set_override('answer', 256)
|
||||
self.assertEqual(self.global_FLAGS.answer, 256)
|
||||
flags.DECLARE('answer', 'nova.tests.declare_flags')
|
||||
self.assertEqual(self.global_FLAGS.answer, 256)
|
||||
@ -135,48 +64,51 @@ class FlagsTestCase(test.TestCase):
|
||||
self.assertEqual(self.global_FLAGS.runtime_answer, 54)
|
||||
|
||||
def test_long_vs_short_flags(self):
|
||||
self.global_FLAGS.Reset()
|
||||
self.global_FLAGS.add_cli_option(cfg.StrOpt('duplicate_answer_long',
|
||||
default='val',
|
||||
help='desc'))
|
||||
self.global_FLAGS.reset()
|
||||
self.global_FLAGS.register_cli_opt(cfg.StrOpt('duplicate_answer_long',
|
||||
default='val',
|
||||
help='desc'))
|
||||
argv = ['flags_test', '--duplicate_answer=60', 'extra_arg']
|
||||
args = self.global_FLAGS(argv)
|
||||
|
||||
self.assert_('duplicate_answer' not in self.global_FLAGS)
|
||||
self.assert_(self.global_FLAGS.duplicate_answer_long, 60)
|
||||
|
||||
self.global_FLAGS.Reset()
|
||||
self.global_FLAGS.add_cli_option(cfg.IntOpt('duplicate_answer',
|
||||
default=60,
|
||||
help='desc'))
|
||||
self.global_FLAGS.reset()
|
||||
self.global_FLAGS.register_cli_opt(cfg.IntOpt('duplicate_answer',
|
||||
default=60,
|
||||
help='desc'))
|
||||
args = self.global_FLAGS(argv)
|
||||
self.assertEqual(self.global_FLAGS.duplicate_answer, 60)
|
||||
self.assertEqual(self.global_FLAGS.duplicate_answer_long, 'val')
|
||||
|
||||
def test_flag_leak_left(self):
|
||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
||||
FLAGS.flags_unittest = 'bar'
|
||||
self.flags(flags_unittest='bar')
|
||||
self.assertEqual(FLAGS.flags_unittest, 'bar')
|
||||
|
||||
def test_flag_leak_right(self):
|
||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
||||
FLAGS.flags_unittest = 'bar'
|
||||
self.flags(flags_unittest='bar')
|
||||
self.assertEqual(FLAGS.flags_unittest, 'bar')
|
||||
|
||||
def test_flag_overrides(self):
|
||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
||||
self.flags(flags_unittest='bar')
|
||||
self.assertEqual(FLAGS.flags_unittest, 'bar')
|
||||
self.assertEqual(FLAGS['flags_unittest'].value, 'bar')
|
||||
self.assertEqual(FLAGS.FlagValuesDict()['flags_unittest'], 'bar')
|
||||
self.reset_flags()
|
||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
||||
self.assertEqual(FLAGS['flags_unittest'].value, 'foo')
|
||||
self.assertEqual(FLAGS.FlagValuesDict()['flags_unittest'], 'foo')
|
||||
|
||||
def test_flagfile(self):
|
||||
self.FLAGS.add_options(test_opts)
|
||||
self.FLAGS.add_option(multistr_opt)
|
||||
opts = [
|
||||
cfg.StrOpt('string', default='default', help='desc'),
|
||||
cfg.IntOpt('int', default=1, help='desc'),
|
||||
cfg.BoolOpt('false', default=False, help='desc'),
|
||||
cfg.BoolOpt('true', default=True, help='desc'),
|
||||
cfg.MultiStrOpt('multi', default=['blaa'], help='desc'),
|
||||
]
|
||||
|
||||
self.FLAGS.register_opts(opts)
|
||||
|
||||
(fd, path) = tempfile.mkstemp(prefix='nova', suffix='.flags')
|
||||
|
||||
@ -200,15 +132,15 @@ class FlagsTestCase(test.TestCase):
|
||||
os.remove(path)
|
||||
|
||||
def test_defaults(self):
|
||||
self.FLAGS.add_option(cfg.StrOpt('foo', default='bar', help='desc'))
|
||||
self.FLAGS.register_opt(cfg.StrOpt('foo', default='bar', help='desc'))
|
||||
self.assertEqual(self.FLAGS.foo, 'bar')
|
||||
|
||||
self.FLAGS['foo'].SetDefault('blaa')
|
||||
self.FLAGS.set_default('foo', 'blaa')
|
||||
self.assertEqual(self.FLAGS.foo, 'blaa')
|
||||
|
||||
def test_templated_values(self):
|
||||
self.FLAGS.add_option(cfg.StrOpt('foo', default='foo', help='desc'))
|
||||
self.FLAGS.add_option(cfg.StrOpt('bar', default='bar', help='desc'))
|
||||
self.FLAGS.add_option(cfg.StrOpt('blaa',
|
||||
default='$foo$bar', help='desc'))
|
||||
self.FLAGS.register_opt(cfg.StrOpt('foo', default='foo', help='desc'))
|
||||
self.FLAGS.register_opt(cfg.StrOpt('bar', default='bar', help='desc'))
|
||||
self.FLAGS.register_opt(cfg.StrOpt('blaa',
|
||||
default='$foo$bar', help='desc'))
|
||||
self.assertEqual(self.FLAGS.blaa, 'foobar')
|
||||
|
@ -173,7 +173,7 @@ class InstanceTypeTestCase(test.TestCase):
|
||||
|
||||
def test_will_not_get_bad_default_instance_type(self):
|
||||
"""ensures error raised on bad default instance type"""
|
||||
FLAGS.default_instance_type = 'unknown_flavor'
|
||||
self.flags(default_instance_type='unknown_flavor')
|
||||
self.assertRaises(exception.ApiError,
|
||||
instance_types.get_default_instance_type)
|
||||
|
||||
|
@ -939,8 +939,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
"""Confirms pre_block_migration works correctly."""
|
||||
# Replace instances_path since this testcase creates tmpfile
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
store = FLAGS.instances_path
|
||||
FLAGS.instances_path = tmpdir
|
||||
self.flags(instances_path=tmpdir)
|
||||
|
||||
# Test data
|
||||
instance_ref = db.instance_create(self.context, self.test_instance)
|
||||
@ -960,8 +959,6 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
|
||||
shutil.rmtree(tmpdir)
|
||||
db.instance_destroy(self.context, instance_ref['id'])
|
||||
# Restore FLAGS.instances_path
|
||||
FLAGS.instances_path = store
|
||||
|
||||
@test.skip_if(missing_libvirt(), "Test requires libvirt")
|
||||
def test_get_instance_disk_info_works_correctly(self):
|
||||
|
@ -45,7 +45,7 @@ test_service_opts = [
|
||||
help="Port number to bind test service to"),
|
||||
]
|
||||
|
||||
flags.FLAGS.add_options(test_service_opts)
|
||||
flags.FLAGS.register_opts(test_service_opts)
|
||||
|
||||
|
||||
class FakeManager(manager.Manager):
|
||||
|
@ -442,9 +442,9 @@ class LibvirtConnTestCase(_VirtDriverTestCase):
|
||||
|
||||
# Point _VirtDriverTestCase at the right module
|
||||
self.driver_module = nova.virt.libvirt.connection
|
||||
FLAGS.firewall_driver = nova.virt.libvirt.firewall.drivers[0]
|
||||
super(LibvirtConnTestCase, self).setUp()
|
||||
self.flags(rescue_image_id="2",
|
||||
self.flags(firewall_driver=nova.virt.libvirt.firewall.drivers[0],
|
||||
rescue_image_id="2",
|
||||
rescue_kernel_id="3",
|
||||
rescue_ramdisk_id=None)
|
||||
|
||||
|
@ -40,8 +40,7 @@ class VsaTestCase(test.TestCase):
|
||||
self.stubs = stubout.StubOutForTesting()
|
||||
self.vsa_api = vsa.API()
|
||||
|
||||
FLAGS.quota_volumes = 100
|
||||
FLAGS.quota_gigabytes = 10000
|
||||
self.flags(quota_volumes=100, quota_gigabytes=10000)
|
||||
|
||||
self.context = context.get_admin_context()
|
||||
|
||||
@ -119,7 +118,7 @@ class VsaTestCase(test.TestCase):
|
||||
def test_vsa_create_with_storage(self, multi_vol_creation=True):
|
||||
"""Test creation of VSA with BE storage"""
|
||||
|
||||
FLAGS.vsa_multi_vol_creation = multi_vol_creation
|
||||
self.flags(vsa_multi_vol_creation=multi_vol_creation)
|
||||
|
||||
param = {'storage': [{'drive_name': 'SATA_500_7200',
|
||||
'num_drives': 3}]}
|
||||
@ -152,7 +151,7 @@ class VsaTestCase(test.TestCase):
|
||||
|
||||
def test_vsa_generate_user_data(self):
|
||||
|
||||
FLAGS.vsa_multi_vol_creation = False
|
||||
self.flags(vsa_multi_vol_creation=False)
|
||||
param = {'display_name': 'VSA name test',
|
||||
'display_description': 'VSA desc test',
|
||||
'vc_count': 2,
|
||||
|
@ -57,8 +57,7 @@ ISO_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
||||
PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
|
||||
FLAGS.add_option(
|
||||
FLAGS.register_opt(
|
||||
cfg.BoolOpt('disable_process_locking', default=False,
|
||||
help='Whether to disable inter-process locks'))
|
||||
|
||||
@ -572,7 +571,7 @@ class LazyPluggable(object):
|
||||
|
||||
def __get_backend(self):
|
||||
if not self.__backend:
|
||||
backend_name = self.__pivot.value
|
||||
backend_name = FLAGS[self.__pivot]
|
||||
if backend_name not in self.__backends:
|
||||
raise exception.Error(_('Invalid backend: %s') % backend_name)
|
||||
|
||||
|
@ -23,13 +23,13 @@ from nova import exception
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
global_opts = [
|
||||
baremetal_opts = [
|
||||
cfg.StrOpt('baremetal_driver',
|
||||
default='tilera',
|
||||
help='Bare-metal driver runs on')
|
||||
]
|
||||
|
||||
FLAGS.add_options(global_opts)
|
||||
FLAGS.register_opts(baremetal_opts)
|
||||
|
||||
|
||||
def get_baremetal_nodes():
|
||||
|
@ -58,7 +58,7 @@ LOG = logging.getLogger('nova.virt.baremetal.proxy')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
global_opts = [
|
||||
baremetal_opts = [
|
||||
cfg.StrOpt('baremetal_injected_network_template',
|
||||
default=utils.abspath('virt/interfaces.template'),
|
||||
help='Template file for injected network'),
|
||||
@ -73,7 +73,7 @@ global_opts = [
|
||||
help='Whether to allow in project network traffic')
|
||||
]
|
||||
|
||||
FLAGS.add_options(global_opts)
|
||||
FLAGS.register_opts(baremetal_opts)
|
||||
|
||||
|
||||
def get_connection(read_only):
|
||||
|
@ -35,13 +35,13 @@ from nova import utils
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
global_opts = [
|
||||
tilera_opts = [
|
||||
cfg.StrOpt('tile_monitor',
|
||||
default='/usr/local/TileraMDE/bin/tile-monitor',
|
||||
help='Tilera command line program for Bare-metal driver')
|
||||
]
|
||||
|
||||
FLAGS.add_options(global_opts)
|
||||
FLAGS.register_opts(tilera_opts)
|
||||
|
||||
LOG = logging.getLogger('nova.virt.tilera')
|
||||
|
||||
|
@ -72,7 +72,7 @@ disk_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(disk_opts)
|
||||
FLAGS.register_opts(disk_opts)
|
||||
|
||||
_MKFS_COMMAND = {}
|
||||
_DEFAULT_MKFS_COMMAND = None
|
||||
|
@ -34,7 +34,7 @@ nbd_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(nbd_opts)
|
||||
FLAGS.register_opts(nbd_opts)
|
||||
|
||||
|
||||
class Mount(mount.Mount):
|
||||
|
@ -33,7 +33,7 @@ allow_same_net_traffic_opt = cfg.BoolOpt('allow_same_net_traffic',
|
||||
help='Whether to allow network traffic from same network')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(allow_same_net_traffic_opt)
|
||||
FLAGS.register_opt(allow_same_net_traffic_opt)
|
||||
|
||||
|
||||
class FirewallDriver(object):
|
||||
|
@ -149,7 +149,7 @@ libvirt_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(libvirt_opts)
|
||||
FLAGS.register_opts(libvirt_opts)
|
||||
|
||||
flags.DECLARE('live_migration_retry_count', 'nova.compute.manager')
|
||||
flags.DECLARE('vncserver_proxyclient_address', 'nova.vnc')
|
||||
@ -190,7 +190,7 @@ class LibvirtConnection(driver.ComputeDriver):
|
||||
self.container = None
|
||||
self.read_only = read_only
|
||||
if FLAGS.firewall_driver not in firewall.drivers:
|
||||
FLAGS['firewall_driver'].SetDefault(firewall.drivers[0])
|
||||
FLAGS.set_default('firewall_driver', firewall.drivers[0])
|
||||
fw_class = utils.import_class(FLAGS.firewall_driver)
|
||||
self.firewall_driver = fw_class(get_connection=self._get_connection)
|
||||
self.vif_driver = utils.import_object(FLAGS.libvirt_vif_driver)
|
||||
|
@ -54,7 +54,7 @@ imagecache_opts = [
|
||||
|
||||
flags.DECLARE('instances_path', 'nova.compute.manager')
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(imagecache_opts)
|
||||
FLAGS.register_opts(imagecache_opts)
|
||||
|
||||
|
||||
def read_stored_checksum(base_file):
|
||||
|
@ -36,7 +36,7 @@ qemu_img_opt = cfg.StrOpt('qemu_img',
|
||||
help='binary to use for qemu-img commands')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(qemu_img_opt)
|
||||
FLAGS.register_opt(qemu_img_opt)
|
||||
|
||||
|
||||
def execute(*args, **kwargs):
|
||||
|
@ -36,7 +36,7 @@ libvirt_ovs_bridge_opt = cfg.StrOpt('libvirt_ovs_bridge',
|
||||
help='Name of Integration Bridge used by Open vSwitch')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(libvirt_ovs_bridge_opt)
|
||||
FLAGS.register_opt(libvirt_ovs_bridge_opt)
|
||||
|
||||
|
||||
class LibvirtBridgeDriver(VIFDriver):
|
||||
|
@ -27,7 +27,7 @@ from nova.virt.vmwareapi import network_utils
|
||||
LOG = logging.getLogger("nova.virt.vmwareapi.vif")
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS['vmwareapi_vlan_interface'].SetDefault('vmnic0')
|
||||
FLAGS.set_default('vmwareapi_vlan_interface', 'vmnic0')
|
||||
|
||||
|
||||
class VMWareVlanBridgeDriver(VIFDriver):
|
||||
|
@ -42,7 +42,7 @@ vmwareapi_wsdl_loc_opt = cfg.StrOpt('vmwareapi_wsdl_loc',
|
||||
'Refer readme-vmware to setup')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(vmwareapi_wsdl_loc_opt)
|
||||
FLAGS.register_opt(vmwareapi_wsdl_loc_opt)
|
||||
|
||||
|
||||
if suds:
|
||||
|
@ -43,7 +43,7 @@ vmware_vif_driver_opt = cfg.StrOpt('vmware_vif_driver',
|
||||
help='The VMWare VIF driver to configure the VIFs.')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(vmware_vif_driver_opt)
|
||||
FLAGS.register_opt(vmware_vif_driver_opt)
|
||||
|
||||
LOG = logging.getLogger("nova.virt.vmwareapi.vmops")
|
||||
|
||||
|
@ -80,7 +80,7 @@ vmwareapi_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(vmwareapi_opts)
|
||||
FLAGS.register_opts(vmwareapi_opts)
|
||||
|
||||
TIME_BETWEEN_API_CALL_RETRIES = 2.0
|
||||
|
||||
|
@ -32,7 +32,7 @@ xenapi_ovs_integration_bridge_opt = cfg.StrOpt('xenapi_ovs_integration_bridge',
|
||||
help='Name of Integration Bridge used by Open vSwitch')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(xenapi_ovs_integration_bridge_opt)
|
||||
FLAGS.register_opt(xenapi_ovs_integration_bridge_opt)
|
||||
LOG = logging.getLogger("nova.virt.xenapi.vif")
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ xenapi_vm_utils_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(xenapi_vm_utils_opts)
|
||||
FLAGS.register_opts(xenapi_vm_utils_opts)
|
||||
|
||||
XENAPI_POWER_STATE = {
|
||||
'Halted': power_state.SHUTDOWN,
|
||||
|
@ -72,7 +72,7 @@ xenapi_vmops_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(xenapi_vmops_opts)
|
||||
FLAGS.register_opts(xenapi_vmops_opts)
|
||||
|
||||
flags.DECLARE('vncserver_proxyclient_address', 'nova.vnc')
|
||||
|
||||
@ -107,7 +107,7 @@ class VMOps(object):
|
||||
self.poll_rescue_last_ran = None
|
||||
VMHelper.XenAPI = self.XenAPI
|
||||
if FLAGS.firewall_driver not in firewall.drivers:
|
||||
FLAGS['firewall_driver'].SetDefault(firewall.drivers[0])
|
||||
FLAGS.set_default('firewall_driver', firewall.drivers[0])
|
||||
fw_class = utils.import_class(FLAGS.firewall_driver)
|
||||
self.firewall_driver = fw_class(xenapi_session=self._session)
|
||||
vif_impl = utils.import_class(FLAGS.xenapi_vif_driver)
|
||||
|
@ -152,7 +152,7 @@ xenapi_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(xenapi_opts)
|
||||
FLAGS.register_opts(xenapi_opts)
|
||||
|
||||
|
||||
def get_connection(_):
|
||||
|
@ -47,4 +47,4 @@ vnc_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(vnc_opts)
|
||||
FLAGS.register_opts(vnc_opts)
|
||||
|
@ -47,7 +47,7 @@ xvp_proxy_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(xvp_proxy_opts)
|
||||
FLAGS.register_opts(xvp_proxy_opts)
|
||||
|
||||
flags.DECLARE('consoleauth_topic', 'nova.consoleauth')
|
||||
|
||||
|
@ -63,7 +63,7 @@ volume_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(volume_opts)
|
||||
FLAGS.register_opts(volume_opts)
|
||||
|
||||
|
||||
class VolumeDriver(object):
|
||||
|
@ -30,7 +30,7 @@ iscsi_helper_opt = cfg.StrOpt('iscsi_helper',
|
||||
help='iscsi target user-land tool to use')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(iscsi_helper_opt)
|
||||
FLAGS.register_opt(iscsi_helper_opt)
|
||||
|
||||
|
||||
class TargetAdmin(object):
|
||||
|
@ -67,7 +67,7 @@ volume_manager_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(volume_manager_opts)
|
||||
FLAGS.register_opts(volume_manager_opts)
|
||||
|
||||
|
||||
class VolumeManager(manager.SchedulerDependentManager):
|
||||
|
@ -75,7 +75,7 @@ san_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(san_opts)
|
||||
FLAGS.register_opts(san_opts)
|
||||
|
||||
|
||||
class SanISCSIDriver(ISCSIDriver):
|
||||
|
@ -62,7 +62,7 @@ vsa_opts = [
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_options(vsa_opts)
|
||||
FLAGS.register_opts(vsa_opts)
|
||||
|
||||
LOG = logging.getLogger('nova.vsa')
|
||||
|
||||
|
@ -40,7 +40,7 @@ vsa_driver_opt = cfg.StrOpt('vsa_driver',
|
||||
help='Driver to use for controlling VSAs')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.add_option(vsa_driver_opt)
|
||||
FLAGS.register_opt(vsa_driver_opt)
|
||||
|
||||
LOG = logging.getLogger('nova.vsa.manager')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user