Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
čEYc@s;ddddgZddlZddlmZddlZddlmZddlm	Z
dd	lmZdd
lmZ
ejddd
ddƒgZdejfd„ƒYZdejfd„ƒYZdejfd„ƒYZejejƒdefd„ƒYƒZdefd„ƒYZdefd„ƒYZdS(tClientSendErrort	RPCClienttRPCVersionCapErrortRemoteErroriÿÿÿÿN(tcfg(tbase(t_utils(t
exceptions(t
serializertrpc_response_timeouttdefaulti<thelps+Seconds to wait for a response from a call.cBs eZdZdddd„ZRS(sDSignifies that a remote endpoint method has raised an exception.

    Contains a string representation of the type of the original exception,
    the value of the original exception, and the traceback.  These are
    sent to the parent as a joined string so printing the exception
    contains all of the relevant info.
    cCs]||_||_||_dtd|jd|jd|jƒ}tt|ƒj|ƒdS(Ns3Remote error: %(exc_type)s %(value)s
%(traceback)s.texc_typetvaluet	traceback(RR
RtdicttsuperRt__init__(tselfRR
Rtmsg((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyR5s			
N(t__name__t
__module__t__doc__tNoneR(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyR+scBseZd„ZRS(cCsK||_||_dtd|jd|jƒ}tt|ƒj|ƒdS(Ns´Requested message version, %(version)s is incompatible.  It needs to be equal in major version and less than or equal in minor version as the specified version cap %(version_cap)s.tversiontversion_cap(RRRRRR(RRRR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyRAs
		(RRR(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyR?scBseZdZd„ZRS(s2Raised if we failed to send a message to a target.cCs<d||f}tt|ƒj|ƒ||_||_dS(Ns!Failed to send to target "%s": %s(RRRttargettex(RRRR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyROs	(RRRR(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyRLst_BaseCallContextcBseZeƒZdddd„Zd„Zd„Zed„Ze	d„ƒZ
d„Zd„Ze
jeeeeeeeeed„	ƒZRS(	cCsY|j|_||_||_||_||_||_||_tt|ƒj	ƒdS(N(
tconft	transportRRttimeouttretryRRRR(RRRRRRR ((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyR[s						cCs¤td|ƒ}tƒ|d<x7|jƒD])\}}|jj||ƒ|d|<q)W|jjdk	r{|jj|d<n|jjdk	r |jj|d<n|S(Ntmethodtargst	namespaceR(RtitemsRtserialize_entityRR#RR(RtctxtR!R"Rtargnametarg((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyt
_make_messagehs
!cCs4tj|j|ƒs0td|d|jƒ‚ndS(NRR(tutilstversion_is_compatibleRR(RR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyt_check_version_capvscCs4||jkr|jjn|}tj|j|ƒS(s=Check to see if a version is compatible with the version cap.(t_markerRRR*R+R(RR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pytcan_send_version{s!cCsW||jk	rSytj||ƒWqSttfk
rOtjd|ƒ‚qSXndS(Ns6Version must contain a major and minor integer. Got %s(R-R*R+t
IndexErrort
ValueErrorRtMessagingException(tclsR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyt_check_version€scKs’|j|||ƒ}|jj|ƒ}|j|jdƒƒy&|jj|j||d|jƒWn(t	j
k
r}t|j|ƒ‚nXdS(s=Invoke a method and return immediately. See RPCClient.cast().RR N(R)Rtserialize_contextR,tgetRt_sendRR tdriver_basetTransportDriverErrorR(RR&R!tkwargsRtmsg_ctxtR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pytcast‹s&c	
Ksú|jjr$tjd|jƒ‚n|j|||ƒ}|jj|ƒ}|j}|jdkrr|j	j
}n|j|jdƒƒy4|j
j|j||dtd|d|jƒ}Wn(tjk
ræ}t|j|ƒ‚nX|jj||ƒS(s;Invoke a method and wait for a reply. See RPCClient.call().s!A call cannot be used with fanoutRtwait_for_replyRR N(RtfanoutRt
InvalidTargetR)RR4RRRR	R,R5RR6tTrueR R7R8Rtdeserialize_entity(	RR&R!R9RR:RtresultR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pytcall—s 		c

CsdS(s=Prepare a method invocation context. See RPCClient.prepare().N((
RtexchangettopicR#RtserverR=RRR ((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pytprepare¯sN(RRtobjectR-RRR)R,R.tclassmethodR3R;RBtabctabstractmethodRF(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyRVs							t_CallContextcBs_eZejZeeeeeeeeeed„	ƒZeeeeeeeeed„	ZRS(c
Csù|j|ƒtd|d|d|d|d|d|ƒ}tg|jƒD]'\}}
|
|jk	rJ||
f^qJƒ}|j|}||jkr¤|j}n|	|jkr¿|j}	n|
|jkrÚ|j}
nt|j	||j
||	|
ƒS(NRCRDR#RRER=(R3RR$R-RRRR RKRR(R2tcall_contextRCRDR#RRER=RRR R9tktvR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyt_prepareºs(
	$c

Cs(tj||||||||||	ƒ
S(N(RKRO(
RRCRDR#RRER=RRR ((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyRFÖs			(RRRR-RHRORF(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyRK¶s					c
BsneZdZejZddddd„Zeeeeeeeeed„	Zd„Zd„Z	ed„Z
RS(sPA class for invoking methods on remote RPC servers.

    The RPCClient class is responsible for sending method invocations to and
    receiving return values from remote RPC servers via a messaging transport.

    Two RPC patterns are supported: RPC calls and RPC casts.

    An RPC cast is used when an RPC method does *not* return a value to
    the caller. An RPC call is used when a return value is expected from the
    method.  For further information see the cast() and call() methods.

    The default target used for all subsequent calls and casts is supplied to
    the RPCClient constructor.  The client uses the target to control how the
    RPC request is delivered to a server.  If only the target's topic (and
    optionally exchange) are set, then the RPC can be serviced by any server
    that is listening to that topic (and exchange).  If multiple servers are
    listening on that topic/exchange, then one server is picked using a
    best-effort round-robin algorithm.  Alternatively, the client can set the
    Target's ``server`` attribute to the name of a specific server to send the
    RPC request to one particular server.  In the case of RPC cast, the RPC
    request can be broadcast to all servers listening to the Target's
    topic/exchange by setting the Target's ``fanout`` property to ``True``.

    While the default target is set on construction, target attributes can be
    overridden for individual method invocations using the prepare() method.

    A method invocation consists of a request context dictionary, a method name
    and a dictionary of arguments.

    This class is intended to be used by wrapping it in another class which
    provides methods on the subclass to perform the remote invocation using
    call() or cast()::

        class TestClient(object):

            def __init__(self, transport):
                target = messaging.Target(topic='test', version='2.0')
                self._client = messaging.RPCClient(transport, target)

            def test(self, ctxt, arg):
                return self._client.call(ctxt, 'test', arg=arg)

    An example of using the prepare() method to override some attributes of the
    default target::

        def test(self, ctxt, arg):
            cctxt = self._client.prepare(version='2.5')
            return cctxt.call(ctxt, 'test', arg=arg)

    RPCClient have a number of other properties - for example, timeout and
    version_cap - which may make sense to override for some method invocations,
    so they too can be passed to prepare()::

        def test(self, ctxt, arg):
            cctxt = self._client.prepare(timeout=10)
            return cctxt.call(ctxt, 'test', arg=arg)

    However, this class can be used directly without wrapping it another class.
    For example::

        transport = messaging.get_rpc_transport(cfg.CONF)
        target = messaging.Target(topic='test', version='2.0')
        client = messaging.RPCClient(transport, target)
        client.call(ctxt, 'test', arg=arg)

    but this is probably only useful in limited circumstances as a wrapper
    class will usually help to make the code much more obvious.

    If the connection to the messaging service is not active when an RPC
    request is made the client will block waiting for the connection to
    complete.  If the connection fails to complete, the client will try to
    re-establish that connection. By default this will continue indefinitely
    until the connection completes. However, the retry parameter can be used to
    have the RPC request fail with a MessageDeliveryFailure after the given
    number of retries. For example::

        client = messaging.RPCClient(transport, target, retry=None)
        client.call(ctxt, 'sync')
        try:
            client.prepare(retry=0).cast(ctxt, 'ping')
        except messaging.MessageDeliveryFailure:
            LOG.error("Failed to send ping message")
    cCsT|dkrtjƒ}ntt|ƒj||||||ƒ|jjtƒdS(sConstruct an RPC client.

        :param transport: a messaging transport handle
        :type transport: Transport
        :param target: the default target for invocations
        :type target: Target
        :param timeout: an optional default timeout (in seconds) for call()s
        :type timeout: int or float
        :param version_cap: raise a RPCVersionCapError version exceeds this cap
        :type version_cap: str
        :param serializer: an optional entity serializer
        :type serializer: Serializer
        :param retry: an optional default connection retries configuration:
                      None or -1 means to retry forever.
                      0 means no retry is attempted.
                      N means attempt at most N retries.
        :type retry: int
        N(	Rtmsg_serializertNoOpSerializerRRRRt
register_optst_client_opts(RRRRRRR ((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyR7s
c

Cs(tj||||||||||	ƒ
S(sPrepare a method invocation context.

        Use this method to override client properties for an individual method
        invocation. For example::

            def test(self, ctxt, arg):
                cctxt = self.prepare(version='2.5')
                return cctxt.call(ctxt, 'test', arg=arg)

        :param exchange: see Target.exchange
        :type exchange: str
        :param topic: see Target.topic
        :type topic: str
        :param namespace: see Target.namespace
        :type namespace: str
        :param version: requirement the server must support, see Target.version
        :type version: str
        :param server: send to a specific server, see Target.server
        :type server: str
        :param fanout: send to all servers on topic, see Target.fanout
        :type fanout: bool
        :param timeout: an optional default timeout (in seconds) for call()s
        :type timeout: int or float
        :param version_cap: raise a RPCVersionCapError version exceeds this cap
        :type version_cap: str
        :param retry: an optional connection retries configuration:
                      None or -1 means to retry forever.
                      0 means no retry is attempted.
                      N means attempt at most N retries.
        :type retry: int
        (RKRO(
RRCRDR#RRER=RRR ((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyRFTs"			cKs|jƒj|||dS(sÉInvoke a method without blocking for a return value.

        The cast() method is used to invoke an RPC method that does not return
        a value.  cast() RPC requests may be broadcast to all Servers listening
        on a given topic by setting the fanout Target property to ``True``.

        The cast() operation is best-effort: cast() will block the
        calling thread until the RPC request method is accepted by the
        messaging transport, but cast() does *not* verify that the RPC method
        has been invoked by the server. cast() does guarantee that the
        method will be not executed twice on a destination (e.g. 'at-most-once'
        execution).

        There are no ordering guarantees across successive casts, even
        among casts to the same destination. Therefore methods may be executed
        in an order different from the order in which they are cast.

        Method arguments must either be primitive types or types supported by
        the client's serializer (if any).

        Similarly, the request context must be a dict unless the client's
        serializer supports serializing another type.

        :param ctxt: a request context dict
        :type ctxt: dict
        :param method: the method name
        :type method: str
        :param kwargs: a dict of method arguments
        :type kwargs: dict
        :raises: MessageDeliveryFailure if the messaging transport fails to
                 accept the request.

        N(RFR;(RR&R!R9((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyR;{s"cKs|jƒj|||S(s	Invoke a method and wait for a reply.

        The call() method is used to invoke RPC methods that return a
        value. Since only a single return value is permitted it is not possible
        to call() to a fanout target.

        call() will block the calling thread until the messaging transport
        provides the return value, a timeout occurs, or a non-recoverable error
        occurs.

        call() guarantees that the RPC request is done 'at-most-once' which
        ensures that the call will never be duplicated.  However if the call
        should fail or time out before the return value arrives then there are
        no guarantees whether or not the method was invoked.

        Since call() blocks until completion of the RPC method, call()s from
        the same thread are guaranteed to be processed in-order.

        Method arguments must either be primitive types or types supported by
        the client's serializer (if any). Similarly, the request context must
        be a dict unless the client's serializer supports serializing another
        type.

        The semantics of how any errors raised by the remote RPC endpoint
        method are handled are quite subtle.

        Firstly, if the remote exception is contained in one of the modules
        listed in the allow_remote_exmods messaging.get_rpc_transport()
        parameter, then it this exception will be re-raised by call(). However,
        such locally re-raised remote exceptions are distinguishable from the
        same exception type raised locally because re-raised remote exceptions
        are modified such that their class name ends with the '_Remote' suffix
        so you may do::

            if ex.__class__.__name__.endswith('_Remote'):
                # Some special case for locally re-raised remote exceptions

        Secondly, if a remote exception is not from a module listed in the
        allowed_remote_exmods list, then a messaging.RemoteError exception is
        raised with all details of the remote exception.

        :param ctxt: a request context dict
        :type ctxt: dict
        :param method: the method name
        :type method: str
        :param kwargs: a dict of method arguments
        :type kwargs: dict
        :raises: MessagingTimeout, RemoteError, MessageDeliveryFailure
        (RFRB(RR&R!R9((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyRBŸs2cCs|jd|ƒjƒS(s=Check to see if a version is compatible with the version cap.R(RFR.(RR((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyR.ÓsN(RRRRR-RRRFR;RBR.(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyRßsT			%	$	4(t__all__RItoslo_configRtsixtoslo_messaging._driversRR7toslo_messagingRR*RRRPtIntOptRSR1RRRt
add_metaclasstABCMetaRGRRKR(((sN/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_messaging/rpc/client.pyt<module>s(	

_)