ó
ÍÿŠTc           @   s  d  d l  m Z m Z m Z d  d l m Z m Z d  d l m Z m	 Z	 d  d l
 m Z d  d l m Z d  d l m Z d  d l m Z d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d S(   iÿÿÿÿ(   t   maybeDeferredt   executet   succeed(   t   RemoteObjectt   MethodCallArgument(   t   ComponentConnectort   get_remote_methods(   t   BrokerServer(   t   BrokerClient(   t   Monitor(   t   Managert   RemoteBrokerc           B   s   e  Z d  „  Z d „  Z RS(   c            s2   |  j  ƒ  } ‡ ‡  ‡ f d †  } | j | ƒ | S(   s8   Call C{callable} if C{type} is an accepted message type.c            s   ˆ |  k r ˆ  ˆ Œ  Sd  S(   N(    (   t   result(   t   callablet   argst   type(    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyt   got_accepted_types   s    (   t   get_accepted_message_typest   addCallback(   t   selfR   R   R   t   deferred_typesR   (    (   R   R   R   s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyt   call_if_accepted   s    c            s+   |  j  ˆ  j ƒ  ƒ } | j ‡  f d †  ƒ S(   sQ  Call a given handler as soon as a certain event occurs.

        @param handlers: A dictionary mapping event types to callables, where
            an event type is string (the name of the event). When the first of
            the given event types occurs in the broker reactor, the associated
            callable will be fired.
        c            s   ˆ  |  ƒ  S(   N(    (   t
   event_type(   t   handlers(    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyt   <lambda>    s    (   t   listen_eventst   keysR   (   R   R   R   (    (   R   s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyt   call_on_event   s    (   t   __name__t
   __module__R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyR      s   	
t   FakeRemoteBrokerc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s@   Looks like L{RemoteBroker}, but actually talks to local objects.c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t	   exchangert   message_storet   broker_server(   R   R   R    R!   (    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyt   __init__&   s    		c            se   t  |  j | d ƒ ‰  | t |  j ƒ k rU ˆ  d k	 rU t ˆ  ƒ rU ‡  f d †  } | St | ƒ ‚ d S(   s~   
        Pass attributes through to the real L{BrokerServer}, after checking
        that they're encodable with AMP.
        c             sh   x# |  D] } t  j | ƒ s t ‚ q Wx/ | j ƒ  D]! \ } } t  j | ƒ s3 t ‚ q3 Wt ˆ  |  | Ž S(   N(   R   t   checkt   AssertionErrort	   iteritemsR   (   R   t   kwargst   argt   kt   v(   t   original(    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyt   method4   s
    N(   t   getattrR!   t   NoneR   R   t   AttributeError(   R   t   nameR+   (    (   R*   s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyt   __getattr__+   s    c         G   s,   | |  j  j ƒ  k r" t | | Œ St d  ƒ S(   N(   R    t   get_accepted_typesR    R   R-   (   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyR   >   s    (   R   R   t   __doc__R"   R0   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyR   #   s   		t   RemoteBrokerConnectorc           B   s   e  Z d  Z e Z e Z RS(   s6   Helper to create connections with the L{BrokerServer}.(   R   R   R2   R   t   remoteR   t	   component(    (    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyR3   D   s   t   RemoteClientConnectorc           B   s   e  Z d  Z e Z RS(   s6   Helper to create connections with the L{BrokerServer}.(   R   R   R2   R   R5   (    (    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyR6   K   s   t   RemoteMonitorConnectorc           B   s   e  Z d  Z e Z RS(   s1   Helper to create connections with the L{Monitor}.(   R   R   R2   R	   R5   (    (    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyR7   Q   s   t   RemoteManagerConnectorc           B   s   e  Z d  Z e Z RS(   s4   Helper for creating connections with the L{Monitor}.(   R   R   R2   R
   R5   (    (    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyR8   W   s   c          C   s&   t  t t t g }  t d „  |  Dƒ ƒ S(   sB   Get a mapping of component name to connectors, for all components.c         s   s!   |  ] } | j  j | f Vq d  S(   N(   R5   R/   (   t   .0t	   connector(    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pys	   <genexpr>f   s   (   R3   R6   R7   R8   t   dict(   t   all_connectors(    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyt   get_component_registry]   s    	N(   t   twisted.internet.deferR    R   R   t   landscape.lib.ampR   R   t   landscape.ampR   R   t   landscape.broker.serverR   t   landscape.broker.clientR   t   landscape.monitor.monitorR	   t   landscape.manager.managerR
   R   t   objectR   R3   R6   R7   R8   R=   (    (    (    s8   /usr/lib/python2.7/dist-packages/landscape/broker/amp.pyt   <module>   s   !