
    d	                     j    d dl Z d dlZd dlmZ d dlmZ d Zde_        d Zd Z	d Z
d Zd	 Zd
 Zd Zy)    N)
get_osutil)	shellutilc                  h    t         j                  t               t         _        t         j                  S )N)_get_os_utilvaluer        G/usr/lib/python3/dist-packages/azurelinuxagent/common/osutil/systemd.pyr   r      s$    !'\r	   c                  @    t         j                  j                  d      S )z
    Determine if systemd is managing system services; the implementation follows the same strategy as, for example,
    sd_booted() in libsystemd, or /usr/sbin/service
    z/run/systemd/system/)ospathexistsr   r	   r
   
is_systemdr       s    
 77>>011r	   c                  0    t        j                  ddg      S )N	systemctlz	--version)r   run_commandr   r	   r
   get_versionr   (   s       +{!;<<r	   c                  2    t               j                         S )z"
    e.g. /lib/systemd/system
    )r   "get_systemd_unit_file_install_pathr   r	   r
   get_unit_file_install_pathr   1   s     ><<>>r	   c                  8    t               j                         dz   S )z#
    e.g. walinuxagent.service
    z.service)r   get_service_namer   r	   r
   get_agent_unit_namer   8   s     >**,z99r	   c                  b    t         j                  j                  t               t	                     S )z7
    e.g. /lib/systemd/system/walinuxagent.service
    )r   r   joinr   r   r   r	   r
   get_agent_unit_filer   ?   s!     77<<246I6KLLr	   c                      t         j                  j                  t               dj	                  t                           S )z9
    e.g. /lib/systemd/system/walinuxagent.service.d
    z{0}.d)r   r   r   r   formatr   r   r	   r
   get_agent_drop_in_pathr   F   s*     77<<24gnnEXEZ6[\\r	   c                     t        j                  dd| d|g      }t        j                  d|      }|t	        dj                  ||             |j                  d      S )Nr   showz
--propertyz[^=]+=(?P<value>.+)zCan't find property {0} of {1}r   )r   r   rematch
ValueErrorr   group)	unit_nameproperty_nameoutputr#   s       r
   get_unit_propertyr)   M   s_    ""KLR_#`aF HH*F3E}9@@PYZ[[;;wr	   )r   r"   azurelinuxagent.common.osutilr   azurelinuxagent.common.utilsr   r   r   r   r   r   r   r   r   r)   r   r	   r
   <module>r,      sG   $ 
 	 4 2  2=?:M] r	   