MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: sonne (1011)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyc
�
d�bc@s�dZddlmZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddl
jjZddljjZddljjZddlmZddlmZmZddlmZdd	lmZmZdd
lmZddl m!Z!ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-dd
l.m/Z/ddl0m1Z1de2fd��YZ3de2fd��YZ4dd�Z6d�Z7d�Z8d�Z9dd�Z:e;dkr�e6�ndS(s
Module agent
i����(tprint_functionN(tcgroupconfiguratortlogcollector(tSystemdCgroupsApi(tustr(tLogCollectortOUTPUT_RESULTS_FILE_PATH(t
get_osutil(tfileutilttextutil(tFlexibleVersion(tAddFirewallRules(t
AGENT_NAMEtAGENT_LONG_VERSIONt
AGENT_VERSIONtDISTRO_NAMEtDISTRO_VERSIONtPY_VERSION_MAJORtPY_VERSION_MINORtPY_VERSION_MICROtGOAL_STATE_AGENT_VERSIONtget_daemon_versiontset_daemon_version(tCollectLogsHandler(tProvisionHandlert
AgentCommandscBsVeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZRS(
sN
    This is the list of all commands that the Linux Guest Agent supports
    sdeprovision+usertdeprovisiontdaemontstartsregister-servicesrun-exthandlerstversionsshow-configurationthelpscollect-logsssetup-firewallt	provision(t__name__t
__module__t__doc__tDeprovisionUsertDeprovisiontDaemontStarttRegisterServicetRunExthandlerstVersiont
ShowConfigtHelptCollectLogst
SetupFirewallt	Provision(((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyR4stAgentcBsteZd
d�Zd�Zd�Zd�Zeed�Zd�Z	ed�Z
d�Zd�Ze
d	��ZRS(cCs||_t�|_|r'tjjn	tjj}tjtjj	|�|jd	k	ra|jn|jj�}tj
|�|p�tj�}|r�tjjn	tjj}tjtjj|dtj��tj�r�tj�r�|j|�ntj�r,tjtjjtjjdtj�ntj�}y\tjj|�retdj|���ntjj |�s�t!j"|dddd�nWn,tk
r�}tj#dj||��nXtj$tj%��tjj&tj%�tj'�}tj(|�tj)d�d	S(
s7
        Initialize agent running environment.
        tpaths
{0} is a filetmodei�townertrootsBException occurred while creating extension log directory {0}: {1}tWALAN(*tconf_file_pathRtosutiltloggertLogLeveltVERBOSEtINFOtadd_logger_appendertAppenderTypetSTDOUTtNonetget_agent_conf_file_pathtconftload_conf_from_filetget_logs_verbosetFILEtget_agent_log_filetget_logs_consoleRtis_provisionedt_Agent__add_console_appenderteventtsend_logs_to_telemetryt	TELEMETRYtWARNINGt
add_log_eventtget_ext_log_dirtosR0tisfilet	ExceptiontformattisdirRtmkdirterrortinit_event_statustget_lib_dirtjointEVENTS_DIRECTORYtinit_event_loggertenable_unhandled_err_dump(tselftverboseR5tleveltext_log_dirtet	event_dir((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyt__init__Gs<	
"
 
cCs tjtjj|dd�dS(NR0s/dev/console(R7R;R<tCONSOLE(R[R]((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyt__add_console_appender|scCs~tt�tjd�tj�jd�|jdkr?dndj	|j�}ddl
m}|�}|jd|�dS(s"
        Run agent daemon
        R%s-configuration-path:{0}i����(tget_daemon_handlert
child_argsN(
RRR7t
set_prefixt	threadingtcurrent_threadtsetNameR5R>RQtazurelinuxagent.daemonRdtrun(R[ReRdtdaemon_handler((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyRs

	cCs'ddlm}|�}|j�dS(s'
        Run provision command
        i����(tget_provision_handlerN(tazurelinuxagent.pa.provisionRmRk(R[Rmtprovision_handler((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyR�s	cCs3ddlm}|�}|jd|d|�dS(s)
        Run deprovision command
        i����(tget_deprovision_handlertforcetdeluserN(tazurelinuxagent.pa.deprovisionRpRk(R[RqRrRptdeprovision_handler((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyR�s	cCsdtdjt��|jj�tdjt��|jj�tdjt��|jj�dS(s-
        Register agent as a service
        sRegister {0} servicesStop {0} servicesStart {0} serviceN(tprintRQRR6tregister_agent_servicetstop_agent_servicetstart_agent_service(R[((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pytregister_service�s

cCs�tjd�tj�jd�tj�rvt�td�krv|j	tj
j�ztjd�Wdtj
�Xnddlm}|�}|j|�dS(s6
        Run the update and extension handler
        t
ExtHandlers2.2.53u�The agent will now check for updates and then will process extensions. Output to /dev/console will be suspended during those operations.Ni����(tget_update_handler(R7RfRgRhRiR@RERR
RGR8R:tinfotdisable_console_outputtazurelinuxagent.ga.updateR{Rk(R[tdebugR{tupdate_handler((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pytrun_exthandlers�s
	!	cCsGtj�}x4t|j��D] }tdj|||��qWdS(Ns	{0} = {1}(R@tget_configurationtsortedtkeysRuRQ(R[t
configurationtk((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pytshow_configuration�sc	Cs5|rtd�n
td�tj�r�tjd�\}}tj|k}tj|k}|sj|r�td�|s�td�n|s�td�ntjt	j
�q�ny2t|�}|j�}tdj
|t��WnLtk
r0}tdj
t|���td	j
t��tjd
�nXdS(NsRunning log collector mode fulls!Running log collector mode normalR[s7The Log Collector process is not in the proper cgroups:s	unexpected cpu slices	unexpected memory slicesnLog collection successfully completed. Archive can be found at {0} and detailed log output can be found at {1}s3Log collection completed unsuccessfully. Error: {0}s'Detailed log output can be found at {0}i(RuRtshould_validate_cgroupsRt!get_process_cgroup_relative_pathsRtLOGCOLLECTOR_SLICEtsystexitRtINVALID_CGROUPS_ERRCODERtcollect_logs_and_get_archiveRQRRPR(	R[tis_full_modetcpu_cgroup_pathtmemory_cgroup_pathtcpu_slice_matchestmemory_slice_matchest
log_collectortarchiveR_((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pytcollect_logs�s.




	cCs�tdj|��y-tj|d|d|d�td�Wn9tk
r{}tdjt|���tjd�nXdS(Ns8Setting up firewall for the WALinux Agent with args: {0}twaittdst_iptuids#Successfully set the firewall ruless(Unable to add firewall rules. Error: {0}i(RuRQRtadd_iptables_rulesRPRR�R�(tfirewall_metadataRT((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pytsetup_firewall�sN(R R!R>RaRGRRtFalseRRyR�R�R�tstaticmethodR�(((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyR/Fs5						 c
Cs|dkrg}nt|�dkr7tjd}nt|�\}}}}}}}|tjkrqt�n�|tjkr�t	t
��n~|tjkr�td|�n_y-t
|d|�}|tjkr�|j|dt�n�|tjkr|j|dt�n�|tjkr*|j�n�|tjkrF|j�n�|tjkrb|j�ny|tjkr�|j|�nZ|tjkr�|j�n>|tjkr�|j|�n|tjkr�|j |�nWn/t!k
r
}	t"j#d|t$j%|	��nXdS(s
    Parse command line arguments, exit with usage() on error.
    Invoke different methods according to different command
    iiR5RruFailed to run '{0}': {1}N(&R>tlenR�targvt
parse_argsRR)RR+RutusageR&RR/R#RtTrueR$R�R.RR'RyR%RR(R�R*R�R,R�R-R�RPR7RTR	tformat_exception(
targstcommandRqR\RR5tlog_collector_full_modeR�tagentR_((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pytmain�sF	!




	cCstj}t}t}t}d}t}idd6dd6dd6}d}x�|D]�}	|	dkrgqOntjd|	�}
|
dk	r�|
jd�}tjj	|�s�t
dj|�d	tj
�t
t��tjd�q�qOtjd
|	�rtj}qOtj|jtj�|	�r*tj}qOtj|jtj�|	�rTtj}qOtj|jtj�|	�r~tj}qOtj|jtj�|	�r�tj}qOtj|jtj�|	�r�tj}qOtj|jtj�|	�r�tj}qOtj|jd�|	�r t}qOtj|jd�|	�rDt}qOtj|jd
�|	�rht}qOtj|jtj�|	�r�tj}qOtjd|	�r�tj}qOtj|jtj�|	�r�tj}qOtj|jd�|	�r�t}qOtj|jtj�|	�r(tj}qOtj|jd�|	�rntj|jd�|	�jd�|d<qOtj|jd�|	�r�tj|jd�|	�jd�|d<qOtj|jd�|	�r�d|d<qOtj}PqOW|||||||fS(s&
    Parse command line arguments
    R�R�tR�s^([-/]*){0}s*^(?:[-/]*)configuration-path:([\w/\.\-_]+)is,Error: Configuration file {0} does not existtfiles^([-/]*)deprovision\+userR\RRqs^([-/]*)(help|usage|\?)tfullsdst_ip=(?P<dst_ip>[\d.]{7,})suid=(?P<uid>[\d]+)s	(w|wait)$s-wN(RR+R�R>tretmatchtgroupRNR0texistsRuRQR�tstderrR�R�R#R$R%R&R'R(R)R�R*R,R-(tsys_argstcmdRqR\RR5R�R�tregex_cmd_formattargtm((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyR�s|	

	
				+
	cCsItdjttt��tdjttt��tdjt��dS(s
    Show agent version
    s{0} running on {1} {2}sPython: {0}.{1}.{2}sGoal state agent: {0}N(	RuRQR
RRRRRR(((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyRhs

cCs.d}|djtjd�7}|d7}|S(s$
    Return agent usage message
    s
susage: {0} [-verbose] [-force] [-help] -configuration-path:<path to configuration file>-deprovision[+user]|-register-service|-version|-daemon|-start|-run-exthandlers|-show-configuration|-collect-logs [-full]|-setup-firewall [-dst_ip=<IP> -uid=<UID> [-w/--wait]]i(RQR�R�(ts((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyR�us
	
c
Csptjddg}|dk	r8|jdj|��nttjd�� }tj	|d|d|�WdQXdS(s[
    Start agent daemon in a background process and set stdout/stderr to
    /dev/null
    is-daemons-configuration-path:{0}twtstdoutR�N(
R�R�R>tappendRQtopenRNtdevnullt
subprocesstPopen(R5R�R�((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyR�s
t__main__(<R"t
__future__RRNR�R�R�Rgtazurelinuxagent.commonRRt azurelinuxagent.common.cgroupapiRtazurelinuxagent.common.conftcommonR@tazurelinuxagent.common.eventRHtazurelinuxagent.common.loggerR7tazurelinuxagent.common.futureRt#azurelinuxagent.common.logcollectorRRtazurelinuxagent.common.osutilRtazurelinuxagent.common.utilsRR	t-azurelinuxagent.common.utils.flexible_versionR
t(azurelinuxagent.common.utils.networkutilRtazurelinuxagent.common.versionRR
RRRRRRRRRtazurelinuxagent.ga.collect_logsRt$azurelinuxagent.pa.provision.defaultRtobjectRR/R>R�R�RR�RR (((s9/usr/lib/python2.7/site-packages/azurelinuxagent/agent.pyt<module>s:L�+	J