Your IP : 216.73.217.13


Current Path : /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_install_hotplug.cpython-38.pyc

U

�Ad=�	@s�UdZddlZddlmZddlmZddlmZmZm	Z	ddl
mZddlm
Z
ddlmZmZdd	lmZdd
lmZmZddlmZdd
ded�egeed�ed�ggd�Zeed<ee�ZdZdZee
eeedd�dd�ZdS)z3Install hotplug udev rules if supported and enabled�N)�Logger)�dedent)�stages�subp�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�ALL_DISTROS)�
EventScope�	EventType)�PER_INSTANCEZcc_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"]
        )�id�name�titleZdescriptionZdistrosZ	frequencyZexamplesZactivate_by_schema_keys�metaz2/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�log�args�returnc	Cs d|ko6d|dko6d|ddko6d|dddk}tj|j�tjg��tjt��k}tj	|j|tjtjd�}|rz|s�t
j�t
�r�|�d�t�t
�t�ddd	g�n|r�|�d
�n
|�d�dSt�d�s�|�d�dSd
}t
j�|�s�d}tjt
tj|d�d�t�ddd	g�dS)NZupdatesZnetworkZwhenZhotplug)�
datasourcerZevent_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 foundz/usr/libexec/cloud-initz/usr/lib/cloud-init)�
libexecdir)�filenameZcontent)r
ZHOTPLUGrZget_supported_events�getrZNETWORK�setrZupdate_event_enabled�os�path�exists�HOTPLUG_UDEV_PATH�debugrZdel_filerZwarningZwhichZ
write_file�HOTPLUG_UDEV_RULES_TEMPLATE�format)	rrrrrZnetwork_hotplug_enabledZhotplug_supportedZhotplug_enabledr�r$�E/usr/lib/python3/dist-packages/cloudinit/config/cc_install_hotplug.py�handleGsR
������

�



�r&)�__doc__rZloggingr�textwraprZ	cloudinitrrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemar	r
Zcloudinit.distrosrZcloudinit.eventrr
Zcloudinit.settingsrr�__annotations__r r"�str�listr&r$r$r$r%�<module>sJ�����+
�