| Server IP : 127.0.1.1 / Your IP : 216.73.216.173 Web Server : Apache/2.4.52 (Ubuntu) System : Linux bahcrestlinepropertiesllc 5.15.0-181-generic #191-Ubuntu SMP Fri May 22 19:09:02 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 7.4.33 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 : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /snap/core22/2437/lib/python3/dist-packages/cloudinit/sources/helpers/ |
Upload File : |
# Author: Jonas Keidel <jonas.keidel@hetzner.com>
# Author: Markus Schade <markus.schade@hetzner.com>
#
# This file is part of cloud-init. See LICENSE file for license information.
from typing import Optional, Tuple
from cloudinit import net, url_helper
def _skip_retry_on_empty_response(cause: url_helper.UrlError) -> bool:
return cause.code != 204
def get_metadata(
urls,
max_wait=120,
timeout=2,
sleep_time=2,
) -> Tuple[Optional[str], bytes]:
try:
url, contents = url_helper.wait_for_url(
urls=urls,
max_wait=max_wait,
timeout=timeout,
sleep_time=sleep_time,
# It is ok for userdata to not exist (that's why we are stopping if
# HTTP code is 204) and just in that case returning an empty
# string.
exception_cb=_skip_retry_on_empty_response,
)
if not url:
raise RuntimeError("No data received from urls: '%s':" % urls)
return url, contents
except url_helper.UrlError as e:
if e.code == 204:
return e.url, b""
raise
def get_interface_name_from_mac(mac: str) -> Optional[str]:
mac_to_iface = net.get_interfaces_by_mac()
return mac_to_iface.get(mac.lower())