܍~c= *UdZddlZddlmZddlmZddlmZmZm Z ddl m Z ddl m Z ddlmZmZdd lmZdd lmZmZdd lmZd d dedegeededggdZeed<eeZdZdZdede de dededdf dZdS)z3Install hotplug udev rules if supported and enabledN)Logger)dedent)stagessubputil)Cloud)Config) MetaSchema get_meta_doc) ALL_DISTROS) EventScope EventType) PER_INSTANCEcc_install_hotplugzInstall Hotplugas This module will install the udev rules to enable hotplug if supported by the datasource and enabled in the userdata. The udev rules will be installed as ``/etc/udev/rules.d/10-cloud-init-hook-hotplug.rules``. When hotplug is enabled, newly added network devices will be added to the system by cloud-init. After udev detects the event, cloud-init will referesh the instance metadata from the datasource, detect the device in the updated metadata, then apply the updated network configuration. Currently supported datasources: Openstack, EC2 z # Enable hotplug of network devices updates: network: when: ["hotplug"] z # Enable network hotplug alongside boot event updates: network: when: ["boot", "hotplug"] )idnametitle descriptiondistros frequencyexamplesactivate_by_schema_keysmetaz2/etc/udev/rules.d/10-cloud-init-hook-hotplug.rulesz# Installed by cloud-init due to network hotplug userdata ACTION!="add|remove", GOTO="cloudinit_end" LABEL="cloudinit_hook" SUBSYSTEM=="net", RUN+="{libexecdir}/hook-hotplug" LABEL="cloudinit_end" rcfgcloudlogargsreturncd|vo/d|dvo%d|ddvod|dddv}tj|jtjgt jtv}tj |j|tjt j}|r|stj trE|dtjtt#jgdn-|r|dn|d dSt#jd s|d dSd }tj |sd }tjtt*|t#jgddS)Nupdatesnetworkwhenhotplug) datasourcerevent_source_typescopez!Uninstalling hotplug, not enabled)udevadmcontrolz--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 foundz/usr/libexec/cloud-initz/usr/lib/cloud-init) libexecdir)filenamecontent)rHOTPLUGr$get_supported_eventsgetr NETWORKsetrupdate_event_enabledospathexistsHOTPLUG_UDEV_PATHdebugrdel_filerwarningwhich write_fileHOTPLUG_UDEV_RULES_TEMPLATEformat) rrrrrnetwork_hotplug_enabledhotplug_supportedhotplug_enabledr)s E/usr/lib/python3/dist-packages/cloudinit/config/cc_install_hotplug.pyhandlerAGs  S ; Y ' ; c)nY/ / ; Y 26: :  ") --y/@.ABBFF     1# #+ O  /  7>>+ , , ? II9 : : : M+ , , , I>>> ? ? ? ? $ ? KK4     II= > > > :i  ?@@@+J 7>>* % %+* O"+22j2II I66677777)__doc__r2loggingrtextwrapr cloudinitrrrcloudinit.cloudrcloudinit.configr cloudinit.config.schemar r cloudinit.distrosr cloudinit.eventr rcloudinit.settingsrr__annotations__r5r;strlistrArBr@rQs999 ((((((((((!!!!!!######<<<<<<<<))))))11111111++++++   B6  }       $ "Q))j)))V ,t  I-8 -8-8#(-8/5-8=A-8 -8-8-8-8-8-8rB