
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
\¼me@  ã            	   @   sæ   U d Z ddlZddlZddlm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mZ ddlmZ dd	lmZmZ dd
lmZ ddd edƒegeedƒedƒgg dœZeeeƒZ ejeƒZdZdZeee
eddœdd„ZdS )z3Install hotplug udev rules if supported and enabledé    N)Údedent)ÚstagesÚsubpÚutil)ÚCloud)ÚConfig)Ú
MetaSchemaÚget_meta_doc)ÚALL_DISTROS)Ú
EventScopeÚ	EventType)ÚPER_INSTANCEZcc_install_hotplugzInstall 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"]
        )ÚidÚnameÚtitleÚdescriptionZdistrosZ	frequencyZexamplesZactivate_by_schema_keysz2/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"
)r   ÚcfgÚcloudÚargsÚreturnc             C   s   d|ko6d|d ko6d|d d ko6d|d d d k}t j|jjt jgƒjtjtƒ ƒk}tj	|j|t jtjd�}|ox|sÊt
jjtƒr¬tjdƒ tjtƒ tjddd	gƒ n|r¼tjd
ƒ n
tjdƒ d S tjdƒsâtjdƒ d S d}t
jj|ƒsöd}tjttj|d�d� tjddd	gƒ d S )NZupdatesZnetworkZwhenZhotplug)Ú
datasourcer   Zevent_source_typeZscopez!Uninstalling hotplug, not enabledZudevadmZcontrolz--reload-ruleszOHotplug is unsupported by current datasource. Udev rules will NOT be installed.z%Skipping hotplug install, not enabledz+Skipping hotplug install, udevadm not foundz/usr/libexec/cloud-initz/usr/lib/cloud-init)Ú
libexecdir)ÚfilenameZcontent)r   ZHOTPLUGr   Zget_supported_eventsÚgetr   ZNETWORKÚsetr   Zupdate_event_enabledÚosÚpathÚexistsÚHOTPLUG_UDEV_PATHÚLOGÚdebugr   Zdel_filer   ZwarningZwhichZ
write_fileÚHOTPLUG_UDEV_RULES_TEMPLATEÚformat)r   r   r   r   Znetwork_hotplug_enabledZhotplug_supportedZhotplug_enabledr   © r#   ú(/usr/lib/python3.6/cc_install_hotplug.pyÚhandleH   s@    





r%   ) Ú__doc__Zloggingr   Útextwrapr   Z	cloudinitr   r   r   Zcloudinit.cloudr   Zcloudinit.configr   Zcloudinit.config.schemar   r	   Zcloudinit.distrosr
   Zcloudinit.eventr   r   Zcloudinit.settingsr   ÚmetaZ	getLoggerÚ__name__r   r   r!   ÚstrÚlistr%   r#   r#   r#   r$   Ú<module>   s6   
