Uname: Linux wputd 5.4.0-200-generic #220-Ubuntu SMP Fri Sep 27 13:19:16 UTC 2024 x86_64
Software: Apache/2.4.41 (Ubuntu)
PHP version: 7.4.3-4ubuntu2.24 [ PHP INFO ] PHP os: Linux
Server Ip: 158.69.144.88
Your Ip: 3.129.25.216
User: www-data (33) | Group: www-data (33)
Safe Mode: OFF
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,

name : akamai.py
import re
from typing import Any, Dict, Optional, Union

from cloudinit import dmi

# dmi data can override
DMI_OVERRIDE_MAP = {
    "als": "allow_local_stage",
    "ais": "allow_init_stage",
    "dhcp": "allow_dhcp",
    "v4": "allow_ipv4",
    "v6": "allow_ipv6",
    "pmp": "preferred_mac_prefixes",
}


def get_dmi_config() -> Dict[str, Union[bool, str]]:
    """
    Parses flags from dmi data and updates self.ds_cfg accordingly
    """
    dmi_flags = dmi.read_dmi_data("baseboard-serial-number")
    ret: Dict[str, Any] = {}

    if not dmi_flags:
        return ret

    # parse the value into individual flags, then set them in our config
    # based on the short name lookup table
    for key, value, _ in re.findall(r"([a-z0-9]+)=(.*?)(;|$)", dmi_flags):
        if key in DMI_OVERRIDE_MAP:
            if value in "01":
                value = bool(int(value))
            elif key == "pmp":
                value = value.split(",")
            ret[DMI_OVERRIDE_MAP[key]] = value

    return ret


def is_on_akamai() -> bool:
    """
    Reads the BIOS vendor from dmi data to determine if we are running in the
    Akamai Connected Cloud.
    """
    vendor = dmi.read_dmi_data("system-manufacturer")
    return vendor in ("Linode", "Akamai")


def get_local_instance_id() -> Optional[str]:
    """
    Returns the instance id read from dmi data without requiring the metadata
    service to be reachable
    """
    return dmi.read_dmi_data("system-serial-number")
© 2025 GrazzMean-Shell