403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.6/site-packages/cloudinit/cmd/devel/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.6/site-packages/cloudinit/cmd/devel/__pycache__/hotplug_hook.cpython-36.pyc
3

��bH#�@s,dZddlZddlZddlZddlZddlZddlmZmZm	Z	ddl
mZmZddl
mZmZddlmZddlmZddlmZdd	lmZdd
lmZeje�ZdZddd
�ZGdd�dej�ZGdd�de�Z de ej!fiZ"dd�Z#dd�Z$ed�dd�Z%dd�Z&edk�r(e�j'�Z(e&ee(�dS)z(Handle reconfiguration on hotplug events�N)�log�	reporting�stages)�
EventScope�	EventType)�
activators�read_sys_net_safe)�parse_net_config_data)�events)�
DataSource)�DataSourceNotFoundException)�Initzhotplug-hookcCs�|stjttd�}t|_|jdddddgd�|jdd	d
�}d|_|jddd
�|jddd
�}|jdddddd�|jddddddgd�|S)aBuild 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--subsystemTzsubsystem to act on�net)�required�help�choiceszHotplug Action�hotplug_action)�title�dest�queryz/query if hotplug is enabled for given subsystem)rZhandlezhandle the hotplug eventz-dz	--devpath�PATHzsysfs path to hotplugged device)r�metavarrz-uz--udevactionzaction to take�add�remove)	�argparse�ArgumentParser�NAME�__doc__r�add_argumentZadd_subparsersrZ
add_parser)�parserZ
subparsersZ
parser_handle�r"�"/usr/lib/python3.6/hotplug_hook.py�
get_parsers:



r$c@s`eZdZdd�Zejdd��Zeejdd���Zeje	d�dd	��Z
d
d�Zdd
�Zdd�Z
dS)�
UeventHandlercCs"||_||_||_||_||_dS)N)�id�
datasource�devpath�action�
success_fn)�selfr&r'r(r)r*r"r"r#�__init__Is
zUeventHandler.__init__cCs
t��dS)N)�NotImplementedError)r+r"r"r#�applyPszUeventHandler.applycCs
t��dS)N)r-)r+r"r"r#�configTszUeventHandler.config)�returncCs
t��dS)N)r-)r+r"r"r#�device_detectedYszUeventHandler.device_detectedcCsPd}|jdkrd}n|jdkr$d}ntd|j��||j�krLtd|j��dS)NrTrFzUnknown action: %sz'Failed to detect %s in updated metadata)r)�
ValueErrorr1�RuntimeErrorr&)r+Zdetect_presencer"r"r#�detect_hotplugged_device]s

z&UeventHandler.detect_hotplugged_devicecCs|j�S)N)r*)r+r"r"r#�successkszUeventHandler.successcCs,|jjtjg�}|s(td|jtjf��|S)Nz&Datasource %s not updated for event %s)r'Zupdate_metadata_if_supportedr�HOTPLUGr3)r+�resultr"r"r#�update_metadatans
zUeventHandler.update_metadataN)�__name__�
__module__�__qualname__r,�abc�abstractmethodr.�propertyr/�boolr1r4r5r8r"r"r"r#r%Hsr%cs>eZdZ�fdd�Zdd�Zedd��Zed�dd	�Z�Z	S)
�
NetHandlercs*ttjj|�d�}t�j|||||�dS)NZaddress)r�os�path�basename�superr,)r+r'r(r)r*r&)�	__class__r"r#r,{szNetHandler.__init__cCsx|jjj|jdd�tjj|j�}tj	�}|j
dkrP|j|�sttdj
|j���n$|j
dkrt|j|�sttdj
|j���dS)NF)Zbring_uprzFailed to bring up device: {}rzFailed to bring down device: {})r'ZdistroZapply_network_configr/rArBrCr(rZselect_activatorr)Zbring_up_interfacer3�formatZbring_down_interface)r+Zinterface_nameZ	activatorr"r"r#r.�s



zNetHandler.applycCs|jjS)N)r'Znetwork_config)r+r"r"r#r/�szNetHandler.config)r0cs<t�j�}�fdd�|j�D�}tjd�j|�t|�dkS)Ncs g|]}|jd��jkr|�qS)Zmac_address)�getr&)�.0Ziface)r+r"r#�
<listcomp>�sz.NetHandler.device_detected.<locals>.<listcomp>zIfaces with ID=%s : %sr)r	r/Ziter_interfaces�LOG�debugr&�len)r+Znetstate�foundr")r+r#r1�s


zNetHandler.device_detected)
r9r:r;r,r.r>r/r?r1�
__classcell__r"r")rEr#r@zsr@rcCs\yt|d}Wn2tk
rB}ztdj|��|�WYdd}~XnXtj|j|jtj	|d�S)N�z4hotplug-hook: cannot handle events for subsystem: {})r'�cfgZevent_source_type�scope)
�SUBSYSTEM_PROPERTES_MAP�KeyError�	ExceptionrFrZupdate_event_enabledr'rPrr6)�hotplug_init�	subsystemrQ�er"r"r#�
is_enabled�srXcCsRtjd�|jdd�}|jtjg�s4tjd|�dSt||�sNtjd|�dS|S)NzFetching datasourceZtrust)Zexistingz*hotplug not supported for event of type %sz(hotplug not enabled for event of type %s)rJrKZfetchZget_supported_eventsrr6rX)rUrVr'r"r"r#�initialize_datasource�s

rY)rUcCst||�}|sdSt|d}tjd|�|||||jd�}dddddg}x�t|�D]�\}}	tjd	||t|��yNtjd
�|j�tjd�|j�tjd�|j	�tjd
�|j
�PWqTtk
r�}
z tjd|
�tj
|	�|
}WYdd}
~
XqTXqTW|�dS)NrzCreating %s event handler)r'r(r)r*rO���
�z!subsystem=%s update attempt %s/%szRefreshing metadataz$Detecting device in updated metadatazApplying config changezUpdating cachez,Exception while processing hotplug event. %s)rYrRrJrKZ_write_to_cache�	enumeraterLr8r4r.r5rT�timeZsleep)rUr(rV�
udevactionr'Zhandler_clsZ
event_handlerZ
wait_timesZattempt�waitrWZlast_exceptionr"r"r#�handle_hotplug�s@







rbcCs8tj|tdd�}tg|d�}|j�tj|j�d|jkrLtj	|jj
d��tjd||j
|jd|krj|jndd|krz|jnd�|��yn|j
dkr�yt||j�}Wn&tk
r�td	�tjd
�YnXt|r�dnd�nt||j|j|jd
�Wn"tk
�rtjd��YnXWdQRXtjd�tj�dS)NT)Zreporting_enabled)Zds_depsZreporterrzh%s called with the following arguments: {hotplug_action: %s, subsystem: %s, udevaction: %s, devpath: %s}r`r(rz9Unable to determine hotplug state. No datasource detectedrOZenabledZdisabled)rUr(rVr`z*Received fatal exception handling hotplug!zExiting hotplug handler)r
ZReportEventStackrr
Zread_cfgrZsetupLoggingrPrZupdate_configurationrGrJrKrrVr`r(rYr�print�sys�exitrbrTZ	exceptionZflush_events)�name�argsZhotplug_reporterrUr'r"r"r#�handle_args�sF



rh�__main__)N))rr<rrArdr_Z	cloudinitrrrZcloudinit.eventrrZ
cloudinit.netrrZcloudinit.net.network_stater	Zcloudinit.reportingr
Zcloudinit.sourcesrrZcloudinit.stagesr
Z	getLoggerr9rJrr$�ABCr%r@ZNETWORKrRrXrYrbrh�
parse_argsrgr"r"r"r#�<module>s4

22(&5



Youez - 2016 - github.com/yon3zu
LinuXploit