HOME


Mini Shell 1.0
DIR: /lib/python3/dist-packages/cloudinit/sources/azure/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/sources/azure/__pycache__/errors.cpython-312.pyc
�

�f��	���ddlZddlZddlZddlZddlmZddlmZddlmZm	Z	m
Z
mZmZddl
mZddlZddlmZddlmZddlmZej,e�Z	d$d	e
ed
ededefd
�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Z Gd�de�Z!Gd�de�Z"Gd�de�Z#Gd�de�Z$Gd �d!e�Z%Gd"�d#e�Z&y)%�N)�datetime)�StringIO)�Any�Dict�List�Optional�Tuple)�ElementTree)�version)�identity)�UrlError�data�	delimiter�	quotechar�returnc���t�5}tj|||tj��j	|�|j�j
�cddd�S#1swYyxYw)zEncode report data with csv.)rr�quotingN)r�csv�writer�
QUOTE_MINIMAL�writerow�getvalue�rstrip)rrr�ios    �@/usr/lib/python3/dist-packages/cloudinit/sources/azure/errors.py�
encode_reportrs]��
��	&�r��
�
�����%�%�		
�
�(�4�.��{�{�}�#�#�%�	&�	&�	&�s�AA)�)A2c�Z�eZdZdd�dedeeeefddfd�Zdefd�Zde	fd�Z
defd	�Zy)
�ReportableErrorN)�supporting_data�reasonrrc� �dtj���|_d|_||_|r||_ni|_t
j�|_	tj�|_y#t$r}d|��|_Yd}~yd}~wwxYw)NzCloud-Init/z%https://aka.ms/linuxprovisioningerrorzfailed to read vm id: )
r�version_string�agent�documentation_urlr rr�utcnow�	timestampr�query_vm_id�vm_id�	Exception)�selfr r�id_errors    r�__init__zReportableError.__init__(s���#�7�#9�#9�#;�"<�=��
�!H�������#2�D� �#%�D� �!���*���	?�!�-�-�/�D�J���	?�1�(��>�D�J�J��	?�s�A0�0	B
�9
B�B
c�F�dd|j��d|j��g}||jj�D��cgc]\}}|�d|����c}}z
}|d|j��d|j
j
���d|j��gz
}t|�Scc}}w)Nzresult=errorzreason=zagent=�=zvm_id=z
timestamp=zdocumentation_url=)	r r#r�itemsr(r&�	isoformatr$r)r*r�k�vs    r�as_encoded_reportz!ReportableError.as_encoded_report>s���
��d�k�k�]�#��T�Z�Z�L�!�
��
	
��(<�(<�(B�(B�(D�E���1�A�3�a��s��E�E����T�Z�Z�L�!�����1�1�3�4�5� ��!7�!7� 8�9�
�	
���T�"�"��Fs�Bc���t|t�xrO|j|jk(xr4|j|jk(xr|j|jk(S)N)�
isinstancerr&r r)r*�others  r�__eq__zReportableError.__eq__OsV���u�o�.�
>����%�/�/�1�
>����u�|�|�+�
>��$�$��(=�(=�=�		
�c��|jj�d|j�d|j�d|j�d�S)Nz(reason=z, timestamp=z, supporting_data=�))�	__class__�__name__r r&r)r*s r�__repr__zReportableError.__repr__WsL���~�~�&�&�'�(��k�k�]�#����(�)�#�3�3�4�A�
7�	
r8)r<�
__module__�__qualname__�strrrrr,r3�boolr7r=�r8rrr'sZ��
59�	?��?�"�$�s�C�x�.�1�	?�

�?�,#�	�#�"
�t�
�
�#�
r8rc�(��eZdZdeddf�fd�Z�xZS)�$ReportableErrorDhcpInterfaceNotFound�durationrNc�B��t�|�d�||jd<y)Nzfailure to find DHCP interfacerE��superr,r)r*rEr;s  �rr,z-ReportableErrorDhcpInterfaceNotFound.__init__as!���
���9�:�+3����Z�(r8)r<r>r?�floatr,�
__classcell__�r;s@rrDrD`s���4��4�4�4�4r8rDc�2��eZdZdedeeddf�fd�Z�xZS)�ReportableErrorDhcpLeaserE�	interfacerNc�`��t�|�d�||jd<||jd<y)Nzfailure to obtain DHCP leaserErNrG)r*rErNr;s   �rr,z!ReportableErrorDhcpLease.__init__hs1���
���7�8�+3����Z�(�,5����[�)r8)r<r>r?rIrr@r,rJrKs@rrMrMgs&���6��6�8�C�=�6�T�6�6r8rMc�j��eZdZdeedeedeedeeeeefdeeefddf�fd�Z	�xZ
S)	�(ReportableErrorDhcpOnNonPrimaryInterfacerN�driver�router�
static_routes�leaserNc���t�|�d�||jd<||jd<||jd<||jd<||jd<y)Nz&failure to find primary DHCP interfacerNrRrSrTrUrG)r*rNrRrSrTrUr;s      �rr,z1ReportableErrorDhcpOnNonPrimaryInterface.__init__psc���	���A�B�,5����[�)�)/����X�&�)/����X�&�0=����_�-�(-����W�%r8)r<r>r?rr@rr	rrr,rJrKs@rrQrQoso���.��C�=�.���
�	.�
��
�.� ��U�3��8�_� 5�6�
.��C��H�~�.�
�.�.r8rQc�,��eZdZdededdf�fd�Z�xZS)�ReportableErrorImdsUrlError�	exceptionrErNc���t|jtj�rd}nmt|jtj�rd}nFt|jtj
�rd}n|jrd|j�d�}nd}t�|�!|�|jr|j|jd<||jd<t|�|jd	<|j|jd
<y)Nz connection timeout querying IMDSzconnection error querying IMDSzread timeout querying IMDSzhttp error z querying IMDSzunexpected error querying IMDS�	http_coderErY�url)r5�cause�requests�ConnectTimeout�ConnectionError�ReadTimeout�coderHr,r�reprr\)r*rYrEr r;s    �rr,z$ReportableErrorImdsUrlError.__init__�s�����i�o�o�x�'>�'>�?�7�F�
�	����)A�)A�
B�5�F�
�	����)=�)=�
>�1�F�
�^�^�"�9�>�>�"2�.�A�F�5�F�
���� ��>�>�09���D� � ��-�+3����Z�(�,0��O����[�)�&/�m�m����U�#r8)r<r>r?r
rIr,rJrKs@rrXrX�s"���4�X�4��4�4�4�4r8rXc�,��eZdZdededdf�fd�Z�xZS)�"ReportableErrorImdsInvalidMetadata�key�valuerNc�x��t�|�d|���||jd<t|�|jd<y)Nzinvalid IMDS metadata for key=rfrg)rHr,rrc)r*rfrgr;s   �rr,z+ReportableErrorImdsInvalidMetadata.__init__�s<���
���9�#��?�@�&)����U�#�(,�U�����W�%r8)r<r>r?r@rr,rJrKs@rrere�s"���4�s�4�3�4�4�4�4r8rec�(��eZdZdeddf�fd�Z�xZS)�+ReportableErrorImdsMetadataParsingExceptionrYrNc�T��t�|�d�t|�|jd<y)Nzerror parsing IMDS metadatarY)rHr,rcr)r*rYr;s  �rr,z4ReportableErrorImdsMetadataParsingException.__init__�s%���
���6�7�,0��O����[�)r8)r<r>r?�
ValueErrorr,rJrKs@rrjrj�s���<�Z�<�D�<�<r8rjc� ��eZdZd�fd�Z�xZS)�ReportableErrorOsDiskPpsFailurec�$��t�|�d�y)Nzerror waiting for host shutdown�rHr,)r*r;s �rr,z(ReportableErrorOsDiskPpsFailure.__init__�s���
���:�;r8)rN)r<r>r?r,rJrKs@rrnrn�s
���<�<r8rnc�(��eZdZdeddf�fd�Z�xZS)�!ReportableErrorOvfInvalidMetadata�messagerNc�*��t�|�d|���y)Nz)unexpected metadata parsing ovf-env.xml: rp)r*rsr;s  �rr,z*ReportableErrorOvfInvalidMetadata.__init__�s���
���D�W�I�N�Or8)r<r>r?r@r,rJrKs@rrrrr�s���P��P��P�Pr8rrc�<��eZdZdejddf�fd�Z�xZS)�"ReportableErrorOvfParsingExceptionrYrNc�B��|j}t�|�	d|���y)Nzerror parsing ovf-env.xml: )�msgrHr,)r*rYrsr;s   �rr,z+ReportableErrorOvfParsingException.__init__�s!����-�-��
���6�w�i�@�Ar8)r<r>r?r
�
ParseErrorr,rJrKs@rrvrv�s%���B�[�%;�%;�B��B�Br8rvc�(��eZdZdeddf�fd�Z�xZS)�!ReportableErrorUnhandledExceptionrYrNc�J��t�|�d�djtjt|�||j��}tj|jd��jd�}t|�|jd<||jd<y)Nzunhandled exception�zutf-8rY�traceback_base64)
rHr,�join�	traceback�format_exception�type�
__traceback__�base64�	b64encode�encode�decodercr)r*rY�trace�trace_base64r;s    �rr,z*ReportableErrorUnhandledException.__init__�s����
���.�/�����&�&��Y���I�,C�,C�
�
��
�'�'����W�(=�>�E�E�g�N��,0��O����[�)�3?����/�0r8)r<r>r?r)r,rJrKs@rr{r{�s���@�)�@��@�@r8r{)�|�')'r�r�loggingr�rrr�typingrrrrr	�	xml.etreer
r^�	cloudinitr�cloudinit.sources.azurer�cloudinit.url_helperr
�	getLoggerr<�LOGr@rr)rrDrMrQrXrerjrnrrrvr{rBr8r�<module>r�s���
�
�����3�3�!���,�)��g����!��=@�
&�
�s�)�
&� #�
&�69�
&��
&� 6
�i�6
�r4�?�4�6��6�.��.�&4�/�4�04��4�<�/�<�<�o�<�
P��P�
B��B�@��@r8