ó
ÍÿŠTc           @   sN   d  d l  Z  d  d l Z d  d l Z d  d l m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   MonitorPlugint   UpdateManagerc           B   sS   e  Z d  Z d Z d Z d Z d Z e Z d	 d „ Z
 d „  Z d „  Z d „  Z RS(
   s    
    Report on changes to the update-manager configuration.

    @param update_manager_filename: the path to the update-manager
        configuration file.
    s$   /etc/update-manager/release-upgradess   update-managert   packagei  c         C   s   | d  k	 r | |  _ n  d  S(   N(   t   Nonet   update_manager_filename(   t   selfR   (    (    sC   /usr/lib/python2.7/dist-packages/landscape/monitor/updatemanager.pyt   __init__   s    c         C   s›   t  j j |  j ƒ s d St |  j ƒ } t j ƒ  } | j | ƒ | j d d ƒ } d d d g } | | k r— d } d |  j | f } t	 j
 | ƒ n  | S(   s.  
        Retrieve the update-manager upgrade prompt which dictates when we
        should prompt users to upgrade the release.  Current valid values are
        "normal" (prompt on all the availability of all releases), "lts"
        (prompt only when LTS releases are available), and "never".
        t   normalt   DEFAULTt   Promptt   ltst   nevers6   %s contains invalid Prompt value. Should be one of %s.(   t   ost   patht   existsR   t   opent   ConfigParsert   SafeConfigParsert   readfpt   gett   loggingt   warning(   R   t   config_filet   parsert   promptt   valid_promptst   message(    (    sC   /usr/lib/python2.7/dist-packages/landscape/monitor/updatemanager.pyt   _get_prompt   s    
c         C   su   |  j  ƒ  } | |  j j d ƒ k r( d S|  j j d | ƒ i d d 6| d 6} t j d ƒ |  j j j | |  j	 ƒ S(   sH   
        Send the current upgrade release prompt to the server.
        R   Ns   update-manager-infot   types4   Queueing message with updated update-manager status.(
   R   t   _persistR   t   setR   t   infot   registryt   brokert   send_messaget   _session_id(   R   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/landscape/monitor/updatemanager.pyR"   7   s    
c         C   s   |  j  j j d |  j ƒ S(   sT   
        Send the update-manager-info messages, if the server accepts them.
        s   update-manager-info(   R    R!   t   call_if_acceptedR"   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/landscape/monitor/updatemanager.pyt   runF   s    N(   t   __name__t
   __module__t   __doc__R   t   persist_namet   scopet   run_intervalt   Truet   run_immediatelyR   R   R   R"   R%   (    (    (    sC   /usr/lib/python2.7/dist-packages/landscape/monitor/updatemanager.pyR      s   		(   R   R   R   t   landscape.monitor.pluginR    R   (    (    (    sC   /usr/lib/python2.7/dist-packages/landscape/monitor/updatemanager.pyt   <module>   s   