messaging: remove RequestContextSerializer
We don't pass any oslo.context object around anymore, we just pass dict if we really need to send some context information – which we barely need actually. And remove oslo.context! Change-Id: I17d15c043b5c7d508af9a43f50511817f9e81151
This commit is contained in:
parent
36a5d1b2d7
commit
2e3f7920ab
|
@ -14,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
import oslo_context.context
|
||||
import oslo_messaging
|
||||
from oslo_messaging import serializer as oslo_serializer
|
||||
|
||||
|
@ -55,30 +54,7 @@ def cleanup():
|
|||
del TRANSPORTS[url]
|
||||
|
||||
|
||||
class RequestContextSerializer(oslo_messaging.Serializer):
|
||||
|
||||
def __init__(self, base):
|
||||
self._base = base
|
||||
|
||||
def serialize_entity(self, context, entity):
|
||||
if not self._base:
|
||||
return entity
|
||||
return self._base.serialize_entity(context, entity)
|
||||
|
||||
def deserialize_entity(self, context, entity):
|
||||
if not self._base:
|
||||
return entity
|
||||
return self._base.deserialize_entity(context, entity)
|
||||
|
||||
def serialize_context(self, context):
|
||||
return context.to_dict()
|
||||
|
||||
def deserialize_context(self, context):
|
||||
return oslo_context.context.RequestContext.from_dict(context)
|
||||
|
||||
|
||||
_SERIALIZER = RequestContextSerializer(
|
||||
oslo_serializer.JsonPayloadSerializer())
|
||||
_SERIALIZER = oslo_serializer.JsonPayloadSerializer()
|
||||
|
||||
|
||||
def get_batch_notification_listener(transport, targets, endpoints,
|
||||
|
|
|
@ -18,7 +18,6 @@ import shutil
|
|||
|
||||
import mock
|
||||
from oslo_config import fixture as fixture_config
|
||||
from oslo_context import context
|
||||
import oslo_messaging
|
||||
import oslo_messaging.conffixture
|
||||
import oslo_service.service
|
||||
|
@ -250,7 +249,7 @@ class BaseRealNotification(tests_base.BaseTestCase):
|
|||
|
||||
notifier = messaging.get_notifier(self.transport,
|
||||
"compute.vagrant-precise")
|
||||
notifier.info(context.RequestContext(), 'compute.instance.create.end',
|
||||
notifier.info({}, 'compute.instance.create.end',
|
||||
TEST_NOTICE_PAYLOAD)
|
||||
start = timeutils.utcnow()
|
||||
while timeutils.delta_seconds(start, timeutils.utcnow()) < 600:
|
||||
|
@ -346,7 +345,7 @@ class TestRealNotification(BaseRealNotification):
|
|||
self.srv.start()
|
||||
notifier = messaging.get_notifier(self.transport,
|
||||
'compute.vagrant-precise')
|
||||
notifier.error(context.RequestContext(), 'compute.instance.error',
|
||||
notifier.error({}, 'compute.instance.error',
|
||||
TEST_NOTICE_PAYLOAD)
|
||||
start = timeutils.utcnow()
|
||||
while timeutils.delta_seconds(start, timeutils.utcnow()) < 600:
|
||||
|
@ -511,12 +510,10 @@ class TestRealNotificationMultipleAgents(tests_base.BaseTestCase):
|
|||
"compute.vagrant-precise")
|
||||
payload1 = TEST_NOTICE_PAYLOAD.copy()
|
||||
payload1['instance_id'] = '0'
|
||||
notifier.info(context.RequestContext(), 'compute.instance.create.end',
|
||||
payload1)
|
||||
notifier.info({}, 'compute.instance.create.end', payload1)
|
||||
payload2 = TEST_NOTICE_PAYLOAD.copy()
|
||||
payload2['instance_id'] = '1'
|
||||
notifier.info(context.RequestContext(), 'compute.instance.create.end',
|
||||
payload2)
|
||||
notifier.info({}, 'compute.instance.create.end', payload2)
|
||||
self.expected_samples = 4
|
||||
start = timeutils.utcnow()
|
||||
with mock.patch('six.moves.builtins.hash', lambda x: int(x)):
|
||||
|
|
|
@ -9,7 +9,6 @@ kafka-python<1.0.0,>=0.9.5 # Apache-2.0
|
|||
keystonemiddleware!=4.1.0,>=4.0.0 # Apache-2.0
|
||||
lxml>=2.3 # BSD
|
||||
msgpack-python>=0.4.0 # Apache-2.0
|
||||
oslo.context>=2.2.0 # Apache-2.0
|
||||
oslo.db>=4.1.0 # Apache-2.0
|
||||
oslo.concurrency>=3.5.0 # Apache-2.0
|
||||
oslo.config>=3.7.0 # Apache-2.0
|
||||
|
|
Loading…
Reference in New Issue