ó
ÍÿŠTc           @   sá   d  Z  d d l Z d d l m Z m Z d d l 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 d
 l m Z d d l m Z d d l m Z d e f d „  ƒ  YZ d „  Z d S(   s    Deployment code for the monitor.iÿÿÿÿN(   t   LandscapeServicet   run_landscape_service(   t   ComponentPublisher(   t   RegistrationHandlert   Identity(   t   BrokerConfiguration(   t   HTTPTransport(   t   MessageExchange(   t   ExchangeStore(   t   Pinger(   t   get_default_message_store(   t   BrokerServert   BrokerServicec           B   s>   e  Z d  Z e Z e Z e j Z	 d „  Z
 d „  Z d „  Z RS(   s"  The core C{Service} of the Landscape Broker C{Application}.

    The Landscape broker service handles all the communication between the
    client and server.  When started it creates and runs all necessary
    components to exchange messages with the Landscape server.

    @cvar service_name: C{broker}

    @ivar persist_filename: Path to broker-specific persistent data.
    @ivar persist: A L{Persist} object saving and loading data from
        C{self.persist_filename}.
    @ivar message_store: A L{MessageStore} used by the C{exchanger} to
        queue outgoing messages.
    @ivar transport: An L{HTTPTransport} used by the C{exchanger} to deliver
        messages.
    @ivar identity: The L{Identity} of the Landscape client the broker runs on.
    @ivar exchanger: The L{MessageExchange} exchanges messages with the server.
    @ivar pinger: The L{Pinger} checks if the server has new messages for us.
    @ivar registration: The L{RegistrationHandler} performs the initial
        registration.

    @param config: A L{BrokerConfiguration}.
    c         C   sk  t  j j | j d |  j f ƒ |  _ t t |  ƒ j | ƒ |  j	 |  j
 | j | j ƒ |  _ t |  j | j ƒ |  _ t |  j |  j ƒ |  _ t |  j j ƒ } t |  j
 |  j |  j |  j | | ƒ |  _ |  j |  j
 |  j |  j | ƒ |  _ t | |  j |  j
 |  j |  j |  j ƒ |  _ t |  j |  j
 |  j |  j |  j |  j ƒ |  _ t |  j |  j
 |  j ƒ |  _  d  S(   Ns
   %s.bpickle(!   t   ost   patht   joint	   data_patht   service_namet   persist_filenamet   superR   t   __init__t   transport_factoryt   reactort   urlt   ssl_public_keyt	   transportR
   t   persistt   message_store_patht   message_storeR   t   configt   identityR   t   exchange_store_pathR   t	   exchangert   pinger_factoryt   pingerR   t   registrationR   t   brokerR   t	   publisher(   t   selfR   t   exchange_store(    (    s<   /usr/lib/python2.7/dist-packages/landscape/broker/service.pyR   .   s,    	c         C   s>   t  t |  ƒ j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  d S(   sâ   Start the broker.

        Create a L{BrokerServer} listening on C{broker_socket_path} for clients
        connecting with the L{BrokerServerConnector}, and start the
        L{MessageExchange} and L{Pinger} services.
        N(   R   R   t   startServiceR%   t   startR    R"   (   R&   (    (    s<   /usr/lib/python2.7/dist-packages/landscape/broker/service.pyR(   G   s    c         C   s>   |  j  j ƒ  |  j j ƒ  |  j j ƒ  t t |  ƒ j ƒ  d S(   s   Stop the broker.N(   R%   t   stopR    R"   R   R   t   stopService(   R&   (    (    s<   /usr/lib/python2.7/dist-packages/landscape/broker/service.pyR+   S   s    (   t   __name__t
   __module__t   __doc__R   R   R	   R!   R   t   nameR   R   R(   R+   (    (    (    s<   /usr/lib/python2.7/dist-packages/landscape/broker/service.pyR      s   			c         C   s   t  t t |  ƒ d S(   s7   Run the application, given some command line arguments.N(   R   R   R   (   t   args(    (    s<   /usr/lib/python2.7/dist-packages/landscape/broker/service.pyt   run[   s    (   R.   R   t   landscape.serviceR    R   t   landscape.ampR   t   landscape.broker.registrationR   R   t   landscape.broker.configR   t   landscape.broker.transportR   t   landscape.broker.exchangeR   t   landscape.broker.exchangestoreR   t   landscape.broker.pingR	   t   landscape.broker.storeR
   t   landscape.broker.serverR   R   R1   (    (    (    s<   /usr/lib/python2.7/dist-packages/landscape/broker/service.pyt   <module>   s   J