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: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyo
�
d�bc@svddlZddlZddlZddlZddlZddljjZddljj	Z	ddl
jjjZddl
mZddlmZmZmZmZddlmZddlmZddlmZddlmZmZddlmZdd	lm Z dd
l!m"Z"m#Z#dZ$dZ%d
Z&dZ'dZ(dZ)dZ*dZ+d�Z,defd��YZ-dS(i����N(tSingletonPerThread(t
ProtocolErrortOSUtilErrortProtocolNotFoundErrort	DhcpError(tustr(t
get_osutil(tget_dhcp_handler(t!cleanup_metadata_server_artifactst#is_metadata_server_artifact_present(tOvfEnv(tWireProtocol(tKNOWN_WIRESERVER_IPtIOErrorCountersovf-env.xmltProtocolihi
tWireServerEndpoints<UserPassword>.*?<s<UserPassword>*<RcCst�S(N(tProtocolUtil(((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pytget_protocol_util4sRcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�ZRS(s1
    ProtocolUtil handles initialization for protocol instance. 2 protocol types
    are invoked, wire protocol and metadata protocols.

    Note: ProtocolUtil is a sub class of SingletonPerThread, this basically means that there would only be 1 single
    instance of ProtocolUtil object per thread.
    cCs=tj�|_d|_d|_t�|_t�|_	dS(N(
t	threadingtRLockt_locktNonet	_protocoltendpointRtosutilRtdhcp_handler(tself((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyt__init__@s
		cCsNtj�}tjj|t�}tjjtj�t�}y|jj�Wn.t	k
r}}t
djt|����nXy%t
j|dt�}t|�}Wn7ttfk
r�}t
dj|t|����nXy)tjtt|�}t
j||�Wn7ttfk
r?}t
dj|t|����nX|j�|S(sm
        Copy ovf env file from dvd to hard disk.
        Remove password before save it to the disk
        s$[CopyOvfEnv] Error mounting dvd: {0}t
remove_boms([CopyOvfEnv] Error reading file {0}: {1}s([CopyOvfEnv] Error writing file {0}: {1}(tconftget_dvd_mount_pointtostpathtjoint
OVF_FILE_NAMEtget_lib_dirRt	mount_dvdRRtformatRtfileutilt	read_filetTrueR
tIOErrortOSErrortretsubtPASSWORD_PATTERNtPASSWORD_REPLACEMENTt
write_filet_cleanup_ovf_dvd(Rtdvd_mount_pointtovf_file_path_on_dvdt
ovf_file_pathtetovfxmltovfenv((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pytcopy_ovf_envGs4					
cCsKy|jj�|jj�Wn&tk
rF}tjt|��nXdS(N(Rt
umount_dvdt	eject_dvdRtloggertwarnR(RR4((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyR0ls

cCs_tjjtj�t�}tjj|�rFtj|�}t	|�St
dj|���dS(s(
        Load saved ovf-env.xml
        sovf-env.xml is missing from {0}N(RR R!RR#R"tisfileR&R'R
RR%(RR3txml_text((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pytget_ovf_envss
cCstjjtj�t�S(N(RR R!RR#tPROTOCOL_FILE_NAME(R((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyt_get_protocol_file_paths		cCstjjtj�t�S(N(RR R!RR#tENDPOINT_FILE_NAME(R((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyt"_get_wireserver_endpoint_file_path�s		cCs|jj�z�|jr |jS|j�}tjj|�r�yItj|�|_|jrvt	j
d|j�|jSt	jd|�Wq�tt
fk
r�}t	jd|t|��q�Xnt	jd|�t|_t	j
d|j�|jSWd|jj�XdS(Ns&WireServer endpoint {0} read from files1[GetWireserverEndpoint] Unexpected empty file {0}s3[GetWireserverEndpoint] Error reading file {0}: {1}s([GetWireserverEndpoint] Missing file {0}s'Using hardcoded Wireserver endpoint {0}(RtacquireRRBRR R<R&R'R:tinfoterrorR)R*tstrRtrelease(Rt	file_pathR4((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pytget_wireserver_endpoint�s&
		 	cCs[y)||_|j�}tj||�Wn+ttfk
rV}tt|���nXdS(N(RRBR&R/R)R*RR(RRRHR4((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyt_set_wireserver_endpoint�s	cCs�d|_|j�}tjj|�s+dSytj|�Wn?ttfk
r}}|j	t	j
krjdStjd|�nXdS(s=
        Cleanup previous saved wireserver endpoint.
        Ns'Failed to clear wiresever endpoint: {0}(
RRRBRR R<tremoveR)R*terrnotENOENTR:RE(Rtendpoint_file_pathR4((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyt_clear_wireserver_endpoint�s	cCs�|j�x{tdt�D]j}y|jj}|d	kr�|jj�}|r�tj	d�y|jj
�Wn%tk
r�}tt
|���nX|jj}q�tj	d�|j�}ny+t|�}|j�|j|�|SWn>tk
r,}tj	d�d	|j_t|j_|�nXWn#tk
rS}tj	d|�nX|tdkrtj	d|�tjt�qqWtd��d	S(
s3
        Probe protocol endpoints in turn.
        is4WireServer endpoint is not found. Rerun dhcp handlers$_detect_protocol: DHCP not availables1WireServer is not responding. Reset dhcp endpoints Protocol endpoint not found: {0}is Retry detect protocol: retry={0}sNo protocol found.N(tclear_protocoltranget	MAX_RETRYRRRRtis_dhcp_availableR:RDtrunRRRRIRtdetectRJR(t
skip_cachettimetsleeptPROBE_INTERVALR(RtretryRtdhcp_availableR4tprotocol((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyt_detect_protocol�s>





cCsP|j�}ytj||�Wn)ttfk
rK}tjd|�nXdS(s(
        Save protocol endpoint
        s%Failed to save protocol endpoint: {0}N(R@R&R/R)R*R:RE(Rt
protocol_nametprotocol_file_pathR4((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyt_save_protocol�s
cCs�|jj�z�tjd�|j�d|_|j�}tj	j
|�sRdSytj|�Wn?tt
fk
r�}|jtjkr�dStjd|�nXWd|jj�XdS(s;
        Cleanup previous saved protocol endpoint.
        s&Clean protocol and wireserver endpointNs&Failed to clear protocol endpoint: {0}(RRCR:RDRORRR@RR R<RKR)R*RLRMRERG(RR_R4((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyRP�s


	cCs|jj�z�|jdk	r&|jS|j�}tjj|�r�tj	|�t
kr�|j�}t|�|_t
�r�t|j�n|jStjd�|j�}tjd|j��|jt
�||_t
�r�t|j�n|jSWd|jj�XdS(sR
        Detect protocol by endpoint.
        :returns: protocol instance
        sDetect protocol endpointRN(RRCRRR@RR R<R&R'tWIRE_PROTOCOL_NAMERIRR	RRR:RDR]R
tset_protocol_endpointtget_endpointR`RG(RR_RR\((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pytget_protocols(
'	

		(t__name__t
__module__t__doc__RR7R0R>R@RBRIRJROR]R`RPRd(((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyR7s		%								/	
	(.RLRR+RWRtazurelinuxagent.common.conftcommonRtazurelinuxagent.common.loggerR:t%azurelinuxagent.common.utils.fileutiltutilsR&t)azurelinuxagent.common.singletonperthreadRt azurelinuxagent.common.exceptionRRRRtazurelinuxagent.common.futureRtazurelinuxagent.common.osutilRtazurelinuxagent.common.dhcpRt>azurelinuxagent.common.protocol.metadata_server_migration_utilRR	t&azurelinuxagent.common.protocol.ovfenvR
t$azurelinuxagent.common.protocol.wireRt%azurelinuxagent.common.utils.restutilRR
R"R?RRRYRAR-R.RaRR(((sH/usr/lib/python2.7/site-packages/azurelinuxagent/common/protocol/util.pyt<module>s4"