
    x[h              
           U d 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
 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 degeg dZeed<    ej0                  e      ZdZdZdede
defdZdede
dede ddf
dZ!y)z3Install hotplug udev rules if supported and enabled    N)stagessubputil)Cloud)Config)
MetaSchema)ALL_DISTROS)
EventScope	EventType)PER_INSTANCE)
DataSourcecc_install_hotplug)iddistros	frequencyactivate_by_schema_keysmetaz2/etc/udev/rules.d/90-cloud-init-hook-hotplug.rulesz# Installed by cloud-init due to network hotplug userdata
ACTION!="add|remove", GOTO="cloudinit_end"{extra_rules}
LABEL="cloudinit_hook"
SUBSYSTEM=="net", RUN+="{libexecdir}/hook-hotplug"
LABEL="cloudinit_end"

datasourcecfgnetwork_hotplug_enabledc                    t         j                  | j                  t         j                  g      j                  t        j
                  t                     v }t        j                  | |t         j                  t        j
                        }|r|st        j                  j                  t              rFt        j                  d       t        j                   t               t#        j"                  g d       y |rt        j%                  d       y t        j                  d       y t#        j&                  d      st        j                  d       y | j(                  | j(                  nd}|rd	|z   }d
}t        j                  j                  |      sd}t        j+                  d       t        j,                  t        t.        j1                  ||             t#        j"                  g d       y )N)r   r   event_source_typescopez!Uninstalling hotplug, not enabled)udevadmcontrolz--reload-ruleszOHotplug is unsupported by current datasource. Udev rules will NOT be installed.z%Skipping hotplug install, not enabledr   z+Skipping hotplug install, udevadm not found 
z/usr/libexec/cloud-initz/usr/lib/cloud-initzInstalling hotplug.)extra_rules
libexecdir)filenamecontent)r   HOTPLUGget_supported_eventsgetr
   NETWORKsetr   update_event_enabledospathexistsHOTPLUG_UDEV_PATHLOGdebugr   del_filer   warningwhichextra_hotplug_udev_rulesinfo
write_fileHOTPLUG_UDEV_RULES_TEMPLATEformat)r   r   r   hotplug_supportedhotplug_enabledr   r   s          E/usr/lib/python3/dist-packages/cloudinit/config/cc_install_hotplug.pyinstall_hotplugr9   %   s   
 "))''):):(;<@@	

 11#++  	O /77>>+,II9:MM+,II>? 	 %KK4 	 II=>::i 		?@ ..: 	++ 
 [(*J77>>*%*
HH"#OO"+22#
 3 
 	II67    namecloudargsreturnc                     d|v xr" d|d   v xr d|d   d   v xr d|d   d   d   v }t        |j                  ||       y )Nupdatesnetworkwhenhotplug)r9   r   )r;   r   r<   r=   r   s        r8   handlerD   [   sh    S 	;Y'	;c)nY//	; Y	26::	  E$$c+BCr:   )"__doc__loggingr(   	cloudinitr   r   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   cloudinit.distrosr	   cloudinit.eventr
   r   cloudinit.settingsr   cloudinit.sourcesr   r   __annotations__	getLogger__name__r,   r+   r4   boolr9   strlistrD    r:   r8   <module>rV      s    9  	 ( ( ! # . ) 1 + ( }!	j  g!
 I  3838	38 "38lD D6 D% Dt D Dr:   