Python oslo_messaging.RPCClient() Examples

The following are 30 code examples of oslo_messaging.RPCClient(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module oslo_messaging , or try the search function .
Example #1
Source File: test_rpcapi.py    From watcher with Apache License 2.0 5 votes vote down vote up
def test_execute_audit_without_error(self):
        with mock.patch.object(om.RPCClient, 'cast') as mock_cast:
            action_plan_uuid = utils.generate_uuid()
            self.api.launch_action_plan(self.context, action_plan_uuid)
            mock_cast.assert_called_once_with(
                self.context,
                'launch_action_plan',
                action_plan_uuid=action_plan_uuid) 
Example #2
Source File: rpc.py    From karbor with Apache License 2.0 5 votes vote down vote up
def get_client(target, version_cap=None, serializer=None):
    assert TRANSPORT is not None
    serializer = RequestContextSerializer(serializer)
    return messaging.RPCClient(TRANSPORT,
                               target,
                               version_cap=version_cap,
                               serializer=serializer) 
Example #3
Source File: rpc.py    From qinling with Apache License 2.0 5 votes vote down vote up
def __init__(self, transport):
        """Constructs an RPC client for engine.

        :param transport: Messaging transport.
        """
        serializer = ContextSerializer(
            messaging.serializer.JsonPayloadSerializer())

        self.topic = cfg.CONF.engine.topic

        self._client = messaging.RPCClient(
            transport,
            messaging.Target(topic=self.topic),
            serializer=serializer
        ) 
Example #4
Source File: test_main.py    From ironic-inspector with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(TestTopic, self).setUp()
        self.transport_mock = self.useFixture(
            fixtures.MockPatchObject(rpc, 'TRANSPORT',
                                     autospec=True)).mock
        self.target_mock = self.useFixture(
            fixtures.MockPatchObject(rpc.messaging, 'Target',
                                     autospec=True)).mock
        self.rpcclient_mock = self.useFixture(
            fixtures.MockPatchObject(rpc.messaging, 'RPCClient',
                                     autospec=True)).mock
        CONF.set_override('host', 'a-host') 
Example #5
Source File: test_main.py    From ironic-inspector with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseAPITest, self).setUp()
        self.init_app()
        self.uuid = uuidutils.generate_uuid()
        self.rpc_get_client_mock = self.useFixture(
            fixtures.MockPatchObject(rpc, 'get_client', autospec=True)).mock
        self.client_mock = mock.MagicMock(spec=messaging.RPCClient)
        self.rpc_get_client_mock.return_value = self.client_mock 
Example #6
Source File: rpc.py    From ironic-inspector with Apache License 2.0 5 votes vote down vote up
def get_client(topic=None):
    """Get a RPC client instance.

    :param topic: The topic of the message will be delivered to. This argument
                  is ignored if CONF.standalone is True.
    """
    assert TRANSPORT is not None
    if CONF.standalone:
        target = messaging.Target(topic=manager.MANAGER_TOPIC,
                                  server=CONF.host,
                                  version='1.3')
    else:
        target = messaging.Target(topic=topic, version='1.3')
    return messaging.RPCClient(TRANSPORT, target) 
Example #7
Source File: rpc.py    From cyborg with Apache License 2.0 5 votes vote down vote up
def get_client(target, version_cap=None, serializer=None):
    assert TRANSPORT is not None
    serializer = RequestContextSerializer(serializer)
    return messaging.RPCClient(TRANSPORT,
                               target,
                               version_cap=version_cap,
                               serializer=serializer) 
Example #8
Source File: rpc.py    From coriolis with GNU Affero General Public License v3.0 5 votes vote down vote up
def get_client(target, serializer=None, timeout=None):
    serializer = RequestContextSerializer(serializer)
    if timeout is None:
        timeout = CONF.default_messaging_timeout
    return messaging.RPCClient(
        _get_transport(), target, serializer=serializer, timeout=timeout) 
Example #9
Source File: messaging.py    From senlin with Apache License 2.0 5 votes vote down vote up
def get_rpc_client(topic, server, serializer=None):
    """Return a configured oslo_messaging RPCClient."""
    target = messaging.Target(topic=topic, server=server,
                              version=consts.RPC_API_VERSION_BASE)
    if serializer is None:
        serializer = JsonPayloadSerializer()
    serializer = RequestContextSerializer(serializer)
    return messaging.RPCClient(TRANSPORT, target, serializer=serializer) 
Example #10
Source File: __init__.py    From barbican with Apache License 2.0 5 votes vote down vote up
def get_client(target=None, version_cap=None, serializer=None):
    if not CONF.queue.enable:
        return None

    queue_target = target or get_target()
    return messaging.RPCClient(TRANSPORT,
                               target=queue_target,
                               version_cap=version_cap,
                               serializer=serializer) 
Example #11
Source File: service.py    From watcher with Apache License 2.0 5 votes vote down vote up
def conductor_client(self):
        if self._conductor_client is None:
            target = om.Target(
                topic=self.conductor_topic,
                version=self.API_VERSION,
            )
            self._conductor_client = om.RPCClient(
                self.transport, target, serializer=self.serializer)
        return self._conductor_client 
Example #12
Source File: rpc.py    From watcher with Apache License 2.0 5 votes vote down vote up
def get_client(target, version_cap=None, serializer=None):
    assert TRANSPORT is not None
    serializer = RequestContextSerializer(serializer)
    return messaging.RPCClient(TRANSPORT,
                               target,
                               version_cap=version_cap,
                               serializer=serializer) 
Example #13
Source File: test_rpcapi.py    From watcher with Apache License 2.0 5 votes vote down vote up
def test_get_strategy_info(self):
        with mock.patch.object(om.RPCClient, 'call') as mock_call:
            self.api.get_strategy_info(self.context, "dummy")
            mock_call.assert_called_once_with(
                self.context, 'get_strategy_info', strategy_name="dummy") 
Example #14
Source File: test_rpcapi.py    From watcher with Apache License 2.0 5 votes vote down vote up
def test_execute_audit_without_error(self):
        with mock.patch.object(om.RPCClient, 'cast') as mock_cast:
            audit_uuid = utils.generate_uuid()
            self.api.trigger_audit(self.context, audit_uuid)
            mock_cast.assert_called_once_with(
                self.context, 'trigger_audit', audit_uuid=audit_uuid) 
Example #15
Source File: test_rpcapi.py    From watcher with Apache License 2.0 5 votes vote down vote up
def test_get_api_version(self):
        with mock.patch.object(om.RPCClient, 'call') as mock_call:
            expected_context = self.context
            self.api.check_api_version(expected_context)
            mock_call.assert_called_once_with(
                expected_context, 'check_api_version',
                api_version=rpcapi.DecisionEngineAPI().api_version) 
Example #16
Source File: rpc.py    From zun with Apache License 2.0 5 votes vote down vote up
def get_client(target, serializer=None, timeout=None):
    assert TRANSPORT is not None
    return messaging.RPCClient(TRANSPORT,
                               target,
                               serializer=serializer,
                               timeout=timeout) 
Example #17
Source File: test_rpcapi.py    From watcher with Apache License 2.0 5 votes vote down vote up
def test_get_api_version(self):
        with mock.patch.object(om.RPCClient, 'call') as mock_call:
            expected_context = self.context
            self.api.check_api_version(expected_context)
            mock_call.assert_called_once_with(
                expected_context,
                'check_api_version',
                api_version=rpcapi.ApplierAPI().API_VERSION) 
Example #18
Source File: messaging.py    From cloudkitty with Apache License 2.0 5 votes vote down vote up
def get_client(version_cap=None):
    transport = get_transport()
    target = get_target()
    return oslo_messaging.RPCClient(transport, target, version_cap=version_cap) 
Example #19
Source File: rpc.py    From vitrage with Apache License 2.0 5 votes vote down vote up
def get_client(transport, target, version_cap=None, serializer=None):
    assert transport is not None

    if profiler:
        LOG.info('profiler enabled for RPC client')
        serializer = ProfilerContextSerializer(serializer=serializer)

    return messaging.RPCClient(transport,
                               target,
                               version_cap=version_cap,
                               serializer=serializer) 
Example #20
Source File: __init__.py    From sgx-kms with Apache License 2.0 5 votes vote down vote up
def get_client(target=None, version_cap=None, serializer=None):
    if not CONF.queue.enable:
        return None

    queue_target = target or get_target()
    return messaging.RPCClient(TRANSPORT,
                               target=queue_target,
                               version_cap=version_cap,
                               serializer=serializer) 
Example #21
Source File: rpc.py    From masakari with Apache License 2.0 5 votes vote down vote up
def get_client(target, version_cap=None, serializer=None):
    assert TRANSPORT is not None
    serializer = RequestContextSerializer(serializer)
    return messaging.RPCClient(TRANSPORT,
                               target,
                               version_cap=version_cap,
                               serializer=serializer) 
Example #22
Source File: rpc.py    From manila with Apache License 2.0 5 votes vote down vote up
def get_client(target, version_cap=None, serializer=None):
    assert TRANSPORT is not None
    serializer = RequestContextSerializer(serializer)
    return messaging.RPCClient(TRANSPORT,
                               target,
                               version_cap=version_cap,
                               serializer=serializer) 
Example #23
Source File: rpc_service.py    From magnum with Apache License 2.0 5 votes vote down vote up
def __init__(self, transport=None, context=None, topic=None, server=None,
                 timeout=None):
        serializer = _init_serializer()
        if transport is None:
            exmods = rpc.get_allowed_exmods()
            transport = messaging.get_rpc_transport(
                CONF, allowed_remote_exmods=exmods)
        self._context = context
        if topic is None:
            topic = ''
        target = messaging.Target(topic=topic, server=server)
        self._client = messaging.RPCClient(transport, target,
                                           serializer=serializer,
                                           timeout=timeout) 
Example #24
Source File: rpc.py    From magnum with Apache License 2.0 5 votes vote down vote up
def get_client(target, version_cap=None, serializer=None, timeout=None):
    assert TRANSPORT is not None
    if profiler:
        serializer = ProfilerRequestContextSerializer(serializer)
    else:
        serializer = RequestContextSerializer(serializer)

    return messaging.RPCClient(TRANSPORT,
                               target,
                               version_cap=version_cap,
                               serializer=serializer,
                               timeout=timeout) 
Example #25
Source File: client.py    From snippet with MIT License 5 votes vote down vote up
def __init__(self, transport):
        target = oslo_messaging.Target(topic='test', version='2.0')
        self._client = oslo_messaging.RPCClient(transport, target) 
Example #26
Source File: client.py    From galaxia with Apache License 2.0 5 votes vote down vote up
def __init__(self, topic, host):
        try:
            transport = messaging.get_transport(cfg.CONF)
            target = messaging.Target(topic=topic, server=host)
            self.rpc_client = messaging.RPCClient(transport, target)
        except MessagingException as ex:
            raise ex 
Example #27
Source File: rpc.py    From vdi-broker with Apache License 2.0 5 votes vote down vote up
def get_client(target, serializer=None):
    serializer = RequestContextSerializer(serializer)
    return messaging.RPCClient(_get_transport(), target, serializer=serializer) 
Example #28
Source File: rpc.py    From designate with Apache License 2.0 5 votes vote down vote up
def get_client(target, version_cap=None, serializer=None):
    if TRANSPORT is None:
        raise AssertionError("'TRANSPORT' must not be None")
    if serializer is None:
        serializer = DesignateObjectSerializer()
    serializer = RequestContextSerializer(serializer)
    return messaging.RPCClient(
        TRANSPORT,
        target,
        version_cap=version_cap,
        serializer=serializer
    ) 
Example #29
Source File: rpc.py    From octavia with Apache License 2.0 5 votes vote down vote up
def get_client(target, version_cap=None, serializer=None,
               call_monitor_timeout=None):
    if TRANSPORT is None:
        init()

    return messaging.RPCClient(TRANSPORT,
                               target,
                               version_cap=version_cap,
                               serializer=serializer,
                               call_monitor_timeout=call_monitor_timeout) 
Example #30
Source File: amphora.py    From octavia with Apache License 2.0 5 votes vote down vote up
def __init__(self, amp_id):
        super(AmphoraUpdateController, self).__init__()

        if CONF.api_settings.default_provider_driver == constants.AMPHORAV2:
            topic = constants.TOPIC_AMPHORA_V2
            version = "2.0"
        else:
            topic = cfg.CONF.oslo_messaging.topic
            version = "1.0"
        self.transport = messaging.get_rpc_transport(cfg.CONF)
        self.target = messaging.Target(
            namespace=constants.RPC_NAMESPACE_CONTROLLER_AGENT,
            topic=topic, version=version, fanout=False)
        self.client = messaging.RPCClient(self.transport, target=self.target)
        self.amp_id = amp_id