U 'Dg @sUdZddlZddlZddlmZmZmZddlmZddl m Z ddl m Z ddl mZddlmZmZdd lmZdd lmZd egegd Ze ed <eeZdZdZee edddZee ee ddddZ!dS)z3Install hotplug udev rules if supported and enabledN)stagessubputil)Cloud)Config) MetaSchema) ALL_DISTROS) EventScope EventType) PER_INSTANCE) DataSourceZcc_install_hotplug)idZdistrosZ frequencyZactivate_by_schema_keysmetaz2/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" ) datasourcecfgnetwork_hotplug_enabledcCstj|tjgtjtk}tj||tjtjd}|r>|st j t rpt dtt tdddgn|rt dn t ddStdst ddS|jdk r|jnd }|rd |}d }t j |sd }t d tjt tj||ddtdddgdS)N)rrZevent_source_typeZscopez!Uninstalling hotplug, not enabledZudevadmZcontrolz--reload-ruleszOHotplug is unsupported by current datasource. Udev rules will NOT be installed.z%Skipping hotplug install, not enabledz+Skipping hotplug install, udevadm not found z/usr/libexec/cloud-initz/usr/lib/cloud-initzInstalling hotplug.) extra_rules libexecdir)filenameZcontent)r ZHOTPLUGZget_supported_eventsgetr ZNETWORKsetrZupdate_event_enabledospathexistsHOTPLUG_UDEV_PATHLOGdebugrZdel_filerZwarningZwhichZextra_hotplug_udev_rulesinfoZ write_fileHOTPLUG_UDEV_RULES_TEMPLATEformat)rrrZhotplug_supportedZhotplug_enabledrrr"E/usr/lib/python3/dist-packages/cloudinit/config/cc_install_hotplug.pyinstall_hotplug%sX        r$)namercloudargsreturncCsJd|ko6d|dko6d|ddko6d|dddk}t|j||dS)NZupdatesZnetworkZwhenZhotplug)r$r)r%rr&r'rr"r"r#handle[s r))"__doc__ZloggingrZ cloudinitrrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarZcloudinit.distrosrZcloudinit.eventr r Zcloudinit.settingsr Zcloudinit.sourcesr r__annotations__Z getLogger__name__rrr boolr$strlistr)r"r"r"r#s.         6