ó
―-'Nc           @   sr   d  d l  Z  d  d l m Z m Z d  d l m Z d  d l m Z d e f d     YZ	 d e f d     YZ
 d S(	   iĸĸĸĸN(   t   LSB_RELEASE_FILENAMEt   parse_lsb_release(   t   get_fqdn(   t   MonitorPlugint   DistributionInfoErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR      s   t   ComputerInfoc           B   s   e  Z d  Z d Z e d e d d  Z d   Z e d  Z	 e d  Z
 e d  Z d	   Z d
   Z d   Z d   Z d   Z RS(   s7   Plugin captures and reports basic computer information.s   computer-infos   /proc/meminfot   /c         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   t	   _get_fqdnt   _meminfo_filet   _lsb_release_filenamet
   _root_path(   t   selfR   t   meminfo_filet   lsb_release_filenamet	   root_path(    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyt   __init__   s    			c         C   sF   t  t |   j |  |  j d |  j t  |  j d |  j t  d  S(   Ns   computer-infos   distribution-info(   t   superR   t   registert   call_on_acceptedt   send_computer_messaget   Truet   send_distribution_message(   R   t   registry(    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR      s
    		c         C   sI   |  j    } | rE d | d <t j d  |  j j j | d | n  d  S(   Ns   computer-infot   types,   Queueing message with updated computer info.t   urgent(   t   _create_computer_info_messaget   loggingt   infoR   t   brokert   send_message(   R   R   t   message(    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR   !   s
    
c         C   sI   |  j    } | rE d | d <t j d  |  j j j | d | n  d  S(   Ns   distribution-infoR   s0   Queueing message with updated distribution info.R   (   t!   _create_distribution_info_messageR   R   R   R   R   (   R   R   R    (    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR   (   s
    
c         C   s<   |  j  j } | j d |  j |  | j d |  j |  d  S(   Ns   computer-infos   distribution-info(   R   R   t   call_if_acceptedR   R   (   R   R   R   (    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyt   exchange/   s
    		c         C   s[   i  } |  j  | d |  j    |  j   \ } } |  j  | d |  |  j  | d |  | S(   Nt   hostnames   total-memorys
   total-swap(   t   _add_if_newR	   t   _get_memory_info(   R   R    t   total_memoryt
   total_swap(    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR   6   s    c         C   s<   | |  j  j |  k r8 |  j  j | |  | | | <n  d  S(   N(   t   _persistt   gett   set(   R   R    t   keyt   value(    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR%   @   s    c         C   s?   |  j    } | |  j j d  k r; |  j j d |  | Sd  S(   Ns   distribution-info(   t   _get_distribution_infoR)   R*   R+   t   None(   R   R    (    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR!   E   s
    c         C   sŪ   i  } t  |  j  } xr | D]j } | d k r | j d  } | d } | d	 k r t | d j   j d  d  } | | | <q q q W| j   | d d | d d f S(
   s>   Get details in megabytes and return a C{(memory, swap)} tuple.s   
t   :i    t   MemTotalt	   SwapTotali   t    i   (   R1   R2   (   t   openR
   t   splitt   intt   stript   close(   R   R    t   filet   linet   partsR,   R-   (    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR&   L   s    
#
c         C   s    i  } | j  t |  j   | S(   s#   Get details about the distribution.(   t   updateR   R   (   R   R    (    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR.   Z   s    (   R   R   t   __doc__t   persist_nameR   R    R   R   t   FalseR   R   R#   R   R%   R!   R&   R.   (    (    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR      s   		
			(   R   t   landscape.lib.lsb_releaseR    R   t   landscape.lib.networkR   t   landscape.monitor.pluginR   t	   ExceptionR   R   (    (    (    sB   /usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyt   <module>   s
   