name : errors.cpython-39.pyc
a

'�Dg��@s�ddlZddlZddlZddlZddlmZmZddlmZddlm	Z	m
Z
mZmZm
Z
ddlmZddlZddlmZmZddlmZddlmZe�e�Zd(eeeeed�dd
�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd�de�Z#Gdd�de�Z$Gdd�de�Z%Gdd�de�Z&Gdd�de�Z'Gd d!�d!e�Z(Gd"d#�d#e�Z)Gd$d%�d%e�Z*Gd&d'�d'e�Z+dS))�N)�datetime�timezone)�StringIO)�Any�Dict�List�Optional�Tuple)�ElementTree)�subp�version)�identity)�UrlError�|�')�data�	delimiter�	quotechar�returncCsPt��6}tj|||tjd��|�|����Wd�S1sB0YdS)zEncode report data with csv.)rrZquotingN)r�csv�writerZ
QUOTE_MINIMALZwriterow�getvalue�rstrip)rrr�io�r�B/usr/lib/python3.9/site-packages/cloudinit/sources/azure/errors.py�
encode_reports��rc@sZeZdZdd�eeeeefdd�dd�Zed�dd�Ze	d�d	d
�Z
ed�dd�ZdS)
�ReportableErrorN)�supporting_data)�reasonrrc
Cs�dt����|_d|_||_|r(||_ni|_t�tj	�|_
zt��|_
Wn0tyz}zd|��|_
WYd}~n
d}~00dS)NzCloud-Init/z%https://aka.ms/linuxprovisioningerrorzfailed to read vm id: )rZversion_string�agent�documentation_urlrrrZnowrZutc�	timestampr
Zquery_vm_id�vm_id�	Exception)�selfrrZid_errorrrr�__init__(szReportableError.__init__�rcCsddd|j��d|j��g}|dd�|j��D�7}|d|j��d|j����d|j��g7}t|�S)	Nzresult=errorzreason=zagent=cSsg|]\}}|�d|���qS)�=r)�.0�k�vrrr�
<listcomp>F�z5ReportableError.as_encoded_report.<locals>.<listcomp>zvm_id=z
timestamp=zdocumentation_url=)	rr r�itemsr#r"Z	isoformatr!r)r%rrrr�as_encoded_report>s

�

�z!ReportableError.as_encoded_reportcCs.t|t�o,|j|jko,|j|jko,|j|jkS)N)�
isinstancerr"rr)r%�otherrrr�__eq__Os

�
�
�zReportableError.__eq__cCs&|jj�d|j�d|j�d|j�d�S)Nz(reason=z, timestamp=z, supporting_data=�))�	__class__�__name__rr"r�r%rrr�__repr__Ws
����zReportableError.__repr__)r5�
__module__�__qualname__�strrrrr&r/�boolr2r7rrrrr's���rcs$eZdZedd��fdd�Z�ZS)�$ReportableErrorDhcpInterfaceNotFoundN)�durationrcst��d�||jd<dS)Nzfailure to find DHCP interfacer=��superr&r)r%r=�r4rrr&asz-ReportableErrorDhcpInterfaceNotFound.__init__)r5r8r9�floatr&�
__classcell__rrr@rr<`sr<cs*eZdZeeedd��fdd�Z�ZS)�ReportableErrorDhcpLeaseN)r=�	interfacercs$t��d�||jd<||jd<dS)Nzfailure to obtain DHCP leaser=rDr>)r%r=rDr@rrr&hs
z!ReportableErrorDhcpLease.__init__)r5r8r9rArr:r&rBrrr@rrCgsrCcsPeZdZeeeeeeeeeeefeeefdd��fdd�Z	�Z
S)�(ReportableErrorDhcpOnNonPrimaryInterfaceN)rD�driver�router�
static_routes�leasercsBt��d�||jd<||jd<||jd<||jd<||jd<dS)Nz&failure to find primary DHCP interfacerDrFrGrHrIr>)r%rDrFrGrHrIr@rrr&ps	



z1ReportableErrorDhcpOnNonPrimaryInterface.__init__)r5r8r9rr:rr	rrr&rBrrr@rrEos
�rEcs&eZdZeedd��fdd�Z�ZS)�ReportableErrorImdsUrlErrorN)�	exceptionr=rcs�t|jtj�rd}nBt|jtj�r(d}n.t|jtj�r<d}n|jrRd|j�d�}nd}t��|�|jrt|j|j	d<||j	d<t
|�|j	d	<|j|j	d
<dS)Nz connection timeout querying IMDSzconnection error querying IMDSzread timeout querying IMDSzhttp error z querying IMDSzunexpected error querying IMDSZ	http_coder=rK�url)r0�cause�requestsZConnectTimeout�ConnectionErrorZReadTimeout�coder?r&r�reprrL)r%rKr=rr@rrr&�s
z$ReportableErrorImdsUrlError.__init__)r5r8r9rrAr&rBrrr@rrJ�srJcs&eZdZeedd��fdd�Z�ZS)�"ReportableErrorImdsInvalidMetadataN)�key�valuercs.t��d|���||jd<t|�|jd<dS)Nzinvalid IMDS metadata for key=rSrT)r?r&rrQ)r%rSrTr@rrr&�s
z+ReportableErrorImdsInvalidMetadata.__init__)r5r8r9r:rr&rBrrr@rrR�srRcs$eZdZedd��fdd�Z�ZS)�+ReportableErrorImdsMetadataParsingExceptionN�rKrcst��d�t|�|jd<dS)Nzerror parsing IMDS metadatarK)r?r&rQr�r%rKr@rrr&�sz4ReportableErrorImdsMetadataParsingException.__init__)r5r8r9�
ValueErrorr&rBrrr@rrU�srUcs"eZdZdd��fdd�Z�ZS)�ReportableErrorOsDiskPpsFailureNr'cst��d�dS)Nzerror waiting for host shutdown�r?r&r6r@rrr&�sz(ReportableErrorOsDiskPpsFailure.__init__�r5r8r9r&rBrrr@rrY�srYcs$eZdZedd��fdd�Z�ZS)�!ReportableErrorOvfInvalidMetadataN)�messagercst��d|���dS)Nz)unexpected metadata parsing ovf-env.xml: rZ)r%r]r@rrr&�sz*ReportableErrorOvfInvalidMetadata.__init__)r5r8r9r:r&rBrrr@rr\�sr\cs&eZdZejdd��fdd�Z�ZS)�"ReportableErrorOvfParsingExceptionNrVcs|j}t��d|���dS)Nzerror parsing ovf-env.xml: )�msgr?r&)r%rKr]r@rrr&�sz+ReportableErrorOvfParsingException.__init__)r5r8r9�ETZ
ParseErrorr&rBrrr@rr^�sr^cs$eZdZedd��fdd�Z�ZS)�!ReportableErrorUnhandledExceptionNrVcsXt��d�d�t�t|�||j��}t�|�	d���
d�}t|�|jd<||jd<dS)Nzunhandled exception�zutf-8rKZtraceback_base64)
r?r&�join�	traceback�format_exception�type�
__traceback__�base64Z	b64encode�encode�decoderQr)r%rKZtraceZtrace_base64r@rrr&�s��z*ReportableErrorUnhandledException.__init__)r5r8r9r$r&rBrrr@rra�sracs"eZdZdd��fdd�Z�ZS)�!ReportableErrorProxyAgentNotFoundNr'cst��d�dS)Nzazure-proxy-agent not foundrZr6r@rrr&�sz*ReportableErrorProxyAgentNotFound.__init__r[rrr@rrk�srkcs&eZdZejdd��fdd�Z�ZS)�&ReportableErrorProxyAgentStatusFailureNrVcs4t��d�|j|jd<|j|jd<|j|jd<dS)Nz azure-proxy-agent status failure�	exit_code�stdout�stderr)r?r&rmrrnrorWr@rrr&�sz/ReportableErrorProxyAgentStatusFailure.__init__)r5r8r9rZProcessExecutionErrorr&rBrrr@rrl�srl)rr),rhrZloggingrdrrrr�typingrrrrr	Z	xml.etreer
r`rNZ	cloudinitrrZcloudinit.sources.azurer
Zcloudinit.url_helperrZ	getLoggerr5ZLOGr:rr$rr<rCrErJrRrUrYr\r^rarkrlrrrr�<module>s<
�
�9

© 2025 Cubjrnet7