File "hotplug_hook.cpython-36.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/usr/lib/python3.6/site-packages/cloudinit/cmd/devel/__pycache__/hotplug_hook.cpython-36.pyc
File size: 7.8 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit

3

\me#@s0dZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
ddlmZm
Z
ddlmZddlmZddlmZddlmZmZdd	lmZejeZd
ZdddZGd
ddejZGdddeZ de ej!fiZ"ddZ#ee$dddZ%edddZ&ddZ'edkr,ej(Z)e'ee)dS)z)Handle reconfiguration on hotplug events.N)log	reportingstages)
EventScope	EventType)read_sys_net_safe)parse_net_config_data)events)
DataSourceDataSourceNotFoundException)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.
    )progdescriptionz-sz--subsystemTzsubsystem to act onnet)requiredhelpchoiceszHotplug Actionhotplug_action)titledestqueryz0Query if hotplug is enabled for given subsystem.)rZhandlezHandle the hotplug event.z-dz	--devpathPATHzSysfs path to hotplugged device)rmetavarrz-uz--udevactionzSpecify action to take.addremove)	argparseArgumentParserNAME__doc__radd_argumentZadd_subparsersrZ
add_parser)parserZ
subparsersZ
parser_handler!"/usr/lib/python3.6/hotplug_hook.py
get_parsers:



r#c@s`eZdZddZejddZeejddZeje	ddd	Z
d
dZdd
ZddZ
dS)
UeventHandlercCs"||_||_||_||_||_dS)N)id
datasourcedevpathaction
success_fn)selfr%r&r'r(r)r!r!r"__init__Ks
zUeventHandler.__init__cCs
tdS)N)NotImplementedError)r*r!r!r"applyRszUeventHandler.applycCs
tdS)N)r,)r*r!r!r"configVszUeventHandler.config)returncCs
tdS)N)r,)r*r!r!r"device_detected[szUeventHandler.device_detectedcCsPd}|jdkrd}n|jdkr$d}ntd|j||jkrLtd|jdS)NrTrFzUnknown action: %sz'Failed to detect %s in updated metadata)r(
ValueErrorr0RuntimeErrorr%)r*Zdetect_presencer!r!r"detect_hotplugged_device_s

z&UeventHandler.detect_hotplugged_devicecCs|jS)N)r))r*r!r!r"successmszUeventHandler.successcCs,|jjtjg}|s(td|jtjf|S)Nz&Datasource %s not updated for event %s)r&Zupdate_metadata_if_supportedrHOTPLUGr2)r*resultr!r!r"update_metadataps
zUeventHandler.update_metadataN)__name__
__module____qualname__r+abcabstractmethodr-propertyr.boolr0r3r4r7r!r!r!r"r$Jsr$cs>eZdZfddZddZeddZeddd	ZZ	S)

NetHandlercs*ttjj|d}tj|||||dS)NZaddress)rospathbasenamesuperr+)r*r&r'r(r)r%)	__class__r!r"r+}szNetHandler.__init__cCs||jjj|jddtjj|j}|jjj}|j	dkrT|j
|sxtdj|jn$|j	dkrx|j
|sxtdj|jdS)NF)Zbring_uprzFailed to bring up device: {}rzFailed to bring down device: {})r&ZdistroZapply_network_configr.r@rArBr'Znetwork_activatorr(Zbring_up_interfacer2formatZbring_down_interface)r*Zinterface_nameZ	activatorr!r!r"r-s



zNetHandler.applycCs|jjS)N)r&Znetwork_config)r*r!r!r"r.szNetHandler.config)r/cs<tj}fdd|jD}tjdj|t|dkS)Ncs g|]}|jdjkr|qS)Zmac_address)getr%).0Ziface)r*r!r"
<listcomp>sz.NetHandler.device_detected.<locals>.<listcomp>zIfaces with ID=%s : %sr)rr.Ziter_interfacesLOGdebugr%len)r*Znetstatefoundr!)r*r"r0s


zNetHandler.device_detected)
r8r9r:r+r-r=r.r>r0
__classcell__r!r!)rDr"r?|sr?rcCs\yt|d}Wn2tk
rB}ztdj||WYdd}~XnXtj|j|jtj	|dS)Nz4hotplug-hook: cannot handle events for subsystem: {})r&cfgZevent_source_typescope)
SUBSYSTEM_PROPERTES_MAPKeyErrorr2rErZupdate_event_enabledr&rOrr5)hotplug_init	subsystemrPer!r!r"
is_enabledsrV)rSrTcCsRtjd|jdd}|jtjgs4tjd|dSt||sNtjd|dS|S)NzFetching datasourceZtrust)Zexistingz*hotplug not supported for event of type %sz(hotplug not enabled for event of type %s)rIrJZfetchZget_supported_eventsrr5rV)rSrTr&r!r!r"initialize_datasources

rW)rScCst||}|sdSt|d}tjd||||||jd}dddddg}td	}xt|D]\}	}
tjd
||	t|yTtjd|j|j	stjd|j
tjd
|jtjd|jPWq\tk
r
}z tjd|t
j|
|}WYdd}~Xq\Xq\W|dS)NrzCreating %s event handler)r&r'r(r)rN
z#Bug while processing hotplug event.z!subsystem=%s update attempt %s/%szRefreshing metadataz$Detecting device in updated metadatazApplying config changezUpdating cachez,Exception while processing hotplug event. %s)rWrQrIrJZ_write_to_cache	Exception	enumeraterKr7Zskip_hotplug_detectr3r-r4timeZsleep)rSr'rT
udevactionr&Zhandler_clsZ
event_handlerZ
wait_timesZlast_exceptionZattemptwaitrUr!r!r"handle_hotplugsD







racCs8tj|tdd}tg|d}|jtj|jd|jkrLtj	|jj
dtjd||j
|jd|krj|jndd|krz|jnd|yn|j
dkryt||j}Wn&tk
rtd	tjd
YnXt|rdndnt||j|j|jd
Wn"tk
rtjdYnXWdQRXtjdtjdS)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 detectedrNZenabledZdisabled)rSr'rTr_z*Received fatal exception handling hotplug!zExiting hotplug handler)r	ZReportEventStackrrZread_cfgrZ
setup_loggingrOrZupdate_configurationrFrIrJrrTr_r'rWrprintsysexitrar\Z	exceptionZflush_events)nameargsZhotplug_reporterrSr&r!r!r"handle_argssF



rg__main__)N)*rr;rZloggingr@rcr^Z	cloudinitrrrZcloudinit.eventrrZ
cloudinit.netrZcloudinit.net.network_staterZcloudinit.reportingr	Zcloudinit.sourcesr
rZcloudinit.stagesrZ	getLoggerr8rIrr#ABCr$r?ZNETWORKrQrVstrrWrarg
parse_argsrfr!r!r!r"<module>s4

22((5