Remove tornado-related code from almost everything.
Left it in api where it is still being used pending gundlach's changes.
This commit is contained in:
16
nova/rpc.py
16
nova/rpc.py
@@ -81,21 +81,6 @@ class Consumer(messaging.Consumer):
|
|||||||
self.failed_connection = False
|
self.failed_connection = False
|
||||||
super(Consumer, self).__init__(*args, **kwargs)
|
super(Consumer, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
# TODO(termie): it would be nice to give these some way of automatically
|
|
||||||
# cleaning up after themselves
|
|
||||||
def attach_to_tornado(self, io_inst=None):
|
|
||||||
"""Attach a callback to tornado that fires 10 times a second"""
|
|
||||||
from tornado import ioloop
|
|
||||||
if io_inst is None:
|
|
||||||
io_inst = ioloop.IOLoop.instance()
|
|
||||||
|
|
||||||
injected = ioloop.PeriodicCallback(
|
|
||||||
lambda: self.fetch(enable_callbacks=True), 100, io_loop=io_inst)
|
|
||||||
injected.start()
|
|
||||||
return injected
|
|
||||||
|
|
||||||
attachToTornado = attach_to_tornado
|
|
||||||
|
|
||||||
def fetch(self, no_ack=None, auto_ack=None, enable_callbacks=False):
|
def fetch(self, no_ack=None, auto_ack=None, enable_callbacks=False):
|
||||||
"""Wraps the parent fetch with some logic for failed connections"""
|
"""Wraps the parent fetch with some logic for failed connections"""
|
||||||
# TODO(vish): the logic for failed connections and logging should be
|
# TODO(vish): the logic for failed connections and logging should be
|
||||||
@@ -123,6 +108,7 @@ class Consumer(messaging.Consumer):
|
|||||||
"""Attach a callback to twisted that fires 10 times a second"""
|
"""Attach a callback to twisted that fires 10 times a second"""
|
||||||
loop = task.LoopingCall(self.fetch, enable_callbacks=True)
|
loop = task.LoopingCall(self.fetch, enable_callbacks=True)
|
||||||
loop.start(interval=0.1)
|
loop.start(interval=0.1)
|
||||||
|
return loop
|
||||||
|
|
||||||
|
|
||||||
class Publisher(messaging.Publisher):
|
class Publisher(messaging.Publisher):
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ FLAGS = flags.FLAGS
|
|||||||
class Context(object):
|
class Context(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class AccessTestCase(test.BaseTestCase):
|
class AccessTestCase(test.TrialTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(AccessTestCase, self).setUp()
|
super(AccessTestCase, self).setUp()
|
||||||
FLAGS.connection_type = 'fake'
|
FLAGS.connection_type = 'fake'
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ from nova.endpoint import cloud
|
|||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
|
|
||||||
class AuthTestCase(test.BaseTestCase):
|
class AuthTestCase(test.TrialTestCase):
|
||||||
flush_db = False
|
flush_db = False
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(AuthTestCase, self).setUp()
|
super(AuthTestCase, self).setUp()
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import StringIO
|
import StringIO
|
||||||
import time
|
import time
|
||||||
from tornado import ioloop
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
import unittest
|
import unittest
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
@@ -36,7 +35,7 @@ from nova.endpoint import cloud
|
|||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
|
|
||||||
class CloudTestCase(test.BaseTestCase):
|
class CloudTestCase(test.TrialTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CloudTestCase, self).setUp()
|
super(CloudTestCase, self).setUp()
|
||||||
self.flags(connection_type='fake',
|
self.flags(connection_type='fake',
|
||||||
@@ -53,16 +52,19 @@ class CloudTestCase(test.BaseTestCase):
|
|||||||
self.compute_consumer = rpc.AdapterConsumer(connection=self.conn,
|
self.compute_consumer = rpc.AdapterConsumer(connection=self.conn,
|
||||||
topic=FLAGS.compute_topic,
|
topic=FLAGS.compute_topic,
|
||||||
proxy=self.compute)
|
proxy=self.compute)
|
||||||
self.injected.append(self.compute_consumer.attach_to_tornado(self.ioloop))
|
self.injected.append(self.compute_consumer.attach_to_twisted())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
manager.AuthManager().create_user('admin', 'admin', 'admin')
|
manager.AuthManager().create_user('admin', 'admin', 'admin')
|
||||||
except: pass
|
except: pass
|
||||||
admin = manager.AuthManager().get_user('admin')
|
admin = manager.AuthManager().get_user('admin')
|
||||||
project = manager.AuthManager().create_project('proj', 'admin', 'proj')
|
project = manager.AuthManager().create_project('proj', 'admin', 'proj')
|
||||||
self.context = api.APIRequestContext(handler=None,project=project,user=admin)
|
self.context = api.APIRequestContext(handler=None,
|
||||||
|
project=project,
|
||||||
|
user=admin)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
super(CloudTestCase, self).tearDown()
|
||||||
manager.AuthManager().delete_project('proj')
|
manager.AuthManager().delete_project('proj')
|
||||||
manager.AuthManager().delete_user('admin')
|
manager.AuthManager().delete_user('admin')
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ os.makedirs(os.path.join(OSS_TEMPDIR, 'images'))
|
|||||||
os.makedirs(os.path.join(OSS_TEMPDIR, 'buckets'))
|
os.makedirs(os.path.join(OSS_TEMPDIR, 'buckets'))
|
||||||
|
|
||||||
|
|
||||||
class ObjectStoreTestCase(test.BaseTestCase):
|
class ObjectStoreTestCase(test.TrialTestCase):
|
||||||
"""Test objectstore API directly."""
|
"""Test objectstore API directly."""
|
||||||
|
|
||||||
def setUp(self): # pylint: disable-msg=C0103
|
def setUp(self): # pylint: disable-msg=C0103
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ from nova import test
|
|||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
|
|
||||||
class RpcTestCase(test.BaseTestCase):
|
class RpcTestCase(test.TrialTestCase):
|
||||||
"""Test cases for rpc"""
|
"""Test cases for rpc"""
|
||||||
def setUp(self): # pylint: disable-msg=C0103
|
def setUp(self): # pylint: disable-msg=C0103
|
||||||
super(RpcTestCase, self).setUp()
|
super(RpcTestCase, self).setUp()
|
||||||
@@ -40,7 +40,7 @@ class RpcTestCase(test.BaseTestCase):
|
|||||||
topic='test',
|
topic='test',
|
||||||
proxy=self.receiver)
|
proxy=self.receiver)
|
||||||
|
|
||||||
self.injected.append(self.consumer.attach_to_tornado(self.ioloop))
|
self.injected.append(self.consumer.attach_to_twisted())
|
||||||
|
|
||||||
def test_call_succeed(self):
|
def test_call_succeed(self):
|
||||||
"""Get a value through rpc call"""
|
"""Get a value through rpc call"""
|
||||||
|
|||||||
Reference in New Issue
Block a user