3 \meJ@s(ddlZddlZddlZddlZddlmZddlmZddlmZm Z m Z m Z m Z ddl Z ddlmZddlmZddlmZejeZde eeeed d d ZGd ddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZ GdddeZ!dS)N)datetime)StringIO)AnyDictListOptionalTuple)version)identity)UrlError|')data delimiter quotecharreturnc Cs8t(}tj|||tjdj||jjSQRXdS)zEncode report data with csv.)rrZquotingN)rcsvwriterZ QUOTE_MINIMALZwriterowgetvaluerstrip)rrrior/usr/lib/python3.6/errors.py encode_reports rc@sZeZdZddeeeeefddddZedddZe dd d Z edd d Z dS) ReportableErrorN)supporting_data)reasonrrcCszdtj|_d|_||_|r(||_ni|_tj|_yt j |_ Wn.t k rt}zd||_ WYdd}~XnXdS)Nz Cloud-Init/z%https://aka.ms/linuxprovisioningerrorzfailed to read vm id: ) r Zversion_stringagentdocumentation_urlrrrZutcnow timestampr Z query_vm_idvm_id Exception)selfrrZid_errorrrr__init__'s zReportableError.__init__)rcCsddd|jd|jg}|dd|jjD7}|d|jd|jjd|jg7}t|S) Nz result=errorzreason=zagent=cSsg|]\}}|d|qS)=r).0kvrrr Esz5ReportableError.as_encoded_report..zvm_id=z timestamp=zdocumentation_url=) rrritemsr rZ isoformatrr)r"rrrras_encoded_report=s  z!ReportableError.as_encoded_reportcCs.t|to,|j|jko,|j|jko,|j|jkS)N) isinstancerrrr)r"otherrrr__eq__Ns   zReportableError.__eq__cCs&|jjd|jd|jd|jdS)Nz(reason=z , timestamp=z, supporting_data=)) __class____name__rrr)r"rrr__repr__VszReportableError.__repr__) r0 __module__ __qualname__strrrrr#r*boolr-r1rrrrr&s rcs$eZdZeddfdd ZZS)$ReportableErrorDhcpInterfaceNotFoundN)durationrcstjd||jd<dS)Nzfailure to find DHCP interfacer7)superr#r)r"r7)r/rrr#`s z-ReportableErrorDhcpInterfaceNotFound.__init__)r0r2r3floatr# __classcell__rr)r/rr6_sr6cs*eZdZeeeddfdd ZZS)ReportableErrorDhcpLeaseN)r7 interfacercs$tjd||jd<||jd<dS)Nzfailure to obtain DHCP leaser7r<)r8r#r)r"r7r<)r/rrr#gs  z!ReportableErrorDhcpLease.__init__)r0r2r3r9rr4r#r:rr)r/rr;fsr;csPeZdZeeeeeeeeeeefeeefddfdd Z Z S)(ReportableErrorDhcpOnNonPrimaryInterfaceN)r<driverrouter static_routesleasercsBtjd||jd<||jd<||jd<||jd<||jd<dS)Nz&failure to find primary DHCP interfacer<r>r?r@rA)r8r#r)r"r<r>r?r@rA)r/rrr#os     z1ReportableErrorDhcpOnNonPrimaryInterface.__init__) r0r2r3rr4rrrrr#r:rr)r/rr=ns  r=cs&eZdZeeddfdd ZZS)ReportableErrorImdsUrlErrorN) exceptionr7rcst|jtjrd}nBt|jtjr(d}n.t|jtjrs*       9