+
    iI,                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	H
t
Ht ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ R	IHtHt ^ R
IHt ]P<                  ! ]4      t Rt!RR lt" ! R R]PF                  4      t$ ! R R]$4      t%R]%]PL                  3/t'R t(R R lt)R R lt*R R lt+R R lt,R t-]R8X  d!   ]"! 4       P]                  4       t/]-! ]!]/4       R# R# )z)Handle reconfiguration on hotplug events.N)	reportingstagesutil)install_hotplug)
EventScope	EventType)loggers)read_sys_net_safe)parse_net_config_data)events)
DataSourceDataSourceNotFoundExceptionInitzhotplug-hookc                   V '       g!   \         P                  ! \        \        R7      p \        V n        V P                  RRRRR.R7       V P                  RR	R
7      pRVn        VP                  RRR7       VP                  RRR7      pVP                  RRRRRR7       VP                  RRRRR.R7       VP                  RRR7       V # )a  Build or extend an arg parser for hotplug-hook utility.

@param parser: Optional existing ArgumentParser instance representing the
    subcommand which will be extended to support the args of this utility.

@returns: ArgumentParser with proper argument configuration.
)progdescriptionz-sz--subsystemTzsubsystem to act onnet)requiredhelpchoiceszHotplug Actionhotplug_action)titledestqueryz0Query if hotplug is enabled for given subsystem.)r   handlezHandle the hotplug event.z-dz	--devpathPATHzSysfs path to hotplugged device)r   metavarr   z-uz--udevactionzSpecify action to take.addenablez%Enable hotplug for a given subsystem.)	argparseArgumentParserNAME__doc__r   add_argumentadd_subparsersr   
add_parser)parser
subparsersparser_handles   &  B/usr/lib/python3/dist-packages/cloudinit/cmd/devel/hotplug_hook.py
get_parserr+      s    ((dH F
"   &&%5 ' J JH   ))2 * M .   &   >   M    c                      a  ] tR t^Qt o R t]P                  R 4       t]]P                  R 4       4       t	]P                  V 3R lR l4       t
R tR tR tR	tV tR
# )UeventHandlerc                B    Wn         W n        W0n        W@n        WPn        R # N)id
datasourcedevpathaction
success_fn)selfr1   r2   r3   r4   r5   s   &&&&&&r*   __init__UeventHandler.__init__R   s    &0$r,   c                    \        4       hr0   NotImplementedErrorr6   s   &r*   applyUeventHandler.applyY       !##r,   c                    \        4       hr0   r:   r<   s   &r*   configUeventHandler.config]   s     "##r,   c                    < V ^8  d   QhRS[ /#    returnbool)format__classdict__s   "r*   __annotate__UeventHandler.__annotate__c   s     $ $ $r,   c                    \        4       hr0   r:   r<   s   &r*   device_detectedUeventHandler.device_detectedb   r?   r,   c                    R pV P                   R8X  d   RpM\        RV P                   ,          4      hWP                  4       8w  d   \        RV P                  ,          4      hR # )Nr   TzUnknown action: %sz'Failed to detect %s in updated metadata)r4   
ValueErrorrN   RuntimeErrorr1   )r6   detect_presences   & r*   detect_hotplugged_device&UeventHandler.detect_hotplugged_devicef   sZ    ;;%"O1DKK?@@22449DGGC  5r,   c                "    V P                  4       # r0   )r5   r<   s   &r*   successUeventHandler.successr   s      r,   c                    V P                   P                  \        P                  .4      pV'       g,   \	        R V P                   : R\        P                  : 24      hV# )zDatasource z not updated for event )r2   update_metadata_if_supportedr   HOTPLUGrR   )r6   results   & r*   update_metadataUeventHandler.update_metadatau   sO    ==
 ??I$5$57  r,   )r4   r2   r3   r1   r5   N)__name__
__module____qualname____firstlineno__r7   abcabstractmethodr=   propertyrA   rN   rT   rW   r]   __static_attributes____classdictcell__)rJ   s   @r*   r.   r.   Q   st     % 	$ $ $  $ 	$ $
!	 	r,   r.   c                   Z   a a ] tR t^t oV 3R ltR t]R 4       tV3R lR ltRt	Vt
V ;t# )
NetHandlerc                |   < \        \        P                  P                  V4      R 4      p\        SV `  WQW#V4       R# )addressN)r	   ospathbasenamesuperr7   )r6   r2   r3   r4   r5   r1   	__class__s   &&&&& r*   r7   NetHandler.__init__   s/    rww//8)D*Er,   c                   V P                   P                  P                  V P                  R R7       \        P
                  P                  V P                  4      pV P                   P                  P                  4       pV P                  R8X  d>   VP                  V4      '       g%   \        RP                  V P                  4      4      hR# R# )F)bring_upr   zFailed to bring up device: {}N)r2   distroapply_network_configrA   rl   rm   rn   r3   network_activatorr4   bring_up_interfacerR   rI   )r6   interface_name	activators   &  r*   r=   NetHandler.apply   s    33KK 	4 	
 ))$,,7OO**<<>	;;%//??"3::4<<H  @  r,   c                .    V P                   P                  # r0   )r2   network_configr<   s   &r*   rA   NetHandler.config   s    ---r,   c                    < V ^8  d   QhRS[ /# rD   rG   )rI   rJ   s   "r*   rK   NetHandler.__annotate__   s       r,   c                   \        V P                  4      pVP                  4        Uu. uF'  pVP                  R 4      V P                  8X  g   K%  VNK)  	  pp\
        P                  RV P                  V4       \        V4      ^ 8  # u upi )mac_addresszIfaces with ID=%s : %s)r
   rA   iter_interfacesgetr1   LOGdebuglen)r6   netstateifacefounds   &   r*   rN   NetHandler.device_detected   s|    (5 "113
3yy'4772 E3 	 

 			*DGGU;5zA~
s   "BB )r_   r`   ra   rb   r7   r=   re   rA   rN   rf   rg   __classcell__)rp   rJ   s   @@r*   ri   ri      s3     F
 . .  r,   ri   r   c                      \         V,          ^,          p\        P
                  ! T P                  T P                  \        P                  TR7      #   \         d!   p\        RP                  T4      4      ThRp?ii ; i)   z4hotplug-hook: cannot handle events for subsystem: {}N)r2   cfgevent_source_typescope)
SUBSYSTEM_PROPERTIES_MAPKeyErrorrR   rI   r   update_event_enabledr2   r   r   r[   )hotplug_init	subsystemr   es   &&  r*   
is_enabledr      s~    (3A6 &&**#++	   BII
 		s   A A=A88A=c                0    V ^8  d   QhR\         R\        /# )rE   r   r   )r   str)rI   s   "r*   rK   rK      s        r,   c                 "   \         P                  R 4       V P                  RR7      pVP                  \        P
                  .4      '       g   \         P                  RV4       R# \        W4      '       g   \         P                  RV4       R# V# )zFetching datasourcetrustexistingz*hotplug not supported for event of type %sNz(hotplug not enabled for event of type %s)r   r   fetchget_supported_eventsr   r[   r   )r   r   r2   s   && r*   initialize_datasourcer      sq    II#$##W#5J**I,=,=+>??		>	Jl..		<iHr,   c                (    V ^8  d   QhR\         RR/# )rE   r   rF   Nr   )rI   s   "r*   rK   rK      s     C C C$ Cr,   c                 2   \        W4      pV'       g   R # \        V,          ^ ,          p\        P                  RV4       V! VVVV P                  R7      p\
        P
                  ! 4       pVP                  P                  '       g   \        W&V4       R # \
        P
                  ! 4       V,
          VP                  P                  8  dN   \        W&V4       \        P                  R4       \
        P                  ! VP                  P                  4       K  R # )NzCreating %s event handler)r2   r3   r4   r5   z>Gathering network configuration again due to IMDS limitations.)r   r   r   r   _write_to_cachetimehotplug_retry_settingsforce_retrytry_hotplugsleep_totalsleepsleep_period)r   r3   r   
udevactionr2   handler_clsevent_handlerstarts   &&&&    r*   handle_hotplugr      s    &|?J*95a8KII)95#.//	$M IIKE,,888Ij9
))+

 A A M M
MIj9		L	
 	

:44AAB Nr,   c                    V ^8  d   QhRR/# )rE   rF   Nr   )rI   s   "r*   rK   rK      s       r,   c           	      n   . R	Op\        R4      p\        V4       F  w  rV\        P                  RV V\	        V4      4        \        P                  R4       VP                  4        VP                  '       g&   \        P                  R4       VP                  4        \        P                  R4       VP                  4        \        P                  R4       VP                  4         R# 	  Vh  \          d;   p\        P                  RT4       \        P                  ! T4       Tp Rp?EK  Rp?ii ; i)
r   z#Bug while processing hotplug event.z!subsystem=%s update attempt %s/%szRefreshing metadataz$Detecting device in updated metadatazApplying config changezUpdating cachez,Exception while processing hotplug event. %sN)r         
      )	Exception	enumerater   r   r   r]   skip_hotplug_detectrT   r=   rW   r   r   )r   r   r2   
wait_timeslast_exceptionattemptwaitr   s   &&&     r*   r   r      s    "JDEN":.		/
O		
	II+,))+111		@A668II./!II&'!!## /.   	IIDaHJJtN	s   B&C//D4:.D//D4c                0    V ^8  d   QhR\         R\        /# )rE   r   rF   )r   rH   )rI   s   "r*   rK   rK      s          T  r,   c                    V P                  R R7      pV'       g   R# \        V,          ^,          p\        P                  VP	                  \        P                  .4      P                  V\        4       4      9   pV'       g!   \        RV 2\        P                  R7       R# \        P                  ! V P                  4      pVP                  VR,          9   d"   \        RV R2\        P                  R7       R# VR,          P                  VP                  4       \        P                  ! V P                  P!                  R	4      \"        P$                  ! V4      R
RR7       \'        VRV P(                  R7       R# )r   r   Fz#hotplug not supported for event of )filescopesz)Not installing hotplug for event of type z. Reason: Already done.Tzhotplug.enabledwi  )omodemode)network_hotplug_enabledr   )r   r   r   r[   r   r   setprintsysstderrr   read_hotplug_enabled_filepathsvalueappend
write_file	get_cpathjsondumpsr   r   )r   r   r2   r   hotplug_supportedhotplug_enabled_files   &&    r*   enable_hotplugr      s9   ##W#5J$Y/2E!))''):):(;<@@N 1)=CJJ	
 99,:L:LM{{*8447	{ C% %	

 "))%++6OO$$%67

'(	 Dl6F6F r,   c           	      `   \         P                  ! V \        R R7      p\        . VR7      pVP	                  4        \
        P                  ! VP                  4       RVP                  9   d0   \        P                  ! VP                  P                  R4      4       \        P                  RT VP                  VP                  RV9   d   VP                  MRRV9   d   VP                   MR4       T;_uu_ 4         VP                  R8X  d-    \#        W1P                  4      p\'        X'       d   R
MR4       MVP                  R8X  d/   \-        VVP                   VP                  VP                  R7       M\.        P0                  ! 4       ^ 8w  d6   \(        P2                  P5                  R4       \(        P*                  ! ^4       \7        W1P                  R7      '       g   \(        P*                  ! ^4       \'        RVP                   24        RRR4       \        P                  R4       \        P<                  ! 4        R#   \$         d&    \'        R	4       \(        P*                  ! ^4        ELRi ; i  \8         d    \        P;                  R4       h i ; i  + '       g   i     L; i)T)reporting_enabled)ds_depsreporterr   zh%s called with the following arguments: {hotplug_action: %s, subsystem: %s, udevaction: %s, devpath: %s}r   Nr3   r   z9Unable to determine hotplug state. No datasource detectedenableddisabledr   )r   r3   r   r   z9Root is required. Try prepending your command with sudo.
)r   r   z)Enabled cloud-init hotplug for subsystem=z*Received fatal exception handling hotplug!zExiting hotplug handler)r   ReportEventStackr#   r   read_cfgr   setup_loggingr   r   update_configurationr   r   r   r   r   r   r3   r   r   r   r   exitr   rl   getuidr   writer   r   	exceptionflush_events)nameargshotplug_reporterr   r2   s   &&   r*   handle_argsr      s    ..g -=>L,**+l&&&&&|'7'7';';K'HIII	J'4/T!T)t 
	&	""g-	 !6$nn"J :i:>$$0!- LL"nn#	 99;!#JJ$$# HHQK%!-  HHQK!!% 02A 
R II'(G 3  # HHQK <  	MMFG	K 
	sa   9J;I8I"I87J8>I86J7BI8J,I51I84I55I88"JJJ-	__main__r0   )0r#   rc   r    r   loggingrl   r   r   	cloudinitr   r   r   #cloudinit.config.cc_install_hotplugr   cloudinit.eventr   r   cloudinit.logr   cloudinit.netr	   cloudinit.net.network_stater
   cloudinit.reportingr   cloudinit.sourcesr   r   cloudinit.stagesr   	getLoggerr_   r   r"   r+   ABCr.   ri   NETWORKr   r   r   r   r   r   r   
parse_argsr   r   r,   r*   <module>r      s    0 
    	 
  - - ? 1 ! + = & E !!3l-CGG -` F 
J
**+ 
$C0: FBJ z<""$Dd r,   