
-'Nc           @   sV  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z 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 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! m" Z" m# Z# d d l$ m% Z% d d l& m' Z' m( Z( m) Z) d d l* m+ Z+ d Z, d Z- d Z. d Z/ d e0 f d     YZ1 d e0 f d     YZ2 d e0 f d     YZ3 d e4 f d     YZ5 d e5 f d     YZ6 d e5 f d     YZ7 d  e5 f d!     YZ8 d" e f d#     YZ9 d$ e4 f d%     YZ: d& e f d'     YZ; d(   Z< d) e f d*     YZ= e! e# d+ d, d- d.  e# d/ d, d- d.  e# d0 d, d- d.  e# d1 d, d- d.  e# d2 d, d- d.  e# d3 d, d- d.  e# d4 d, d- d5  e# d6 d, d- d.  e# d7 d, d- d.  e" d8 d, d- d9  g
  Z> d:   Z? e j@ d d;  ZB d S(<   s   See L{WatchDog}.

The WatchDog must run as root, because it spawns the Landscape Manager.

The main C{landscape-client} program uses this watchdog.
iN(   t   warningt   infot   error(   t   reactor(   t   Deferredt   succeed(   t   ProcessProtocol(   t   ProcessExitedAlready(   t   Servicet   Application(   t   startApplication(   t   Configurationt   init_logging(   t   gather_results(   t   log_failure(   t   BootstrapListt   BootstrapFilet   BootstrapDirectory(   t   rotate_logs(   t   RemoteBrokerConnectort   RemoteMonitorConnectort   RemoteManagerConnector(   t   TwistedReactori
   i   i   t   DaemonErrorc           B   s   e  Z d  Z RS(   s(   One of the daemons could not be started.(   t   __name__t
   __module__t   __doc__(    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR   (   s   t   TimeoutErrorc           B   s   e  Z d  Z RS(   s   Something took too long.(   R   R   R   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR   ,   s   t   ExecutableNotFoundErrorc           B   s   e  Z d  Z RS(   s   An executable was not found.(   R   R   R   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR   0   s   t   Daemonc           B   s   e  Z d  Z d Z d Z d Z e e d d  Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z RS(   sf  A Landscape daemon which can be started and tracked.

    This class should be subclassed to specify individual daemon.

    @cvar program: The name of the executable program that will start this
        daemon.
    @cvar username: The name of the user to switch to, by default.
    @cvar service: The DBus service name that the program will be expected to
        listen on.
    @cvar max_retries: The maximum number of retries before giving up when
        trying to connect to the watched daemon.
    @cvar factor: The factor by which the delay between subsequent connection
        attempts will increase.
    t	   landscapei   g?c         C   s   | |  _  | |  _ t j j   |  _ t j   d k r t j |  j	  } | j
 |  _ | j |  _ | j |  j d <|  j	 |  j d <|  j	 |  j d <n d |  _ d |  _ | |  _ | |  _ d |  _ d |  _ d |  _ t |  _ d S(   s-  
        @param connector: The L{RemoteComponentConnector} of the daemon.
        @param reactor: The reactor used to spawn the process and schedule
            timed calls.
        @param verbose: Optionally, report more information when
            running this program.  Defaults to False.
        i    t   HOMEt   USERt   LOGNAMEN(   t
   _connectort   _reactort   ost   environt   copyt   _envt   getuidt   pwdt   getpwnamt   usernamet   pw_uidt   _uidt   pw_gidt   _gidt   pw_dirt   Nonet   _verboset   _configt   _processt   _last_startedt   _quick_startst   Truet   _allow_restart(   t   selft	   connectorR   t   verboset   configt   pwd_info(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   __init__H   s$    										c         C   si   t  j j t  j j t j d   } t  j j | |  j  } t  j j |  se t	 d | f   n  | S(   s   Find the fully-qualified path to the executable.

        If the executable can't be found, L{ExecutableNotFoundError} will be
        raised.
        i    s   %s doesn't exist(
   R$   t   patht   dirnamet   abspatht   syst   argvt   joint   programt   existsR   (   R9   R@   t
   executable(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   find_executableg   s
    %c         C   s  d |  _ t j   } |  j t | k rk |  j d 7_ |  j t k rt t d |  j  |  j	 j
   d Sn	 d |  _ | |  _ t |   |  _ |  j   } | d g } |  j s | j d  n  |  j r | j d |  j g  n  |  j	 j |  j | d | d	 |  j d
 |  j d |  j d S(   s   Start this daemon.i   s   Can't keep %s running. Exiting.Ni    s   --ignore-sigints   --quiets   -ct   argst   envt   uidt   gid(   R1   R4   t   timeR5   t   RESTART_BURST_DELAYR6   t   MAXIMUM_CONSECUTIVE_RESTARTSR   RE   R#   t   stopt   WatchedProcessProtocolRH   R2   t   appendR3   t   extendt   spawnProcessR'   R-   R/   (   R9   t   nowt   exeRI   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   starts   s&    					c         C   s    |  j  s t d  S|  j  j   S(   s   Stop this daemon.N(   R4   R   R1   t   kill(   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRP      s    	
c            sg    f d   }  j  j  j  j d t } | j   f d    | j |  | j d    | S(   s  Connect to the remote daemon over AMP and perform the given command.

        @param name: The name of the command to perform.
        @param args: Arguments list to be passed to the connect method
        @param kwargs: Keywords arguments to pass to the connect method.
        @return: A L{Deferred} resulting in C{True} if the command was
            successful or C{False} otherwise.
        @see: L{RemoteLandscapeComponentCreator.connect}.
        c            s     j  j   t S(   N(   R"   t
   disconnectR7   (   t   ignored(   R9   (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRY      s    t   quietc            s   t  |       S(   N(   t   getattr(   t   remote(   t   name(    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   <lambda>   s    c         S   s   t  S(   N(   t   False(   t   x(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR_      s    (   R"   t   connectt   max_retriest   factorR7   t   addCallbackt
   addErrback(   R9   R^   RI   t   kwargsRY   t	   connected(    (   R^   R9   s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   _connect_and_call   s    	c         C   s   |  j  d  S(   Nt   exit(   Ri   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   request_exit   s    c         C   s   |  j  d  S(   Nt   ping(   Ri   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt
   is_running   s    c         C   s    |  j  s t d  S|  j  j   S(   sN   
        Return a Deferred which will fire when the process has died.
        N(   R4   R   R1   t   wait(   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRn      s    	
c         C   s    |  j  s t d  S|  j  j   S(   s   
        Wait for the process to die for C{GRACEFUL_WAIT_PERIOD}. If it hasn't
        died by that point, send it a SIGTERM. If it doesn't die for
        C{SIGKILL_DELAY},
        N(   R4   R   R1   t   wait_or_die(   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRo      s    	
c         C   s   t  |  _ d S(   s   Called by the watchdog when starting to shut us down.

        It will prevent our L{WatchedProcessProtocol} to restart the process
        when it exits.
        N(   R`   R8   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   prepare_for_shutdown   s    c         C   s   |  j  S(   s>   Return a boolean indicating if the daemon should be restarted.(   R8   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   allow_restart   s    c         C   s   |  j  j   d  S(   N(   R4   R   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR      s    N(   R   R   R   R+   Rc   Rd   R   R`   R1   R>   RH   RW   RP   Ri   Rk   Rm   Rn   Ro   Rp   Rq   R   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR   4   s"   								
		t   Brokerc           B   s   e  Z d  Z RS(   s   landscape-broker(   R   R   RE   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRr      s   t   Monitorc           B   s   e  Z d  Z RS(   s   landscape-monitor(   R   R   RE   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRs      s   t   Managerc           B   s   e  Z d  Z d Z RS(   s   landscape-managert   root(   R   R   RE   R+   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRt      s   RQ   c           B   sq   e  Z d  Z e Z d   Z d   Z e d  Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z RS(   su   
    A process-watching protocol which sends any of its output to the log file
    and restarts it when it dies.
    c         C   s(   | |  _  d  |  _ d  |  _ d  |  _ d  S(   N(   t   daemonR1   t   _wait_resultt   _delayed_really_killt   _delayed_terminate(   R9   Rv   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR>      s    			c         C   s   |  j    |  j   S(   N(   t
   _terminateRn   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRX      s    
c         C   s   |  j  d  k	 r{ | r/ t d |  j j f  n  y |  j  j t j  Wn t k
 rY q{ Xt	 j
 t |  j  } | |  _ n  d  S(   Ns   %s didn't exit. Sending SIGTERM(   t	   transportR1   R    Rv   RE   t   signalProcesst   signalt   SIGTERMR   R   t	   callLatert   SIGKILL_DELAYt   _really_killRx   (   R9   t   warnt   delayed(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRz      s    c         C   sL   y |  j  j t j  Wn t k
 r* n Xt d |  j j  d  |  _	 d  S(   Ns    %s didn't die.  Sending SIGKILL.(
   R{   R|   R}   t   SIGKILLR   R    Rv   RE   R1   Rx   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR     s    c         C   sA   |  j  d  k	 r= y |  j  j t j  Wq= t k
 r9 q= Xn  d  S(   N(   R{   R1   R|   R}   t   SIGUSR1R   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR   
  s
    c         C   s/   |  j  j d  k r t d   St   |  _ |  j S(   N(   R{   t   pidR1   R   R   Rw   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRn     s    
c         C   s(   t  j t |  j d t |  _ |  j   S(   NR   (   R   R   t   GRACEFUL_WAIT_PERIODRz   R7   Ry   Rn   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRo     s    	c         C   s   t  j j |  d  S(   N(   RB   t   stdoutt   write(   R9   t   data(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   outReceived  s    c         C   s   t  j j |  d  S(   N(   RB   t   stderrR   (   R9   R   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   errReceived   s    c         C   s   |  j  d k	 r |  j  j   n  |  j d k	 rM |  j j   rM |  j j   n  |  j d k	 ro |  j j d  n |  j j   r |  j j	   n  d S(   s"   The process has ended; restart it.N(
   Rx   R1   t   cancelRy   t   activeRw   t   callbackRv   Rq   RW   (   R9   t   reason(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   processEnded#  s    (   R   R   R   R`   t   _killedR>   RX   Rz   R   R   Rn   Ro   R   R   R   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRQ      s   									t   WatchDogc           B   sk   e  Z d  Z e e d	 d	 d	 d	 d	 d  Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z RS(
   sj   
    The Landscape WatchDog starts all other landscape daemons and ensures that
    they are working.
    c   	   	   C   sa  t    } | d  k r' t t t g } n  | d  k rf t | k rf t t | |  d | d | j } n  | d  k r t | k r t t | |  d | d | j } n  | d  k r t | k r t t | |  d | d | j } n  | |  _	 | |  _
 | |  _ t d  |  j	 |  j
 |  j g  |  _ | |  _ d  |  _ t |  _ t j t j |  j  i  |  _ d  S(   NR;   R<   (   R   R1   Rr   Rs   Rt   R   R<   R   R   t   brokert   monitort   managert   filtert   daemonsR   t	   _checkingR`   t	   _stoppingR}   R   t   _notify_rotate_logst   _ping_failures(	   R9   R   R;   R<   R   R   R   t   enabled_daemonst   twisted_reactor(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR>   6  s0    				$			c         C   sb   g  } x= |  j  D]2 } | j   } | j | d   | j |  q Wd   } t |  j |  S(   s6   Return a list of any daemons that are already running.c         S   s
   |  | f S(   N(    (   Rm   t   d(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR_   \  s    c         S   s%   g  |  D] } | d r | d ^ q S(   Ni    i   (    (   t   rRa   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   got_all_results_  s    (   R   Rm   Re   RR   R   (   R9   t   resultsRv   t   resultR   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   check_runningT  s    	c         C   s,   x |  j  D] } | j   q
 W|  j   d S(   sm  
        Start all daemons. The broker will be started first, and no other
        daemons will be started before it is running and responding to DBUS
        messages.

        @return: A deferred which fires when all services have successfully
            started. If a daemon could not be started, the deferred will fail
            with L{DaemonError}.
        N(   R   RW   t   start_monitoring(   R9   Rv   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRW   c  s    
c         C   s   |  j  j d |  j  |  _ d S(   s;   Start monitoring processes which have already been started.i   N(   R   R   t   _checkR   (   R9   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR   q  s    c            s   | r  j  r t d   j f     j k rD d  j   <n   j   c d 7< j   d k r t d   j f    j   }    f d   } | j |  | Sn d  j   <d  S(   Ns   %s failed to respond to a ping.i    i   i   s   %s died! Restarting.c            s     j    d  j   <d  S(   Ni    (   RW   R   (   RZ   (   Rv   R9   (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   stopped  s    
(   R   R    RE   R   RP   t   addBoth(   R9   Rm   Rv   t   stoppingR   (    (   Rv   R9   s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   _restart_if_not_runningw  s    c            sl   g  } x=   j  D]2 } | j   } | j   j |  | j |  q W  f d   } t |  j |  d  S(   Nc            s     j  j d   j    _ d  S(   Ni   (   R   R   R   R   (   RZ   (   R9   (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt
   reschedule  s    (   R   Rm   Re   R   RR   R   R   (   R9   t   all_runningRv   Rm   R   (    (   R9   s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR     s    c            s     j  d  k	 r.   j  j   r.   j  j   n  t   _ x   j D] } | j   qA W  f d   }   j j	   } | j
 |  S(   Nc            sa   |  r+ g    j  D] } | j   ^ q } n, t d  g    j  D] } | j   ^ q? } t |  S(   NsF   Couldn't request that broker gracefully shut down; killing forcefully.(   R   Ro   R   RP   R   (   t   broker_stoppedRv   R   Ra   (   R9   (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   terminate_processes  s
    %
"(   R   R1   R   R   R7   R   R   Rp   R   Rk   Re   (   R9   Rv   R   R   (    (   R9   s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyRk     s    	c         C   s)   x |  j  D] } | j   q
 Wt   d  S(   N(   R   R   (   R9   R}   t   frameRv   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR     s    N(   R   R   R   R   R`   R1   R>   R   RW   R   R   R   Rk   R   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR   0  s   								t   WatchDogConfigurationc           B   s   e  Z d    Z d   Z RS(   c         C   sd   t  t |   j   } | j d d d d d | j d d d d d	 | j d
 d d d d | S(   Ns   --daemont   actiont
   store_truet   helps   Fork and run in the background.s
   --pid-filet   typet   strs   The file to write the PID to.s   --monitor-onlysb   Don't enable management features. This is useful if you want to run the client as a non-root user.(   t   superR   t   make_parsert
   add_option(   R9   t   parser(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR     s    c         C   s)   t  t g } |  j s% | j t  n  | S(   N(   Rr   Rs   t   monitor_onlyRR   Rt   (   R9   R   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   get_enabled_daemons  s    	(   R   R   R   R   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR     s   	c          C   s   t  j   r t  j d  n  t  j   t  j   rB t  j d  n  t  j d  t  j d t  j  }  xV t d  D]H } y t  j |  |  Wqq t	 k
 r } | j
 t
 j k r   q qq Xqq Wt  j |   d  S(   Ni    i?   s	   /dev/nulli   (   R$   t   forkt   _exitt   setsidt   umaskt   opent   O_RDWRt   ranget   dup2t   OSErrort   errnot   EBADFt   close(   t   nullt   it   e(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt	   daemonize  s    
t   WatchDogServicec           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   s>   | |  _  t d | j d | d | j    |  _ d |  _ d  S(   NR;   R<   R   i    (   R3   R   Rv   R   t   watchdogt	   exit_code(   R9   R<   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR>     s
    	c            sz   t  j    t j d   j j d   j j    j j   }   f d   }   f d   } | j	 |  | j
 |  | S(   Nt	   data_patht   log_dirc            s_   |  r> t  d d j d   |  D   d   _ t j   d  S  j   t d    j j   S(   Ns4   ERROR: The following daemons are already running: %ss   , c         s   s   |  ] } | j  Vq d  S(   N(   RE   (   t   .0Ra   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pys	   <genexpr>  s    i   s   Watchdog watching for daemons.(	   R   RD   R   R   t   crasht
   _daemonizeR   R   RW   (   t   running_daemons(   R9   (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   start_if_not_running  s    	


c            s$   t  |  d  d   _ t j   d  S(   Ns   Unknown error occurred!i   (   R   R   R   R   (   t   failure(   R9   (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   die  s    	(   R   t   startServicet   bootstrap_listt	   bootstrapR3   R   R   R   R   Re   Rf   (   R9   R   R   R   (    (   R9   s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR     s    c         C   sa   |  j  j r] t   |  j  j r] t |  j  j d  } | j t t j     | j	   q] n  d  S(   Nt   w(
   R3   Rv   R   t   pid_fileR   R   R   R$   t   getpidR   (   R9   t   stream(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR     s    c            sV   t  d  t j    t j t j t j    j j   } | j   f d    | S(   Ns   Stopping client...c            s
     j    S(   N(   t   _remove_pid(   R   (   R9   (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR_     s    (	   R   R   t   stopServiceR}   t   SIGINTt   SIG_IGNR   Rk   R   (   R9   t   done(    (   R9   s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR     s    
c         C   s~   |  j  j } | d  k	 rz t j | t j  rz t |  } | j   } | j   | t	 t j
    k rz t j |  qz n  d  S(   N(   R3   R   R1   R$   t   accesst   W_OKR   t   readR   R   R   t   unlink(   R9   R   R   R   (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR     s    !
(   R   R   R>   R   R   R   R   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR     s
   				s
   $data_pathR   Ru   i  s   $data_path/packages   $data_path/package/hash-ids   $data_path/package/binariess   $data_path/package/upgrade-tools   $data_path/messagess   $data_path/socketsi  s   $data_path/custom-graph-scriptss   $log_dirs   $data_path/package/databasei  c          C   sU   xN t  j j   D]= }  |  j d  s@ |  j d  s@ |  d k r t  j |  =q q Wd S(   sT  Unset dangerous environment variables.

    In particular unset all variables beginning with DEBIAN_ or DEBCONF_,
    to avoid any problems when landscape-client is invoked from its
    postinst script.  Some environment variables may be set which would affect
    *other* maintainer scripts which landscape-client invokes (via smart).
    t   DEBIAN_t   DEBCONF_t   LANDSCAPE_ATTACHMENTSt   MAILN(   R   R   (   R$   R%   t   keyst
   startswith(   t   key(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   clean_environment.  s
    c         C   s   t    t   } | j |   y t j d  j } Wn t k
 rS t j d  n Xt	 j
   d | f k r| t j d  n  t | d  t d  } t |  } | j |  | d	 k r d d l m } n  | j d t | t  | j   | j S(
   s  Start the watchdog.

    This is the topmost function that kicks off the Landscape client.  It
    cleans up the environment, loads the configuration, and starts the
    reactor.

    @param args: Command line arguments, including the program name as the
        first element.
    @param reactor: The reactor to use.  If none is specified, the global
        reactor is used.
    @raise SystemExit: if command line arguments are bad, or when landscape-
        client is not running as 'root' or 'landscape'.
    R   s#   The 'landscape' user doesn't exist!i    s:   landscape-client can only be run as 'root' or 'landscape'.R   s   landscape-clienti(   R   N(   R   R   t   loadR)   R*   R,   t   KeyErrorRB   Rj   R$   R(   R   R	   R   t   setServiceParentR1   t   twisted.internetR   R   R
   R`   t   runR   (   RI   R   R<   t   landscape_uidt   applicationt   watchdog_service(    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyR   =  s$    	
(C   R   R$   R   RB   R)   R}   RM   t   loggingR    R   R   R   R   t   twisted.internet.deferR   R   t   twisted.internet.protocolR   t   twisted.internet.errorR   t   twisted.application.serviceR   R	   t   twisted.application.appR
   t   landscape.deploymentR   R   t   landscape.lib.twisted_utilR   t   landscape.lib.logR   t   landscape.lib.bootstrapR   R   R   t   landscape.logR   t   landscape.broker.ampR   R   R   t   landscape.reactorR   R   RO   RN   R   t	   ExceptionR   R   R   t   objectR   Rr   Rs   Rt   RQ   R   R   R   R   R   R   RC   R1   R   (    (    (    s6   /usr/lib/python2.7/dist-packages/landscape/watchdog.pyt   <module>   sj   O	@	