The openstack_dashboard.openstack.common.rpc ModuleΒΆ

A remote procedure call (rpc) abstraction.

For some wrappers that add message versioning to rpc, see:
rpc.dispatcher rpc.proxy
openstack_dashboard.openstack.common.rpc.call(context, topic, msg, timeout=None, check_for_lock=False)[source]

Invoke a remote method that returns something.

Parameters:
  • context – Information that identifies the user that has made this request.
  • topic – The topic to send the rpc message to. This correlates to the topic argument of openstack.common.rpc.common.Connection.create_consumer() and only applies when the consumer was created with fanout=False.
  • msg – This is a dict in the form { “method” : “method_to_invoke”, “args” : dict_of_kwargs }
  • timeout – int, number of seconds to use for a response timeout. If set, this overrides the rpc_response_timeout option.
  • check_for_lock – if True, a warning is emitted if a RPC call is made with a lock held.
Returns:

A dict from the remote method.

Raises :

openstack.common.rpc.common.Timeout if a complete response is not received before the timeout is reached.

openstack_dashboard.openstack.common.rpc.cast(context, topic, msg)[source]

Invoke a remote method that does not return anything.

Parameters:
  • context – Information that identifies the user that has made this request.
  • topic – The topic to send the rpc message to. This correlates to the topic argument of openstack.common.rpc.common.Connection.create_consumer() and only applies when the consumer was created with fanout=False.
  • msg – This is a dict in the form { “method” : “method_to_invoke”, “args” : dict_of_kwargs }
Returns:

None

openstack_dashboard.openstack.common.rpc.cast_to_server(context, server_params, topic, msg)[source]

Invoke a remote method that does not return anything.

Parameters:
  • context – Information that identifies the user that has made this request.
  • server_params – Connection information
  • topic – The topic to send the notification to.
  • msg – This is a dict in the form { “method” : “method_to_invoke”, “args” : dict_of_kwargs }
Returns:

None

openstack_dashboard.openstack.common.rpc.cleanup()[source]

Clean up resoruces in use by implementation.

Clean up any resources that have been allocated by the RPC implementation. This is typically open connections to a messaging service. This function would get called before an application using this API exits to allow connections to get torn down cleanly.

Returns:None
openstack_dashboard.openstack.common.rpc.create_connection(new=True)[source]

Create a connection to the message bus used for rpc.

For some example usage of creating a connection and some consumers on that connection, see nova.service.

Parameters:new – Whether or not to create a new connection. A new connection will be created by default. If new is False, the implementation is free to return an existing connection from a pool.
Returns:An instance of openstack.common.rpc.common.Connection
openstack_dashboard.openstack.common.rpc.fanout_cast(context, topic, msg)[source]

Broadcast a remote method invocation with no return.

This method will get invoked on all consumers that were set up with this topic name and fanout=True.

Parameters:
  • context – Information that identifies the user that has made this request.
  • topic – The topic to send the rpc message to. This correlates to the topic argument of openstack.common.rpc.common.Connection.create_consumer() and only applies when the consumer was created with fanout=True.
  • msg – This is a dict in the form { “method” : “method_to_invoke”, “args” : dict_of_kwargs }
Returns:

None

openstack_dashboard.openstack.common.rpc.fanout_cast_to_server(context, server_params, topic, msg)[source]

Broadcast to a remote method invocation with no return.

Parameters:
  • context – Information that identifies the user that has made this request.
  • server_params – Connection information
  • topic – The topic to send the notification to.
  • msg – This is a dict in the form { “method” : “method_to_invoke”, “args” : dict_of_kwargs }
Returns:

None

openstack_dashboard.openstack.common.rpc.multicall(context, topic, msg, timeout=None, check_for_lock=False)[source]

Invoke a remote method and get back an iterator.

In this case, the remote method will be returning multiple values in separate messages, so the return values can be processed as the come in via an iterator.

Parameters:
  • context – Information that identifies the user that has made this request.
  • topic – The topic to send the rpc message to. This correlates to the topic argument of openstack.common.rpc.common.Connection.create_consumer() and only applies when the consumer was created with fanout=False.
  • msg – This is a dict in the form { “method” : “method_to_invoke”, “args” : dict_of_kwargs }
  • timeout – int, number of seconds to use for a response timeout. If set, this overrides the rpc_response_timeout option.
  • check_for_lock – if True, a warning is emitted if a RPC call is made with a lock held.
Returns:

An iterator. The iterator will yield a tuple (N, X) where N is an index that starts at 0 and increases by one for each value returned and X is the Nth value that was returned by the remote method.

Raises :

openstack.common.rpc.common.Timeout if a complete response is not received before the timeout is reached.

openstack_dashboard.openstack.common.rpc.notify(context, topic, msg, envelope=False)[source]

Send notification event.

Parameters:
  • context – Information that identifies the user that has made this request.
  • topic – The topic to send the notification to.
  • msg – This is a dict of content of event.
  • envelope – Set to True to enable message envelope for notifications.
Returns:

None

openstack_dashboard.openstack.common.rpc.queue_get_for(context, topic, host)[source]

Get a queue name for a given topic + host.

This function only works if this naming convention is followed on the consumer side, as well. For example, in nova, every instance of the nova-foo service calls create_consumer() for two topics:

foo foo.<host>

Messages sent to the ‘foo’ topic are distributed to exactly one instance of the nova-foo service. The services are chosen in a round-robin fashion. Messages sent to the ‘foo.<host>’ topic are sent to the nova-foo service on <host>.

openstack_dashboard.openstack.common.rpc.set_defaults(control_exchange)[source]

Previous topic

The openstack_dashboard.openstack.common.rpc.matchmaker_ring Module

Next topic

The openstack_dashboard.openstack.common.notifier.no_op_notifier Module

This Page