本文整理汇总了Python中neutron.api.rpc.handlers.resources_rpc.resource_type_versioned_topic函数的典型用法代码示例。如果您正苦于以下问题:Python resource_type_versioned_topic函数的具体用法?Python resource_type_versioned_topic怎么用?Python resource_type_versioned_topic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resource_type_versioned_topic函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test___init__
def test___init__(self, mocked_register):
mock_conn = mock.MagicMock()
with mock.patch.object(rpc.Connection, 'create_consumer',
new_callable=mock_conn):
test_obj = agent.TrunkSkeleton()
self.assertEqual(2, mocked_register.call_count)
calls = [mock.call(test_obj.handle_trunks, resources.TRUNK),
mock.call(test_obj.handle_subports, resources.SUBPORT)]
mocked_register.assert_has_calls(calls, any_order=True)
# Test to see if the call to rpc.get_server has the correct
# target and the correct endpoints
topic = resources_rpc.resource_type_versioned_topic(
resources.SUBPORT)
subport_target = oslo_messaging.Target(
topic=topic, server=cfg.CONF.host, fanout=True)
topic = resources_rpc.resource_type_versioned_topic(
resources.TRUNK)
trunk_target = oslo_messaging.Target(
topic=topic, server=cfg.CONF.host, fanout=True)
calls = [mock.call(subport_target.topic, mock.ANY, fanout=True),
mock.call(trunk_target.topic, mock.ANY, fanout=True)]
self.assertIn(calls[0], mock_conn().mock_calls)
self.assertIn(calls[1], mock_conn().mock_calls)
self.assertIn("ResourcesPushRpcCallback",
str(mock_conn().call_args_list))
示例2: __init__
def __init__(self):
registry.register(self.handle_trunks, resources.TRUNK)
registry.register(self.handle_subports, resources.SUBPORT)
self._connection = n_rpc.Connection()
endpoints = [resources_rpc.ResourcesPushRpcCallback()]
topic = resources_rpc.resource_type_versioned_topic(resources.SUBPORT)
self._connection.create_consumer(topic, endpoints, fanout=True)
topic = resources_rpc.resource_type_versioned_topic(resources.TRUNK)
self._connection.create_consumer(topic, endpoints, fanout=True)
self._connection.consume_in_threads()
示例3: _register_rpc_consumers
def _register_rpc_consumers(self, connection):
endpoints = [resources_rpc.ResourcesPushRpcCallback()]
for resource_type in self.SUPPORTED_RESOURCES:
# we assume that neutron-server always broadcasts the latest
# version known to the agent
topic = resources_rpc.resource_type_versioned_topic(resource_type)
connection.create_consumer(topic, endpoints, fanout=True)
示例4: _init_rpc_listeners
def _init_rpc_listeners(self):
endpoints = [resources_rpc.ResourcesPushRpcCallback()]
self._connection = n_rpc.Connection()
for rtype in self.rcache.resource_types:
registry_rpc.register(self.resource_change_handler, rtype)
topic = resources_rpc.resource_type_versioned_topic(rtype)
self._connection.create_consumer(topic, endpoints, fanout=True)
self._connection.consume_in_threads()
示例5: test_resource_type_versioned_topic
def test_resource_type_versioned_topic(self, validate_mock):
obj_name = FakeResource.obj_name()
expected = topics.RESOURCE_TOPIC_PATTERN % {
'resource_type': 'FakeResource', 'version': '1.0'}
with mock.patch.object(resources_rpc.resources, 'get_resource_cls',
return_value=FakeResource):
observed = resources_rpc.resource_type_versioned_topic(obj_name)
self.assertEqual(expected, observed)
示例6: _register_rpc_consumers
def _register_rpc_consumers(self):
registry.register(self._handle_notification, resources.QOS_POLICY)
self._connection = n_rpc.Connection()
endpoints = [resources_rpc.ResourcesPushRpcCallback()]
topic = resources_rpc.resource_type_versioned_topic(
resources.QOS_POLICY)
self._connection.create_consumer(topic, endpoints, fanout=True)
self._connection.consume_in_threads()
示例7: test_initialize_subscribed_to_rpc
def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
self.qos_ext.initialize(self.connection, constants.EXTENSION_DRIVER_TYPE)
self.connection.create_consumer.assert_has_calls(
[
mock.call(resources_rpc.resource_type_versioned_topic(resource_type), [rpc_mock()], fanout=True)
for resource_type in self.qos_ext.SUPPORTED_RESOURCES
]
)
subscribe_mock.assert_called_with(mock.ANY, resources.QOS_POLICY)
示例8: _register_rpc_consumers
def _register_rpc_consumers(self, connection):
"""Allows an extension to receive notifications of updates made to
items of interest.
"""
endpoints = [resources_rpc.ResourcesPushRpcCallback()]
for resource_type in self.SUPPORTED_RESOURCE_TYPES:
# We assume that the neutron server always broadcasts the latest
# version known to the agent
registry.register(self._handle_notification, resource_type)
topic = resources_rpc.resource_type_versioned_topic(resource_type)
connection.create_consumer(topic, endpoints, fanout=True)
示例9: test___init__
def test___init__(self, mocked_get_server, mocked_register):
test_obj = agent.TrunkSkeleton()
self.assertEqual(2, mocked_register.call_count)
calls = [mock.call(test_obj.handle_trunks, resources.TRUNK),
mock.call(test_obj.handle_subports, resources.SUBPORT)]
mocked_register.assert_has_calls(calls, any_order=True)
# Test to see if the call to rpc.get_server has the correct
# target and the correct endpoints
topic = resources_rpc.resource_type_versioned_topic(resources.SUBPORT)
subport_target = oslo_messaging.Target(
topic=topic, server=cfg.CONF.host, fanout=True)
topic = resources_rpc.resource_type_versioned_topic(resources.TRUNK)
trunk_target = oslo_messaging.Target(
topic=topic, server=cfg.CONF.host, fanout=True)
calls = [mock.call(subport_target, mock.ANY),
mock.call(trunk_target, mock.ANY)]
mocked_get_server.assert_has_calls(calls, any_order=True)
self.assertIn("ResourcesPushRpcCallback",
str(mocked_get_server.call_args_list))
示例10: test_initialize_subscribed_to_rpc
def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
with mock.patch.object(n_rpc, 'Connection',
return_value=self.connection) as create_connection:
self.fip_qos_ext.initialize(
self.connection, lib_const.L3_AGENT_MODE)
create_connection.assert_has_calls([mock.call()])
self.connection.create_consumer.assert_has_calls(
[mock.call(
resources_rpc.resource_type_versioned_topic(
resources.QOS_POLICY),
[rpc_mock()],
fanout=True)]
)
subscribe_mock.assert_called_with(mock.ANY, resources.QOS_POLICY)
示例11: test_initialize_subscribed_to_rpc
def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
call_to_patch = 'neutron.common.rpc.Connection'
with mock.patch(call_to_patch,
return_value=self.connection) as create_connection:
self.fip_pf_ext.initialize(
self.connection, lib_const.L3_AGENT_MODE)
create_connection.assert_has_calls([mock.call()])
self.connection.create_consumer.assert_has_calls(
[mock.call(
resources_rpc.resource_type_versioned_topic(
resources.PORTFORWARDING),
[rpc_mock()],
fanout=True)]
)
subscribe_mock.assert_called_with(
mock.ANY, resources.PORTFORWARDING)
示例12: _register_rpc_consumers
def _register_rpc_consumers(self, connection):
endpoints = [resources_rpc.ResourcesPushRpcCallback()]
for resource_type in self.SUPPORTED_RESOURCE_TYPES:
registry.register(self._handle_notification, resource_type)
topic = resources_rpc.resource_type_versioned_topic(resource_type)
connection.create_consumer(topic, endpoints, fanout=True)