Handle nova.flags removal
nova.flags has been removed and we're now supposed to use nova.config Put some compat code for Foslom. Change-Id: I53bd74310df35ba37fdaaf26139ab73a46bebd1f Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
97c96f7ebf
commit
c942064bbe
@ -21,7 +21,6 @@ import datetime
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from nova import flags
|
||||
try:
|
||||
from nova import config as nova_config
|
||||
except ImportError:
|
||||
@ -52,7 +51,7 @@ def get_compute_driver():
|
||||
flags.parse_args([])
|
||||
return flags.FLAGS.compute_driver
|
||||
nova_config.parse_args([])
|
||||
return nova_config.CONF.compute_driver
|
||||
return nova_config.CONF.compute_driver or ""
|
||||
|
||||
|
||||
def get_libvirt_connection():
|
||||
|
@ -29,7 +29,13 @@ else:
|
||||
import mock
|
||||
import time
|
||||
|
||||
from nova import flags
|
||||
try:
|
||||
from nova import config
|
||||
nova_CONF = config.CONF
|
||||
except ImportError:
|
||||
# XXX Folsom compat
|
||||
from nova import flags
|
||||
nova_CONF = flags.FLAGS
|
||||
|
||||
from ceilometer.compute import libvirt
|
||||
from ceilometer.compute import manager
|
||||
@ -60,8 +66,8 @@ class TestLibvirtBase(test_base.TestCase):
|
||||
self.instance.name)
|
||||
self.instance.id = 1
|
||||
self.instance.flavor = {'name': 'm1.small', 'id': 2}
|
||||
flags.FLAGS.compute_driver = 'libvirt.LibvirtDriver'
|
||||
flags.FLAGS.connection_type = 'libvirt'
|
||||
nova_CONF.compute_driver = 'libvirt.LibvirtDriver'
|
||||
nova_CONF.connection_type = 'libvirt'
|
||||
|
||||
|
||||
class TestInstancePollster(TestLibvirtBase):
|
||||
@ -87,7 +93,7 @@ class TestDiskIOPollster(TestLibvirtBase):
|
||||
|
||||
@skip.skip_if(libvirt_missing, 'Test requires libvirt')
|
||||
def test_fetch_diskio(self):
|
||||
flags.FLAGS.compute_driver = 'fake.FakeVirtAPI'
|
||||
nova_CONF.compute_driver = 'fake.FakeVirtAPI'
|
||||
list(self.pollster.get_counters(self.manager, self.instance))
|
||||
#assert counters
|
||||
# FIXME(dhellmann): The CI environment doesn't produce
|
||||
@ -96,15 +102,15 @@ class TestDiskIOPollster(TestLibvirtBase):
|
||||
|
||||
@skip.skip_if(libvirt_missing, 'Test requires libvirt')
|
||||
def test_fetch_diskio_not_libvirt(self):
|
||||
flags.FLAGS.compute_driver = 'fake.FakeVirtAPI'
|
||||
flags.FLAGS.connection_type = 'fake'
|
||||
nova_CONF.compute_driver = 'fake.FakeVirtAPI'
|
||||
nova_CONF.connection_type = 'fake'
|
||||
counters = list(self.pollster.get_counters(self.manager,
|
||||
self.instance))
|
||||
assert not counters
|
||||
|
||||
@skip.skip_if(libvirt_missing, 'Test requires libvirt')
|
||||
def test_fetch_diskio_with_libvirt_non_existent_instance(self):
|
||||
flags.FLAGS.compute_driver = 'fake.FakeVirtAPI'
|
||||
nova_CONF.compute_driver = 'fake.FakeVirtAPI'
|
||||
instance = mock.MagicMock()
|
||||
instance.name = 'instance-00000999'
|
||||
instance.id = 999
|
||||
|
@ -24,7 +24,13 @@ import datetime
|
||||
from stevedore import extension
|
||||
from stevedore.tests import manager as test_manager
|
||||
|
||||
from nova import flags
|
||||
try:
|
||||
from nova import config
|
||||
nova_CONF = config.CONF
|
||||
except ImportError:
|
||||
# XXX Folsom compat
|
||||
from nova import flags
|
||||
nova_CONF = flags.FLAGS
|
||||
from nova import db
|
||||
from nova import context
|
||||
from nova.tests import fake_network
|
||||
@ -81,9 +87,9 @@ class TestNovaNotifier(base.TestCase):
|
||||
@skip.skip_unless(notifier_api, "Notifier API not found")
|
||||
def setUp(self):
|
||||
super(TestNovaNotifier, self).setUp()
|
||||
flags.FLAGS.compute_driver = 'nova.virt.fake.FakeDriver'
|
||||
flags.FLAGS.notification_driver = [nova_notifier.__name__]
|
||||
self.compute = importutils.import_object(flags.FLAGS.compute_manager)
|
||||
nova_CONF.compute_driver = 'nova.virt.fake.FakeDriver'
|
||||
nova_CONF.notification_driver = [nova_notifier.__name__]
|
||||
self.compute = importutils.import_object(nova_CONF.compute_manager)
|
||||
self.context = context.get_admin_context()
|
||||
fake_network.set_stub_network_methods(self.stubs)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user