a '¡Dgkã@s¢ddlZddlmZmZddlmZddlmZddlmZm Z ddl m Z m Z e  e¡Zeejdœdd „Zeed œd d „Ze jed œdd„Zedœdd„ZdS)éN)ÚdatetimeÚtimezone)ÚOptional)Úversion)ÚhandlersÚinstantiated_handler_registry)ÚerrorsÚidentity)ÚreturncCs tj d¡}t|tjƒsdS|S)z'Get instantiated KVP telemetry handler.Z telemetryN)rZregistered_itemsÚgetÚ isinstancerÚHyperVKvpReportingHandler)Ú kvp_handler©rú?/usr/lib/python3.9/site-packages/cloudinit/sources/azure/kvp.pyÚget_kvp_handlers ÿ r)Úreportr cCs,tƒ}|durt d¡dS| d|¡dS)z/Report to host via PROVISIONING_REPORT KVP key.Nz.KVP handler not enabled, skipping host report.FZPROVISIONING_REPORTT)rÚLOGÚdebugZ write_key)rrrrrÚreport_via_kvps   r)Úerrorr cCs t| ¡ƒS)N)rZas_encoded_report)rrrrÚreport_failure_to_host&src Csxz t ¡}Wn.ty:}zd|›�}WYd}~n d}~00t ddt ¡›�dt t j ¡  ¡›�d|›�g¡}t |ƒS)Nzfailed to read vm id: zresult=successzagent=Cloud-Init/z timestamp=zvm_id=) r Z query_vm_idÚ ExceptionrZ encode_reportrZversion_stringrZnowrZutcZ isoformatr)Zvm_idZid_errorrrrrÚreport_success_to_host*s   üÿ r)ZloggingrrÚtypingrZ cloudinitrZcloudinit.reportingrrZcloudinit.sources.azurerr Z getLoggerÚ__name__rr rÚstrÚboolrZReportableErrorrrrrrrÚs