Current Dir: /snap/core22/2955/usr/lib/python3/dist-packages/cloudinit/sources/azure/__pycache__/

[FILE] errors.cpython-310.pyc [ edit | delete | rename ]
[FILE] identity.cpython-310.pyc [ edit | delete | rename ]
[FILE] imds.cpython-310.pyc [ edit | delete | rename ]
[FILE] kvp.cpython-310.pyc [ edit | delete | rename ]
[FILE] __init__.cpython-310.pyc [ edit | delete | rename ]

Viewing: /snap/core22/2955/usr/lib/python3/dist-packages/cloudinit/sources/azure/__pycache__/errors.cpython-310.pyc

o

��i�	@s�ddlZddlZddlZddlZddlmZmZddlmZddlm	Z	m
Z
mZmZm
Z
ddlmZddlZddlmZmZddlmZe�e�Z		d,d
eededed
efdd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�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(Gd(d)�d)e�Z)Gd*d+�d+e�Z*dS)-�N)�datetime�timezone)�StringIO)�Any�Dict�List�Optional�Tuple)�ElementTree)�subp�version)�UrlError�|�'�data�	delimiter�	quotechar�returncCsPt��}tj|||tjd��|�|����Wd�S1s!wYdS)zEncode report data with csv.)rr�quotingN)r�csv�writer�
QUOTE_MINIMAL�writerow�getvalue�rstrip)rrr�io�r�@/usr/lib/python3/dist-packages/cloudinit/sources/azure/errors.py�
encode_reports�
$�rc@sfeZdZdd�dedeeeefddfdd�Zdeedefd	d
�Zde	fdd�Z
defd
d�ZdS)�ReportableErrorN)�supporting_data�reasonr rcCs@dt����|_d|_||_|r||_ni|_t�tj	�|_
dS)NzCloud-Init/z%https://aka.ms/linuxprovisioningerror)r�version_string�agent�documentation_urlr!r r�nowr�utc�	timestamp)�selfr!r rrr�__init__'szReportableError.__init__�vm_idcCsbdd|j��d|j��g}|dd�|j��D�7}|d|��d|j����d|j��g7}t|�S)	Nzresult=errorzreason=zagent=cSsg|]\}}|�d|���qS)�=r)�.0�k�vrrr�
<listcomp>?sz5ReportableError.as_encoded_report.<locals>.<listcomp>zvm_id=z
timestamp=zdocumentation_url=)r!r#r �itemsr'�	isoformatr$r)r(r*rrrr�as_encoded_report5s

�
�z!ReportableError.as_encoded_reportcCs.t|t�o|j|jko|j|jko|j|jkS)N)�
isinstancerr'r!r )r(�otherrrr�__eq__Hs

�
�
�zReportableError.__eq__cCs&|jj�d|j�d|j�d|j�d�S)Nz(reason=z, timestamp=z, supporting_data=�))�	__class__�__name__r!r'r �r(rrr�__repr__Ps
����zReportableError.__repr__)r8�
__module__�__qualname__�strrrrr)r2�boolr5r:rrrrr&s ���
��
�rc�&eZdZdeddf�fdd�Z�ZS)�$ReportableErrorDhcpInterfaceNotFound�durationrNcst��d�||jd<dS)Nzfailure to find DHCP interfacerA��superr)r )r(rA�r7rrr)Zsz-ReportableErrorDhcpInterfaceNotFound.__init__)r8r;r<�floatr)�
__classcell__rrrDrr@Y�r@c
s>eZdZdeededeedeeddf
�fdd�Z�ZS)	�ReportableErrorDhcpLease�driverrA�	interface�mac_addressrNcs8t��d�||jd<||jd<||jd<||jd<dS)Nzfailure to obtain DHCP leaserIrArJrKrB)r(rIrArJrKrDrrr)as



z!ReportableErrorDhcpLease.__init__)r8r;r<rr=rEr)rFrrrDrrH`s�����rHcsZeZdZdeedeedeedeeeeefdeeefddf�fdd	�Z	�Z
S)
�(ReportableErrorDhcpOnNonPrimaryInterfacerJrI�router�
static_routes�leaserNcsBt��d�||jd<||jd<||jd<||jd<||jd<dS)Nz&failure to find primary DHCP interfacerJrIrMrNrOrB)r(rJrIrMrNrOrDrrr)qs	



z1ReportableErrorDhcpOnNonPrimaryInterface.__init__)r8r;r<rr=rr	rrr)rFrrrDrrLps����
��rLc�*eZdZdededdf�fdd�Z�ZS)�ReportableErrorImdsUrlError�	exceptionrArNcs�t|jtj�r
d}n!t|jtj�rd}nt|jtj�rd}n
|jr)d|j�d�}nd}t��|�|jr:|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 IMDS�	http_coderArR�url)r3�cause�requests�ConnectTimeout�ConnectionError�ReadTimeout�coderCr)r �reprrT)r(rRrAr!rDrrr)�s
z$ReportableErrorImdsUrlError.__init__)r8r;r<r
rEr)rFrrrDrrQ��"rQcrP)�"ReportableErrorImdsInvalidMetadata�key�valuerNcs:t��d|���||jd<||jd<t|�j|jd<dS)Nzinvalid IMDS metadata for key=r^r_�type)rCr)r r`r8)r(r^r_rDrrr)�s

z+ReportableErrorImdsInvalidMetadata.__init__)r8r;r<r=rr)rFrrrDrr]�r\r]cr?)�+ReportableErrorImdsMetadataParsingExceptionrRrNcst��d�t|�|jd<dS)Nzerror parsing IMDS metadatarR�rCr)r[r �r(rRrDrrr)�sz4ReportableErrorImdsMetadataParsingException.__init__)r8r;r<�
ValueErrorr)rFrrrDrra�rGrac�eZdZd�fdd�Z�ZS)�ReportableErrorOsDiskPpsFailurerNc�t��d�dS)Nzerror waiting for host shutdown�rCr)r9rDrrr)��z(ReportableErrorOsDiskPpsFailure.__init__�rN�r8r;r<r)rFrrrDrrf��rfcr?)�!ReportableErrorOvfInvalidMetadata�messagerNcst��d|���dS)Nz)unexpected metadata parsing ovf-env.xml: rh)r(rnrDrrr)�sz*ReportableErrorOvfInvalidMetadata.__init__)r8r;r<r=r)rFrrrDrrm�rGrmc�(eZdZdejddf�fdd�Z�ZS)�"ReportableErrorOvfParsingExceptionrRrNcs|j}t��d|���dS)Nzerror parsing ovf-env.xml: )�msgrCr))r(rRrnrDrrr)�sz+ReportableErrorOvfParsingException.__init__)r8r;r<�ET�
ParseErrorr)rFrrrDrrp�� rpcr?)�!ReportableErrorUnhandledExceptionrRrNcszt��d�d�t�t|�||j��}|�d�}|ddd�}d�|�}t�	|�
d���d�}t|�|j
d<||j
d<dS)Nzunhandled exception��
���zutf-8rR�traceback_base64)rCr)�join�	traceback�format_exceptionr`�
__traceback__�split�base64�	b64encode�encode�decoder[r )r(rR�trace�trace_lines�reversed_trace_lines�reversed_trace�trace_base64rDrrr)�s��

�z*ReportableErrorUnhandledException.__init__)r8r;r<�	Exceptionr)rFrrrDrru�rGrucre)�!ReportableErrorProxyAgentNotFoundrNcrg)Nzazure-proxy-agent not foundrhr9rDrrr)�riz*ReportableErrorProxyAgentNotFound.__init__rjrkrrrDrr��rlr�cro)�&ReportableErrorProxyAgentStatusFailurerRrNcs4t��d�|j|jd<|j|jd<|j|jd<dS)Nz azure-proxy-agent status failure�	exit_code�stdout�stderr)rCr)r�r r�r�rcrDrrr)�sz/ReportableErrorProxyAgentStatusFailure.__init__)r8r;r<r�ProcessExecutionErrorr)rFrrrDrr��rtr�cs4eZdZdd�dedeeddf�fdd�Z�ZS)�ReportableErrorVmIdentificationN)�system_uuidrRr�rcs(t��d�t|�|jd<||jd<dS)Nzfailure to identify Azure VM IDrRr�rb)r(rRr�rDrrr)�sz(ReportableErrorVmIdentification.__init__)r8r;r<r�rr=r)rFrrrDrr��s����r�)rr)+rr�loggingr{rrrr�typingrrrrr	�	xml.etreer
rrrV�	cloudinitrr�cloudinit.url_helperr
�	getLoggerr8�LOGr=rr�rr@rHrLrQr]rarfrmrprur�r�r�rrrr�<module>sH
����
�3		
Upload File: