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
1aabb70080
commit
6d7dfd27ec
@ -55,7 +55,7 @@ delete_exchange_opt = \
|
|||||||
help='delete nova exchange too.')
|
help='delete nova exchange too.')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_option(delete_exchange_opt)
|
FLAGS.register_cli_opt(delete_exchange_opt)
|
||||||
|
|
||||||
|
|
||||||
def delete_exchange(exch):
|
def delete_exchange(exch):
|
||||||
|
@ -57,7 +57,7 @@ direct_api_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
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.
|
# An example of an API that only exposes read-only methods.
|
||||||
|
@ -2201,7 +2201,7 @@ class ConfigCommands(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
for key, value in FLAGS.FlagValuesDict().iteritems():
|
for key, value in FLAGS.iteritems():
|
||||||
if value is not None:
|
if value is not None:
|
||||||
print '%s = %s' % (key, value)
|
print '%s = %s' % (key, value)
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ ldap_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(ldap_opts)
|
FLAGS.register_opts(ldap_opts)
|
||||||
|
|
||||||
LOG = logging.getLogger("nova.ldapdriver")
|
LOG = logging.getLogger("nova.ldapdriver")
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ class LdapDriver(object):
|
|||||||
def __role_to_dn(self, role, project_id=None):
|
def __role_to_dn(self, role, project_id=None):
|
||||||
"""Convert role to corresponding dn"""
|
"""Convert role to corresponding dn"""
|
||||||
if project_id is None:
|
if project_id is None:
|
||||||
return FLAGS.__getitem__("ldap_%s" % role).value
|
return FLAGS["ldap_%s" % role]
|
||||||
else:
|
else:
|
||||||
project_dn = self.__project_to_dn(project_id)
|
project_dn = self.__project_to_dn(project_id)
|
||||||
return 'cn=%s,%s' % (role, project_dn)
|
return 'cn=%s,%s' % (role, project_dn)
|
||||||
|
@ -92,7 +92,7 @@ auth_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(auth_opts)
|
FLAGS.register_opts(auth_opts)
|
||||||
|
|
||||||
flags.DECLARE('osapi_compute_listen_port', 'nova.service')
|
flags.DECLARE('osapi_compute_listen_port', 'nova.service')
|
||||||
|
|
||||||
|
100
nova/flags.py
100
nova/flags.py
@ -3,7 +3,7 @@
|
|||||||
# Copyright 2010 United States Government as represented by the
|
# Copyright 2010 United States Government as represented by the
|
||||||
# Administrator of the National Aeronautics and Space Administration.
|
# Administrator of the National Aeronautics and Space Administration.
|
||||||
# All Rights Reserved.
|
# 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
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
@ -30,97 +30,21 @@ import os
|
|||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import gflags
|
|
||||||
|
|
||||||
from nova.compat import flagfile
|
from nova.compat import flagfile
|
||||||
from nova.openstack.common import cfg
|
from nova.openstack.common import cfg
|
||||||
|
|
||||||
|
|
||||||
class FlagValues(object):
|
class NovaConfigOpts(cfg.ConfigOpts):
|
||||||
class Flag:
|
|
||||||
def __init__(self, name, value, update_default=None):
|
|
||||||
self.name = name
|
|
||||||
self.value = value
|
|
||||||
self._update_default = update_default
|
|
||||||
|
|
||||||
def SetDefault(self, default):
|
def __init__(self, *args, **kwargs):
|
||||||
if self._update_default:
|
super(NovaConfigOpts, self).__init__(*args, **kwargs)
|
||||||
self._update_default(self.name, default)
|
self.disable_interspersed_args()
|
||||||
|
|
||||||
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 __call__(self, argv):
|
def __call__(self, argv):
|
||||||
self.Reset()
|
with flagfile.handle_flagfiles_managed(argv[1:]) as args:
|
||||||
self._args = argv[1:]
|
return argv[:1] + super(NovaConfigOpts, self).__call__(args)
|
||||||
self._parse()
|
|
||||||
return [argv[0]] + self._extra
|
|
||||||
|
|
||||||
def __getattr__(self, name):
|
FLAGS = NovaConfigOpts()
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
class UnrecognizedFlag(Exception):
|
class UnrecognizedFlag(Exception):
|
||||||
@ -191,9 +115,9 @@ debug_opts = [
|
|||||||
help='use a fake rabbit'),
|
help='use a fake rabbit'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS.add_cli_options(log_opts)
|
FLAGS.register_cli_opts(log_opts)
|
||||||
FLAGS.add_cli_options(core_opts)
|
FLAGS.register_cli_opts(core_opts)
|
||||||
FLAGS.add_cli_options(debug_opts)
|
FLAGS.register_cli_opts(debug_opts)
|
||||||
|
|
||||||
global_opts = [
|
global_opts = [
|
||||||
cfg.StrOpt('my_ip',
|
cfg.StrOpt('my_ip',
|
||||||
@ -523,4 +447,4 @@ global_opts = [
|
|||||||
help='Host reserved for specific images'),
|
help='Host reserved for specific images'),
|
||||||
]
|
]
|
||||||
|
|
||||||
FLAGS.add_options(global_opts)
|
FLAGS.register_opts(global_opts)
|
||||||
|
@ -82,7 +82,7 @@ log_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(log_opts)
|
FLAGS.register_opts(log_opts)
|
||||||
|
|
||||||
# A list of things we want to replicate from logging.
|
# A list of things we want to replicate from logging.
|
||||||
# levels
|
# levels
|
||||||
|
@ -33,7 +33,7 @@ notifier_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(notifier_opts)
|
FLAGS.register_opts(notifier_opts)
|
||||||
|
|
||||||
WARN = 'WARN'
|
WARN = 'WARN'
|
||||||
INFO = 'INFO'
|
INFO = 'INFO'
|
||||||
|
@ -25,7 +25,7 @@ list_notifier_drivers_opt = cfg.MultiStrOpt('list_notifier_drivers',
|
|||||||
help='List of drivers to send notifications')
|
help='List of drivers to send notifications')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_option(list_notifier_drivers_opt)
|
FLAGS.register_opt(list_notifier_drivers_opt)
|
||||||
|
|
||||||
LOG = logging.getLogger('nova.notifier.list_notifier')
|
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')
|
help='RabbitMQ topic used for Nova notifications')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_option(notification_topic_opt)
|
FLAGS.register_opt(notification_topic_opt)
|
||||||
|
|
||||||
|
|
||||||
def notify(message):
|
def notify(message):
|
||||||
|
@ -34,7 +34,7 @@ policy_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(policy_opts)
|
FLAGS.register_opts(policy_opts)
|
||||||
|
|
||||||
_POLICY_PATH = None
|
_POLICY_PATH = None
|
||||||
_POLICY_CACHE = {}
|
_POLICY_CACHE = {}
|
||||||
|
@ -57,7 +57,7 @@ quota_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(quota_opts)
|
FLAGS.register_opts(quota_opts)
|
||||||
|
|
||||||
|
|
||||||
def _get_default_quotas():
|
def _get_default_quotas():
|
||||||
|
@ -28,7 +28,7 @@ rpc_backend_opt = cfg.StrOpt('rpc_backend',
|
|||||||
help="The messaging module to use, defaults to kombu.")
|
help="The messaging module to use, defaults to kombu.")
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_option(rpc_backend_opt)
|
FLAGS.register_opt(rpc_backend_opt)
|
||||||
|
|
||||||
|
|
||||||
def create_connection(new=True):
|
def create_connection(new=True):
|
||||||
|
@ -39,7 +39,7 @@ rpc_opts = [
|
|||||||
help='Seconds to wait for a response from call or multicall'),
|
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):
|
class RemoteError(exception.NovaException):
|
||||||
|
@ -78,7 +78,7 @@ qpid_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(qpid_opts)
|
FLAGS.register_opts(qpid_opts)
|
||||||
|
|
||||||
|
|
||||||
class ConsumerBase(object):
|
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.')
|
help='When True, routing to child zones will occur.')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_option(enable_zone_routing_opt)
|
FLAGS.register_opt(enable_zone_routing_opt)
|
||||||
|
|
||||||
LOG = logging.getLogger('nova.scheduler.api')
|
LOG = logging.getLogger('nova.scheduler.api')
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ scheduler_driver_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(scheduler_driver_opts)
|
FLAGS.register_opts(scheduler_driver_opts)
|
||||||
|
|
||||||
flags.DECLARE('instances_path', 'nova.compute.manager')
|
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')
|
help='Virtual CPU to Physical CPU allocation ratio')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_option(cpu_allocation_ratio_opt)
|
FLAGS.register_opt(cpu_allocation_ratio_opt)
|
||||||
|
|
||||||
|
|
||||||
class CoreFilter(abstract_filter.AbstractHostFilter):
|
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")
|
help="virtual ram to physical ram allocation ratio")
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_option(ram_allocation_ratio_opt)
|
FLAGS.register_opt(ram_allocation_ratio_opt)
|
||||||
|
|
||||||
|
|
||||||
class RamFilter(abstract_filter.AbstractHostFilter):
|
class RamFilter(abstract_filter.AbstractHostFilter):
|
||||||
|
@ -47,7 +47,7 @@ host_manager_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(host_manager_opts)
|
FLAGS.register_opts(host_manager_opts)
|
||||||
|
|
||||||
LOG = logging.getLogger('nova.scheduler.host_manager')
|
LOG = logging.getLogger('nova.scheduler.host_manager')
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ least_cost_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
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
|
# 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)
|
# 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')
|
help='Default driver to use for the scheduler')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_option(scheduler_driver_opt)
|
FLAGS.register_opt(scheduler_driver_opt)
|
||||||
|
|
||||||
|
|
||||||
class SchedulerManager(manager.Manager):
|
class SchedulerManager(manager.Manager):
|
||||||
|
@ -37,7 +37,7 @@ multi_scheduler_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
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.
|
# A mapping of methods to topics so we can figure out which driver to use.
|
||||||
_METHOD_MAP = {'run_instance': 'compute',
|
_METHOD_MAP = {'run_instance': 'compute',
|
||||||
|
@ -35,7 +35,7 @@ scheduler_json_config_location_opt = cfg.StrOpt(
|
|||||||
help='Absolute path to scheduler configuration JSON file.')
|
help='Absolute path to scheduler configuration JSON file.')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
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')
|
LOG = logging.getLogger('nova.scheduler.scheduler_options')
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ simple_scheduler_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(simple_scheduler_opts)
|
FLAGS.register_opts(simple_scheduler_opts)
|
||||||
|
|
||||||
|
|
||||||
class SimpleScheduler(chance.ChanceScheduler):
|
class SimpleScheduler(chance.ChanceScheduler):
|
||||||
|
@ -48,7 +48,7 @@ vsa_scheduler_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(vsa_scheduler_opts)
|
FLAGS.register_opts(vsa_scheduler_opts)
|
||||||
|
|
||||||
|
|
||||||
def BYTES_TO_GB(bytes):
|
def BYTES_TO_GB(bytes):
|
||||||
|
@ -40,7 +40,7 @@ zone_manager_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(zone_manager_opts)
|
FLAGS.register_opts(zone_manager_opts)
|
||||||
|
|
||||||
LOG = logging.getLogger('nova.scheduler.zone_manager')
|
LOG = logging.getLogger('nova.scheduler.zone_manager')
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ service_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(service_opts)
|
FLAGS.register_opts(service_opts)
|
||||||
|
|
||||||
|
|
||||||
class Launcher(object):
|
class Launcher(object):
|
||||||
|
13
nova/test.py
13
nova/test.py
@ -53,7 +53,7 @@ test_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(test_opts)
|
FLAGS.register_opts(test_opts)
|
||||||
|
|
||||||
LOG = log.getLogger('nova.tests')
|
LOG = log.getLogger('nova.tests')
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ class TestCase(unittest.TestCase):
|
|||||||
self.stubs = stubout.StubOutForTesting()
|
self.stubs = stubout.StubOutForTesting()
|
||||||
self.injected = []
|
self.injected = []
|
||||||
self._services = []
|
self._services = []
|
||||||
self._original_flags = FLAGS.FlagValuesDict()
|
self._overridden_opts = []
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""Runs after each test method to tear down test environment."""
|
"""Runs after each test method to tear down test environment."""
|
||||||
@ -176,7 +176,8 @@ class TestCase(unittest.TestCase):
|
|||||||
def flags(self, **kw):
|
def flags(self, **kw):
|
||||||
"""Override flag variables for a test."""
|
"""Override flag variables for a test."""
|
||||||
for k, v in kw.iteritems():
|
for k, v in kw.iteritems():
|
||||||
setattr(FLAGS, k, v)
|
FLAGS.set_override(k, v)
|
||||||
|
self._overridden_opts.append(k)
|
||||||
|
|
||||||
def reset_flags(self):
|
def reset_flags(self):
|
||||||
"""Resets all flag variables for the test.
|
"""Resets all flag variables for the test.
|
||||||
@ -184,9 +185,9 @@ class TestCase(unittest.TestCase):
|
|||||||
Runs after each test.
|
Runs after each test.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
FLAGS.Reset()
|
for k in self._overridden_opts:
|
||||||
for k, v in self._original_flags.iteritems():
|
FLAGS.set_override(k, None)
|
||||||
setattr(FLAGS, k, v)
|
self._overridden_opts = []
|
||||||
|
|
||||||
def start_service(self, name, host=None, **kwargs):
|
def start_service(self, name, host=None, **kwargs):
|
||||||
host = host and host or uuid.uuid4().hex
|
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)
|
absdir = os.path.abspath(reldir)
|
||||||
sys.path.insert(0, absdir)
|
sys.path.insert(0, absdir)
|
||||||
|
|
||||||
|
from nova import flags
|
||||||
from nova import log as logging
|
from nova import log as logging
|
||||||
|
from nova.openstack.common import cfg
|
||||||
|
|
||||||
|
|
||||||
class _AnsiColorizer(object):
|
class _AnsiColorizer(object):
|
||||||
@ -341,18 +343,15 @@ class NovaTestRunner(core.TextTestRunner):
|
|||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
flags.FLAGS.register_cli_opt(cfg.BoolOpt('hide-elapsed', default=False))
|
||||||
|
argv = flags.FLAGS(sys.argv)
|
||||||
logging.setup()
|
logging.setup()
|
||||||
|
|
||||||
# If any argument looks like a test name but doesn't have "nova.tests" in
|
# 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
|
# front of it, automatically add that so we don't have to type as much
|
||||||
show_elapsed = True
|
for i, arg in enumerate(argv):
|
||||||
argv = []
|
if arg.startswith('test_'):
|
||||||
for x in sys.argv:
|
argv[i] = append('nova.tests.%s' % arg)
|
||||||
if x.startswith('test_'):
|
|
||||||
argv.append('nova.tests.%s' % x)
|
|
||||||
elif x.startswith('--hide-elapsed'):
|
|
||||||
show_elapsed = False
|
|
||||||
else:
|
|
||||||
argv.append(x)
|
|
||||||
|
|
||||||
testdir = os.path.abspath(os.path.join("nova", "tests"))
|
testdir = os.path.abspath(os.path.join("nova", "tests"))
|
||||||
c = config.Config(stream=sys.stdout,
|
c = config.Config(stream=sys.stdout,
|
||||||
@ -364,7 +363,7 @@ def run():
|
|||||||
runner = NovaTestRunner(stream=c.stream,
|
runner = NovaTestRunner(stream=c.stream,
|
||||||
verbosity=c.verbosity,
|
verbosity=c.verbosity,
|
||||||
config=c,
|
config=c,
|
||||||
show_elapsed=show_elapsed)
|
show_elapsed=not flags.FLAGS.hide_elapsed)
|
||||||
sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
|
sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ fake_domains = [{'status': 1, 'name': 'instance-00000001',
|
|||||||
class DomainReadWriteTestCase(test.TestCase):
|
class DomainReadWriteTestCase(test.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.flags(baremetal_driver='fake')
|
|
||||||
super(DomainReadWriteTestCase, self).setUp()
|
super(DomainReadWriteTestCase, self).setUp()
|
||||||
|
self.flags(baremetal_driver='fake')
|
||||||
|
|
||||||
def test_read_domain_with_empty_list(self):
|
def test_read_domain_with_empty_list(self):
|
||||||
"""Read a file that contains no domains"""
|
"""Read a file that contains no domains"""
|
||||||
@ -143,8 +143,8 @@ class DomainReadWriteTestCase(test.TestCase):
|
|||||||
class BareMetalDomTestCase(test.TestCase):
|
class BareMetalDomTestCase(test.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.flags(baremetal_driver='fake')
|
|
||||||
super(BareMetalDomTestCase, self).setUp()
|
super(BareMetalDomTestCase, self).setUp()
|
||||||
|
self.flags(baremetal_driver='fake')
|
||||||
# Stub out utils.execute
|
# Stub out utils.execute
|
||||||
self.stubs = stubout.StubOutForTesting()
|
self.stubs = stubout.StubOutForTesting()
|
||||||
fake_utils.stub_out_utils_execute(self.stubs)
|
fake_utils.stub_out_utils_execute(self.stubs)
|
||||||
@ -263,8 +263,8 @@ class ProxyBareMetalTestCase(test.TestCase):
|
|||||||
'instance_type_id': '5'} # m1.small
|
'instance_type_id': '5'} # m1.small
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.flags(baremetal_driver='fake')
|
|
||||||
super(ProxyBareMetalTestCase, self).setUp()
|
super(ProxyBareMetalTestCase, self).setUp()
|
||||||
|
self.flags(baremetal_driver='fake')
|
||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
fake_utils.stub_out_utils_execute(self.stubs)
|
fake_utils.stub_out_utils_execute(self.stubs)
|
||||||
|
|
||||||
|
@ -20,4 +20,4 @@ from nova import flags
|
|||||||
from nova.openstack.common import cfg
|
from nova.openstack.common import cfg
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
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 = flags.FLAGS
|
||||||
|
|
||||||
flags.DECLARE('volume_driver', 'nova.volume.manager')
|
flags.DECLARE('volume_driver', 'nova.volume.manager')
|
||||||
FLAGS['volume_driver'].SetDefault('nova.volume.driver.FakeISCSIDriver')
|
FLAGS.set_default('volume_driver', 'nova.volume.driver.FakeISCSIDriver')
|
||||||
FLAGS['connection_type'].SetDefault('fake')
|
FLAGS.set_default('connection_type', 'fake')
|
||||||
FLAGS['fake_rabbit'].SetDefault(True)
|
FLAGS.set_default('fake_rabbit', True)
|
||||||
FLAGS['rpc_backend'].SetDefault('nova.rpc.impl_fake')
|
FLAGS.set_default('rpc_backend', 'nova.rpc.impl_fake')
|
||||||
flags.DECLARE('auth_driver', 'nova.auth.manager')
|
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('network_size', 'nova.network.manager')
|
||||||
flags.DECLARE('num_networks', 'nova.network.manager')
|
flags.DECLARE('num_networks', 'nova.network.manager')
|
||||||
flags.DECLARE('fake_network', 'nova.network.manager')
|
flags.DECLARE('fake_network', 'nova.network.manager')
|
||||||
FLAGS['network_size'].SetDefault(8)
|
FLAGS.set_default('network_size', 8)
|
||||||
FLAGS['num_networks'].SetDefault(2)
|
FLAGS.set_default('num_networks', 2)
|
||||||
FLAGS['fake_network'].SetDefault(True)
|
FLAGS.set_default('fake_network', True)
|
||||||
FLAGS['image_service'].SetDefault('nova.image.fake.FakeImageService')
|
FLAGS.set_default('image_service', 'nova.image.fake.FakeImageService')
|
||||||
flags.DECLARE('iscsi_num_targets', 'nova.volume.driver')
|
flags.DECLARE('iscsi_num_targets', 'nova.volume.driver')
|
||||||
FLAGS['iscsi_num_targets'].SetDefault(8)
|
FLAGS.set_default('iscsi_num_targets', 8)
|
||||||
FLAGS['verbose'].SetDefault(True)
|
FLAGS.set_default('verbose', True)
|
||||||
FLAGS['sqlite_db'].SetDefault("tests.sqlite")
|
FLAGS.set_default('sqlite_db', "tests.sqlite")
|
||||||
FLAGS['use_ipv6'].SetDefault(True)
|
FLAGS.set_default('use_ipv6', True)
|
||||||
FLAGS['flat_network_bridge'].SetDefault('br100')
|
FLAGS.set_default('flat_network_bridge', 'br100')
|
||||||
FLAGS['sqlite_synchronous'].SetDefault(False)
|
FLAGS.set_default('sqlite_synchronous', False)
|
||||||
flags.DECLARE('policy_file', 'nova.policy')
|
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
|
from nova.openstack.common import cfg
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
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).\
|
vpn=False).\
|
||||||
AndRaise(quantum_client.QuantumServerException())
|
AndRaise(quantum_client.QuantumServerException())
|
||||||
|
|
||||||
FLAGS.stub_network = False
|
self.flags(stub_network=False)
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
|
@ -42,16 +42,14 @@ class ConsoleauthTestCase(test.TestCase):
|
|||||||
super(ConsoleauthTestCase, self).setUp()
|
super(ConsoleauthTestCase, self).setUp()
|
||||||
self.manager = utils.import_object(FLAGS.consoleauth_manager)
|
self.manager = utils.import_object(FLAGS.consoleauth_manager)
|
||||||
self.context = context.get_admin_context()
|
self.context = context.get_admin_context()
|
||||||
self.old_ttl = FLAGS.console_token_ttl
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(ConsoleauthTestCase, self).tearDown()
|
super(ConsoleauthTestCase, self).tearDown()
|
||||||
FLAGS.console_token_ttl = self.old_ttl
|
|
||||||
|
|
||||||
def test_tokens_expire(self):
|
def test_tokens_expire(self):
|
||||||
"""Test that tokens expire correctly."""
|
"""Test that tokens expire correctly."""
|
||||||
token = 'mytok'
|
token = 'mytok'
|
||||||
FLAGS.console_token_ttl = 1
|
self.flags(console_token_ttl=1)
|
||||||
self.manager.authorize_console(self.context, token, 'novnc',
|
self.manager.authorize_console(self.context, token, 'novnc',
|
||||||
'127.0.0.1', 'host', '')
|
'127.0.0.1', 'host', '')
|
||||||
self.assertTrue(self.manager.check_token(self.context, token))
|
self.assertTrue(self.manager.check_token(self.context, token))
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import exceptions
|
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
@ -26,88 +25,18 @@ from nova.openstack.common import cfg
|
|||||||
from nova import test
|
from nova import test
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_option(cfg.StrOpt('flags_unittest',
|
FLAGS.register_opt(cfg.StrOpt('flags_unittest',
|
||||||
default='foo',
|
default='foo',
|
||||||
help='for testing purposes only'))
|
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')
|
|
||||||
|
|
||||||
|
|
||||||
class FlagsTestCase(test.TestCase):
|
class FlagsTestCase(test.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(FlagsTestCase, self).setUp()
|
super(FlagsTestCase, self).setUp()
|
||||||
self.FLAGS = flags.FlagValues()
|
self.FLAGS = flags.NovaConfigOpts()
|
||||||
self.global_FLAGS = flags.FLAGS
|
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):
|
def test_declare(self):
|
||||||
self.assert_('answer' not in self.global_FLAGS)
|
self.assert_('answer' not in self.global_FLAGS)
|
||||||
flags.DECLARE('answer', 'nova.tests.declare_flags')
|
flags.DECLARE('answer', 'nova.tests.declare_flags')
|
||||||
@ -115,7 +44,7 @@ class FlagsTestCase(test.TestCase):
|
|||||||
self.assertEqual(self.global_FLAGS.answer, 42)
|
self.assertEqual(self.global_FLAGS.answer, 42)
|
||||||
|
|
||||||
# Make sure we don't overwrite anything
|
# 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)
|
self.assertEqual(self.global_FLAGS.answer, 256)
|
||||||
flags.DECLARE('answer', 'nova.tests.declare_flags')
|
flags.DECLARE('answer', 'nova.tests.declare_flags')
|
||||||
self.assertEqual(self.global_FLAGS.answer, 256)
|
self.assertEqual(self.global_FLAGS.answer, 256)
|
||||||
@ -135,48 +64,51 @@ class FlagsTestCase(test.TestCase):
|
|||||||
self.assertEqual(self.global_FLAGS.runtime_answer, 54)
|
self.assertEqual(self.global_FLAGS.runtime_answer, 54)
|
||||||
|
|
||||||
def test_long_vs_short_flags(self):
|
def test_long_vs_short_flags(self):
|
||||||
self.global_FLAGS.Reset()
|
self.global_FLAGS.reset()
|
||||||
self.global_FLAGS.add_cli_option(cfg.StrOpt('duplicate_answer_long',
|
self.global_FLAGS.register_cli_opt(cfg.StrOpt('duplicate_answer_long',
|
||||||
default='val',
|
default='val',
|
||||||
help='desc'))
|
help='desc'))
|
||||||
argv = ['flags_test', '--duplicate_answer=60', 'extra_arg']
|
argv = ['flags_test', '--duplicate_answer=60', 'extra_arg']
|
||||||
args = self.global_FLAGS(argv)
|
args = self.global_FLAGS(argv)
|
||||||
|
|
||||||
self.assert_('duplicate_answer' not in self.global_FLAGS)
|
self.assert_('duplicate_answer' not in self.global_FLAGS)
|
||||||
self.assert_(self.global_FLAGS.duplicate_answer_long, 60)
|
self.assert_(self.global_FLAGS.duplicate_answer_long, 60)
|
||||||
|
|
||||||
self.global_FLAGS.Reset()
|
self.global_FLAGS.reset()
|
||||||
self.global_FLAGS.add_cli_option(cfg.IntOpt('duplicate_answer',
|
self.global_FLAGS.register_cli_opt(cfg.IntOpt('duplicate_answer',
|
||||||
default=60,
|
default=60,
|
||||||
help='desc'))
|
help='desc'))
|
||||||
args = self.global_FLAGS(argv)
|
args = self.global_FLAGS(argv)
|
||||||
self.assertEqual(self.global_FLAGS.duplicate_answer, 60)
|
self.assertEqual(self.global_FLAGS.duplicate_answer, 60)
|
||||||
self.assertEqual(self.global_FLAGS.duplicate_answer_long, 'val')
|
self.assertEqual(self.global_FLAGS.duplicate_answer_long, 'val')
|
||||||
|
|
||||||
def test_flag_leak_left(self):
|
def test_flag_leak_left(self):
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
||||||
FLAGS.flags_unittest = 'bar'
|
self.flags(flags_unittest='bar')
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'bar')
|
self.assertEqual(FLAGS.flags_unittest, 'bar')
|
||||||
|
|
||||||
def test_flag_leak_right(self):
|
def test_flag_leak_right(self):
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
||||||
FLAGS.flags_unittest = 'bar'
|
self.flags(flags_unittest='bar')
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'bar')
|
self.assertEqual(FLAGS.flags_unittest, 'bar')
|
||||||
|
|
||||||
def test_flag_overrides(self):
|
def test_flag_overrides(self):
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
||||||
self.flags(flags_unittest='bar')
|
self.flags(flags_unittest='bar')
|
||||||
self.assertEqual(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.reset_flags()
|
||||||
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
self.assertEqual(FLAGS.flags_unittest, 'foo')
|
||||||
self.assertEqual(FLAGS['flags_unittest'].value, 'foo')
|
|
||||||
self.assertEqual(FLAGS.FlagValuesDict()['flags_unittest'], 'foo')
|
|
||||||
|
|
||||||
def test_flagfile(self):
|
def test_flagfile(self):
|
||||||
self.FLAGS.add_options(test_opts)
|
opts = [
|
||||||
self.FLAGS.add_option(multistr_opt)
|
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')
|
(fd, path) = tempfile.mkstemp(prefix='nova', suffix='.flags')
|
||||||
|
|
||||||
@ -200,15 +132,15 @@ class FlagsTestCase(test.TestCase):
|
|||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
def test_defaults(self):
|
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.assertEqual(self.FLAGS.foo, 'bar')
|
||||||
|
|
||||||
self.FLAGS['foo'].SetDefault('blaa')
|
self.FLAGS.set_default('foo', 'blaa')
|
||||||
self.assertEqual(self.FLAGS.foo, 'blaa')
|
self.assertEqual(self.FLAGS.foo, 'blaa')
|
||||||
|
|
||||||
def test_templated_values(self):
|
def test_templated_values(self):
|
||||||
self.FLAGS.add_option(cfg.StrOpt('foo', default='foo', help='desc'))
|
self.FLAGS.register_opt(cfg.StrOpt('foo', default='foo', help='desc'))
|
||||||
self.FLAGS.add_option(cfg.StrOpt('bar', default='bar', help='desc'))
|
self.FLAGS.register_opt(cfg.StrOpt('bar', default='bar', help='desc'))
|
||||||
self.FLAGS.add_option(cfg.StrOpt('blaa',
|
self.FLAGS.register_opt(cfg.StrOpt('blaa',
|
||||||
default='$foo$bar', help='desc'))
|
default='$foo$bar', help='desc'))
|
||||||
self.assertEqual(self.FLAGS.blaa, 'foobar')
|
self.assertEqual(self.FLAGS.blaa, 'foobar')
|
||||||
|
@ -173,7 +173,7 @@ class InstanceTypeTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_will_not_get_bad_default_instance_type(self):
|
def test_will_not_get_bad_default_instance_type(self):
|
||||||
"""ensures error raised on bad default instance type"""
|
"""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,
|
self.assertRaises(exception.ApiError,
|
||||||
instance_types.get_default_instance_type)
|
instance_types.get_default_instance_type)
|
||||||
|
|
||||||
|
@ -939,8 +939,7 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
"""Confirms pre_block_migration works correctly."""
|
"""Confirms pre_block_migration works correctly."""
|
||||||
# Replace instances_path since this testcase creates tmpfile
|
# Replace instances_path since this testcase creates tmpfile
|
||||||
tmpdir = tempfile.mkdtemp()
|
tmpdir = tempfile.mkdtemp()
|
||||||
store = FLAGS.instances_path
|
self.flags(instances_path=tmpdir)
|
||||||
FLAGS.instances_path = tmpdir
|
|
||||||
|
|
||||||
# Test data
|
# Test data
|
||||||
instance_ref = db.instance_create(self.context, self.test_instance)
|
instance_ref = db.instance_create(self.context, self.test_instance)
|
||||||
@ -960,8 +959,6 @@ class LibvirtConnTestCase(test.TestCase):
|
|||||||
|
|
||||||
shutil.rmtree(tmpdir)
|
shutil.rmtree(tmpdir)
|
||||||
db.instance_destroy(self.context, instance_ref['id'])
|
db.instance_destroy(self.context, instance_ref['id'])
|
||||||
# Restore FLAGS.instances_path
|
|
||||||
FLAGS.instances_path = store
|
|
||||||
|
|
||||||
@test.skip_if(missing_libvirt(), "Test requires libvirt")
|
@test.skip_if(missing_libvirt(), "Test requires libvirt")
|
||||||
def test_get_instance_disk_info_works_correctly(self):
|
def test_get_instance_disk_info_works_correctly(self):
|
||||||
|
@ -442,9 +442,9 @@ class LibvirtConnTestCase(_VirtDriverTestCase):
|
|||||||
|
|
||||||
# Point _VirtDriverTestCase at the right module
|
# Point _VirtDriverTestCase at the right module
|
||||||
self.driver_module = nova.virt.libvirt.connection
|
self.driver_module = nova.virt.libvirt.connection
|
||||||
FLAGS.firewall_driver = nova.virt.libvirt.firewall.drivers[0]
|
|
||||||
super(LibvirtConnTestCase, self).setUp()
|
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_kernel_id="3",
|
||||||
rescue_ramdisk_id=None)
|
rescue_ramdisk_id=None)
|
||||||
|
|
||||||
|
@ -40,8 +40,7 @@ class VsaTestCase(test.TestCase):
|
|||||||
self.stubs = stubout.StubOutForTesting()
|
self.stubs = stubout.StubOutForTesting()
|
||||||
self.vsa_api = vsa.API()
|
self.vsa_api = vsa.API()
|
||||||
|
|
||||||
FLAGS.quota_volumes = 100
|
self.flags(quota_volumes=100, quota_gigabytes=10000)
|
||||||
FLAGS.quota_gigabytes = 10000
|
|
||||||
|
|
||||||
self.context = context.get_admin_context()
|
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):
|
def test_vsa_create_with_storage(self, multi_vol_creation=True):
|
||||||
"""Test creation of VSA with BE storage"""
|
"""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',
|
param = {'storage': [{'drive_name': 'SATA_500_7200',
|
||||||
'num_drives': 3}]}
|
'num_drives': 3}]}
|
||||||
@ -152,7 +151,7 @@ class VsaTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_vsa_generate_user_data(self):
|
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',
|
param = {'display_name': 'VSA name test',
|
||||||
'display_description': 'VSA desc test',
|
'display_description': 'VSA desc test',
|
||||||
'vc_count': 2,
|
'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"
|
PERFECT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%f"
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
|
FLAGS.register_opt(
|
||||||
FLAGS.add_option(
|
|
||||||
cfg.BoolOpt('disable_process_locking', default=False,
|
cfg.BoolOpt('disable_process_locking', default=False,
|
||||||
help='Whether to disable inter-process locks'))
|
help='Whether to disable inter-process locks'))
|
||||||
|
|
||||||
@ -572,7 +571,7 @@ class LazyPluggable(object):
|
|||||||
|
|
||||||
def __get_backend(self):
|
def __get_backend(self):
|
||||||
if not self.__backend:
|
if not self.__backend:
|
||||||
backend_name = self.__pivot.value
|
backend_name = FLAGS[self.__pivot]
|
||||||
if backend_name not in self.__backends:
|
if backend_name not in self.__backends:
|
||||||
raise exception.Error(_('Invalid backend: %s') % backend_name)
|
raise exception.Error(_('Invalid backend: %s') % backend_name)
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ vsa_opts = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_options(vsa_opts)
|
FLAGS.register_opts(vsa_opts)
|
||||||
|
|
||||||
LOG = logging.getLogger('nova.vsa')
|
LOG = logging.getLogger('nova.vsa')
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ vsa_driver_opt = cfg.StrOpt('vsa_driver',
|
|||||||
help='Driver to use for controlling VSAs')
|
help='Driver to use for controlling VSAs')
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.add_option(vsa_driver_opt)
|
FLAGS.register_opt(vsa_driver_opt)
|
||||||
|
|
||||||
LOG = logging.getLogger('nova.vsa.manager')
|
LOG = logging.getLogger('nova.vsa.manager')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user