
\c           @   s   d  d l  Z  d  d l j Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l	 Z	 d  d l
 m Z m Z e j j   Z d e f d     YZ d S(   iN(   t   commands(   t   Popent   PIPEt   Pluginc           B   so  e  Z d  Z d   Z d   Z d   Z e d    Z e d    Z	 e d    Z
 e d    Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e d  Z d   Z d   Z  d   Z! e d  Z" d   Z# d   Z$ e d   Z% d!   Z& d"   Z' d#   Z( d$   Z) d%   Z* d&   Z+ d= d= d= d'  Z- d= d(  Z. d= d)  Z/ d= d*  Z0 d+   Z1 d,   Z2 d-   Z3 d.   Z4 d/   Z5 d= e d0  Z6 d= d= d1  Z7 d2   Z8 d3   Z9 d4   Z: d= d5  Z; d= d6  Z< d7   Z= d8   Z> d9   Z? d:   Z@ d;   ZA d<   ZB RS(>   s  
	Base class for all plugins.

	Plugins change various system settings in order to get desired performance or power
	saving. Plugins use Monitor objects to get information from the running system.

	Intentionally a lot of logic is included in the plugin to increase plugin flexibility.
	c	   	      C   s   | j  |  j j  |  _ | |  _ | |  _ | |  _ | |  _ | |  _ t	 j
   |  _ |  j   | |  _ | |  _ t |  _ t |  _ |  j   |  _ t   |  _ d S(   s   Plugin constructor.N(   t   createt	   __class__t   __name__t   _storaget   _monitors_repositoryt   _hardware_inventoryt   _device_matchert   _device_matcher_udevt   _instance_factoryt   collectionst   OrderedDictt
   _instancest   _init_commandst   _global_cfgt
   _variablest   Falset   _has_dynamic_optionst   _devices_initedt#   _get_config_options_used_by_dynamict   _options_used_by_dynamicR    t   _cmd(	   t   selft   monitors_repositoryt   storage_factoryt   hardware_inventoryt   device_matchert   device_matcher_udevt   instance_factoryt
   global_cfgt	   variables(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   __init__   s    					
				c         C   s   |  j    d  S(   N(   t   destroy_instances(   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   cleanup,   s    c         C   s#   |  j  s |  j   t |  _  n  d  S(   N(   R   t   _init_devicest   True(   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   init_devices/   s    	
c         C   s'   |  j  j j d  d j d d  d S(   Nt   .it   _i   (   R   t
   __module__t   split(   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   name4   s    c         C   s   i  S(   s-   Default configuration options for the plugin.(    (   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _get_config_options<   s    c         C   s   i  S(   s*   Explanation of each config option function(    (   t   cls(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   get_config_options_hintsA   s    c         C   s   g  S(   sn   List of config options used by dynamic tuning. Their previous values will be automatically saved and restored.(    (   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   F   s    c         C   sj   |  j    j   } xQ | D]I } | | k s4 |  j rE | | | | <q t j d | |  j j f  q W| S(   s3   Merge provided options with plugin default options.s$   Unknown option '%s' for plugin '%s'.(   R-   t   copyR   t   logt   warnR   R   (   R   t   optionst	   effectivet   key(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _get_effective_optionsK   s    !c         C   s>   t  |  t k r | St |  j   } | d k p= | d k S(   Nt   truet   1(   t   typet   boolt   strt   lower(   R   t   value(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _option_boolV   s    c   	      C   sf   | |  j  k r" t d |   n  |  j |  } |  j j |  | | | | | |  } | |  j  | <| S(   s8   Create new instance of the plugin and seize the devices.s.   Plugin instance with name '%s' already exists.(   R   t	   ExceptionR6   R   R   (	   R   R,   t   devices_expressiont   devices_udev_regext
   script_pret   script_postR3   t   effective_optionst   instance(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   create_instance`   s    c         C   s{   | j  |  k r( t d | |  f   n  | j |  j k rM t d |   n  |  j | j } |  j |  |  j | j =d S(   s   Destroy existing instance.s9   Plugin instance '%s' does not belong to this plugin '%s'.s+   Plugin instance '%s' was already destroyed.N(   t   _pluginR?   R,   R   t   _destroy_instance(   R   RE   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   destroy_instancel   s    c         C   s.   t  j d | j |  j f  |  j |  d S(   s   Initialize an instance.s   initializing instance %s (%s)N(   R1   t   debugR,   t   _instance_init(   R   RE   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   initialize_instancew   s    c         C   s[   xG t  |  j j    D]0 } t j d | j |  j f  |  j |  q W|  j j   d S(   s   Destroy all instances.s   destroying instance %s (%s)N(   t   listR   t   valuesR1   RJ   R,   RH   t   clear(   R   RE   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR#   |   s    c         C   s   |  j  |  |  j |  d  S(   N(   t   release_devicest   _instance_cleanup(   R   RE   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyRH      s    c         C   s   t     d  S(   N(   t   NotImplementedError(   R   RE   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyRK      s    c         C   s   t     d  S(   N(   RR   (   R   RE   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyRQ      s    c         C   s%   t  |  _ t   |  _ t   |  _ d  S(   N(   R   t   _devices_supportedt   sett   _assigned_devicest   _free_devices(   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR%      s    	c         C   s   d S(   s   Override this in a subclass to transform a list of device names (e.g. ['sda'])
		   to a list of pyudev.Device objects, if your plugin supports itN(   t   None(   R   t   devices(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _get_device_objects   s    c         C   s   | j  d  k r+ t |  j j | j |   S|  j |  } | d  k r` t j d |  j	  t   S|  j
 j | j  |  } t g  | D] } | j ^ q  Sd  S(   Ns<   Plugin '%s' does not support the 'devices_udev_regex' option(   RA   RW   RT   R
   t
   match_listR@   RY   R1   t   errorR,   R   t   sys_name(   R   RE   RX   t   udev_devicest   x(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _get_matching_devices   s    c         C   s   |  j  s d  St j d | j  |  j | |  j  } t |  d k | _ | j sk t j d | j  n} | j } | j |  j k r | d |  j 7} n  t j	 d | d j
 |  f  | j j |  |  j | O_ |  j | 8_ d  S(   Ns    assigning devices to instance %si    s*   instance %s: no matching devices availables    (%s)s!   instance %s: assigning devices %ss   , (   RS   R1   RJ   R,   R_   RV   t   lent   activeR2   t   infot   joint   assigned_devicest   updateRU   (   R   RE   t	   to_assignR,   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   assign_free_devices   s    			 c         C   si   |  j  s d  S| j | j B|  j @} t | _ | j j   | j j   |  j | 8_ |  j | O_ d  S(   N(   RS   t   processed_devicesRd   RU   R   Ra   RO   RV   (   R   RE   t
   to_release(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyRP      s    	
	c         C   s7   |  j  s d  g } n  x | D] } | | |  q Wd  S(   N(   RS   RW   (   R   RE   t   callbackRX   t   device(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _run_for_each_device   s    	c         C   s   d  S(   N(    (   R   RE   t   enabling(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _instance_pre_static   s    c         C   s   d  S(   N(    (   R   RE   Rm   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _instance_post_static   s    c         C   s  | d  k r d  St |  d k r@ t j d | j | f  d  S| j d  sd t j d d  t St j	 j
 |  } t } xR| D]J} t j }	 |	 j |  j j    | g }
 | r |
 j d  n  |
 j |  t j d | t |
  f  t j d t t |	 j      y t | g |
 d	 t d
 t d t d |	 d | d t } | j   \ } } | j rt j d | | j | d  f  t } n  Wq t t f k
 r} t j d | | f  t } q Xq W| S(   Ni    s1   Instance '%s': no device to call script '%s' for.t   /s<   Relative paths cannot be used in script_pre or script_post. s   Use ${i:PROFILE_DIR}.t   full_rollbacks'   calling script '%s' with arguments '%s's   using environment '%s't   stdoutt   stderrt	   close_fdst   envt   cwdt   universal_newliness   script '%s' error: %d, '%s'is   script '%s' error: %s(   RW   R`   R1   R2   R,   t
   startswithR[   R   t   ost   patht   dirnameR&   t   environRe   R   t   get_envt   appendRb   R;   RJ   RM   t   itemsR   R   t   communicatet
   returncodet   OSErrort   IOError(   R   RE   t   scriptt   opRX   Rq   t   dir_namet   rett   devR|   t	   argumentst   proct   outt   errt   e(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _call_device_script   sB    			#	!c         C   s   | j  s d S| j r~ |  j | | j d | j  |  j | t  |  j |  |  j | t  |  j | | j	 d | j  n  | j
 r |  j j t j t j  r |  j | |  j | j  n  | j j | j  | j j   d S(   sG   
		Apply static and dynamic tuning if the plugin instance is active.
		Nt   apply(   Ra   t   has_static_tuningR   RB   Rd   Rn   R&   t   _instance_apply_staticRo   RC   t   has_dynamic_tuningR   t   gett   constst   CFG_DYNAMIC_TUNINGt   CFG_DEF_DYNAMIC_TUNINGRl   t   _instance_apply_dynamicRh   Re   RO   (   R   RE   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   instance_apply_tuning   s    		$c         C   s   | j  s d St | j  d k rB t j d d j | j   n  | j j   } | j	 r |  j
 | | j d |  t k r t S|  j | | |  t k r t S|  j
 | | j d |  t k r t St Sd Sd S(   s<   
		Verify static tuning if the plugin instance is active.
		i    s)   BUG: Some devices have not been tuned: %ss   , t   verifyN(   Ra   RW   R`   Rd   R1   R[   Rc   Rh   R0   R   R   RB   R   t   _instance_verify_staticRC   R&   (   R   RE   t   ignore_missingRX   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   instance_verify_tuning  s    			!!c         C   sW   | j  s d S| j rS |  j j t j t j  rS |  j | |  j | j	 j
    n  d S(   s<   
		Apply dynamic tuning if the plugin instance is active.
		N(   Ra   R   R   R   R   R   R   Rl   t   _instance_update_dynamicRh   R0   (   R   RE   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   instance_update_tuning$  s    	$c         C   s   | j  r@ |  j j t j t j  r@ |  j | |  j | j  n  | j	 r |  j
 | | j d | j d | |  j | t  |  j | |  |  j | t  |  j
 | | j d | j d | n  d S(   s8   
		Remove all tunings applied by the plugin instance.
		t   unapplyRq   N(   R   R   R   R   R   R   Rl   t   _instance_unapply_dynamicRh   R   R   RC   Rn   R   t   _instance_unapply_staticRo   RB   (   R   RE   Rq   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   instance_unapply_tuning-  s    $	c         C   s$   |  j  |  |  j | | j  d  S(   N(   t    _execute_all_non_device_commandst   _execute_all_device_commandsRd   (   R   RE   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   <  s    c         C   sO   t  } |  j | |  t k r' t } n  |  j | | |  t k rK t } n  | S(   N(   R&   t   _verify_all_non_device_commandsR   t   _verify_all_device_commands(   R   RE   R   RX   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   @  s    		c         C   s$   |  j  | | j  |  j |  d  S(   N(   t   _cleanup_all_device_commandsRh   t    _cleanup_all_non_device_commands(   R   RE   Rq   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   H  s    	
c         C   sw   x` g  |  j  D]. } |  j | |  j | |  d  k r | ^ q D]  } |  j | |  j | |  q? W|  j | |  d  S(   N(   R   t   _storage_gett	   _commandsRW   t   _check_and_save_valueR   (   R   RE   Rk   t   optt   option(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   M  s    Ec         C   s   t     d  S(   N(   RR   (   R   RE   Rk   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   S  s    c         C   s   t     d  S(   N(   RR   (   R   RE   Rk   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   V  s    c         C   s'   t  j   |  _ |  j   |  j   d S(   s   
		Initialize commands.
		N(   R   R   R   t   _autoregister_commandst   _check_commands(   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   ]  s    
c         C   s\  x%|  j  j D]} | j d  r( q n  t |  |  } t | d  sL q n  | j d } |  j j | i | d 6 } d | j k r d | d <| | d <| j d | d <| j d | d <nZ d | j k r | | d <n> d | j k r| | d <| j d | d <| j d | d <n  | |  j | <q Wt	 j
 t t |  j j    d	 d
    |  _ d S(   sd   
		Register all commands marked using @command_set, @command_get, and @command_custom decorators.
		t   __t   _commandR,   RT   t   customt
   per_devicet   priorityR   R5   c         S   s   |  d d S(   Ni   R   (    (   t	   name_info(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   <lambda>  s    N(   R   t   __dict__Rx   t   getattrt   hasattrR   R   R   RW   R   R   t   sortedt   iterR   (   R   t   member_namet   membert   command_nameRb   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   e  s*    


c         C   sm   xf t  |  j j    D]O \ } } | j d t  r: q n  d | k sR d | k r t d |   q q Wd S(   s2   
		Check if all commands are defined correctly.
		R   R   RT   s,   Plugin command '%s' is not defined correctlyN(   RM   R   R   R   R   t	   TypeError(   R   R   t   command(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR     s
    "c         C   sk   t  |   j } | d  k r! d n | } | d  k r9 d n | } | d  k rQ d n | } d | | | | f S(   Nt    s   %s/%s/%s/%s(   R9   R   RW   (   R   t   instance_nameR   t   device_namet
   class_name(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _storage_key  s    	c         C   s3   |  j  | j | d |  } |  j j | |  d  S(   NR,   (   R   R,   R   RT   (   R   RE   R   R=   R   R5   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _storage_set  s    c         C   s,   |  j  | j | d |  } |  j j |  S(   NR,   (   R   R,   R   R   (   R   RE   R   R   R5   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR     s    c         C   s,   |  j  | j | d |  } |  j j |  S(   NR,   (   R   R,   R   t   unset(   R   RE   R   R   R5   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _storage_unset  s    c         C   s   x g  t  |  j j    D] } | d s | ^ q D]M } |  j j | j j | d d    } | d  k	 r3 |  j | | |  q3 q3 Wd  S(   NR   R,   (	   RM   R   RN   R   t   expandR3   R   RW   t   _execute_non_device_command(   R   RE   R   t	   new_value(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR     s    9%c         C   s   x g  t  |  j j    D] } | d r | ^ q D]d } |  j j | j j | d d    } | d  k rp q3 n  x$ | D] } |  j | | | |  qw Wq3 Wd  S(   NR   R,   (	   RM   R   RN   R   R   R3   R   RW   t   _execute_device_command(   R   RE   RX   R   R   Rk   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR     s    9%c         C   s   t  } x g  t |  j j    D] } | d s | ^ q D]a } |  j j | j j | d d    } | d  k	 r9 |  j	 | | | |  t
 k r t
 } q q9 q9 W| S(   NR   R,   (   R&   RM   R   RN   R   R   R3   R   RW   t   _verify_non_device_commandR   (   R   RE   R   R   R   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR     s    9%c         C   s   t  } x g  t |  j j    D] } | d r | ^ q D]l } | j j | d d   } | d  k rj q9 n  x8 | D]0 } |  j | | | | |  t k rq t } qq qq Wq9 W| S(   NR   R,   (	   R&   RM   R   RN   R3   R   RW   t   _verify_device_commandR   (   R   RE   RX   R   R   R   R   Rk   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR     s    9!c         C   s   | d  k	 r t |  } t |  d k r. | S| d  } | d } | d  k rb | d k r^ | S| Syb | d k r t |  t |  k r | Sd  Sn/ | d k r t |  t |  k  r | Sd  Sn  Wq t k
 r t j d | | | | f  q Xn  | S(   Ni   t   <t   >sh   cannot compare new value '%s' with current value '%s' by operator '%s', using '%s' directly as new value(   R   R   (   RW   R;   R`   t   intt
   ValueErrorR1   R2   (   R   R   t   current_valuet   nwsR   t   val(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _process_assignment_modifiers  s(    

$c         C   s/   | d  k	 r  | d | d | S| d   Sd  S(   NR   R   (   RW   (   R   R   Rk   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _get_current_value  s    c         C   sY   |  j  | |  } |  j | |  } | d  k	 rU | d  k	 rU |  j | | | |  n  | S(   N(   R   R   RW   R   (   R   RE   R   Rk   R   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR     s
    c         C   so   | d d  k	 r- | d t | | t t  n> |  j | | | |  } | d  k	 rk | d | | d t n  d  S(   NR   RT   t   sim(   RW   R&   R   R   (   R   RE   R   Rk   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR     s
    c         C   si   | d d  k	 r* | d t | t t  n; |  j | | d  |  } | d  k	 re | d | d t n  d  S(   NR   RT   R   (   RW   R&   R   R   (   R   RE   R   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR     s
    c         C   sA   |  j  j t |   } t j d |  r= t j d d |  S| S(   Ns   \s*(0+,?)+([\da-fA-F]*,?)*\s*$s   ^\s*(0+,?)+R   (   R   t   unquoteR;   t   ret   matcht   sub(   R   R=   t   v(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _norm_value  s    c   	      C   s  | d  k r d  St } | d  k ri | ri | d  k rK t j t j |  n t j t j | | f  t S| d  k	 re|  j |  } |  j |  } y t	 |  t	 |  k } Wqet
 k
 ray" t	 | d  t	 | d  k } Wqbt
 k
 r]t |  t |  k } | s^t |  j d  } x3 | D]( } | j   } | | k } | r+Pq+q+Wq^qbXqeXn  |  j | | | | d | | S(   Ni   t   |Rk   (   RW   R   R1   Rb   R   t    STR_VERIFY_PROFILE_VALUE_MISSINGt'   STR_VERIFY_PROFILE_DEVICE_VALUE_MISSINGR&   R   R   R   R;   R+   t   stript   _log_verification_result(	   R   R,   R   R   R   Rk   R   t   valsR   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   _verify_value
  s8    "c         C   s   | rh | d  k r; t j t j | t |  j   f  n) t j t j | | t |  j   f  t S| d  k r t j	 t j
 | t |  j   t |  j   f  n8 t j	 t j | | t |  j   t |  j   f  t Sd  S(   N(   RW   R1   Rb   R   t   STR_VERIFY_PROFILE_VALUE_OKR;   R   t"   STR_VERIFY_PROFILE_DEVICE_VALUE_OKR&   R[   t   STR_VERIFY_PROFILE_VALUE_FAILt$   STR_VERIFY_PROFILE_DEVICE_VALUE_FAILR   (   R   R,   t   successR   R   Rk   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   *  s    ))88c         C   s   | d d  k	 r* | d t | | t |  S|  j | | d | } |  j | |  } | d  k rd d  S| d | | t  } |  j | d | | | |  S(   NR   R   RT   R,   (   RW   R&   R   R   R   (   R   RE   R   Rk   R   R   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   9  s    c         C   s   | d d  k	 r' | d t | t |  S|  j |  } |  j | |  } | d  k rX d  S| d | t  } |  j | d | | |  S(   NR   RT   R,   (   RW   R&   R   R   R   (   R   RE   R   R   R   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   C  s    c         C   s   x t  g  t |  j j    D] } | d s | ^ q  D]K } | j j | d d   d  k	 sq | d |  j k r9 |  j | |  q9 q9 Wd  S(   NR   R,   (	   t   reversedRM   R   RN   R3   R   RW   R   t   _cleanup_non_device_command(   R   RE   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   M  s    ?2c         C   s   x t  g  t |  j j    D] } | d r | ^ q  D]_ } | j j | d d   d  k	 sq | d |  j k r9 x$ | D] } |  j | | |  qx Wq9 q9 Wd  S(   NR   R,   (	   R   RM   R   RN   R3   R   RW   R   t   _cleanup_device_command(   R   RE   RX   R   Rk   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   R  s    ?2c         C   s   | d d  k	 r- | d t d  | t t  nN |  j | | |  } | d  k	 rh | d | | d t n  |  j | | |  d  S(   NR   RT   R   (   RW   R   R   R   (   R   RE   R   Rk   t	   old_value(    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   X  s    c         C   ss   | d d  k	 r* | d t d  t t  nE |  j | |  } | d  k	 r_ | d | d t n  |  j | |  d  S(   NR   RT   R   (   RW   R   R   R   (   R   RE   R   R   (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR   a  s    N(C   R   R*   t   __doc__R"   R$   R'   t   propertyR,   t   classmethodR-   R/   R   R6   R>   RF   RI   RL   R#   RH   RK   RQ   R%   RY   R_   Rg   RP   Rl   Rn   Ro   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   RW   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyR      s|   					
															#																					!	
	
				(   R   t   tuned.constsR   t   tuned.profiles.variablest   tunedt
   tuned.logsR   t   tuned.utils.commandsR    Ry   t
   subprocessR   R   t   logsR   R1   t   objectR   (    (    (    s6   /usr/lib/python2.7/site-packages/tuned/plugins/base.pyt   <module>   s   