| Server IP : 185.11.201.71 / Your IP : 192.168.7.18 Web Server : Apache/2.4.29 (Ubuntu) System : Linux tech-virtual-machine 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 User : tech ( 1000) PHP Version : 7.4.28 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /snap/core24/current/lib/python3/dist-packages/cloudinit/sources/azure/ |
Upload File : |
# Copyright (C) 2022 Microsoft Corporation.
#
# This file is part of cloud-init. See LICENSE file for license information.
import logging
from datetime import datetime, timezone
from typing import Optional
from cloudinit import version
from cloudinit.reporting import handlers, instantiated_handler_registry
from cloudinit.sources.azure import errors
LOG = logging.getLogger(__name__)
def get_kvp_handler() -> Optional[handlers.HyperVKvpReportingHandler]:
"""Get instantiated KVP telemetry handler."""
kvp_handler = instantiated_handler_registry.registered_items.get(
"telemetry"
)
if not isinstance(kvp_handler, handlers.HyperVKvpReportingHandler):
return None
return kvp_handler
def report_via_kvp(report: str) -> bool:
"""Report to host via PROVISIONING_REPORT KVP key."""
kvp_handler = get_kvp_handler()
if kvp_handler is None:
LOG.debug("KVP handler not enabled, skipping host report.")
return False
kvp_handler.write_key("PROVISIONING_REPORT", report)
return True
def report_success_to_host(*, vm_id: Optional[str]) -> bool:
report = errors.encode_report(
[
"result=success",
f"agent=Cloud-Init/{version.version_string()}",
f"timestamp={datetime.now(timezone.utc).isoformat()}",
f"vm_id={vm_id}",
]
)
return report_via_kvp(report)