/snap/core18/2979/usr/lib/python3/dist-packages/cloudinit
NameSizeModeActions
analyze/-0755rm
cmd/-0755rm
config/-0755rm
distros/-0755rm
filters/-0755rm
handlers/-0755rm
mergers/-0755rm
net/-0755rm
reporting/-0755rm
sources/-0755rm
__pycache__/-0755rm
apport.py58810644editdlrm
atomic_helper.py14170644editdlrm
cloud.py35740644editdlrm
dhclient_hook.py25490644editdlrm
dmi.py69790644editdlrm
event.py20970644editdlrm
features.py31460644editdlrm
gpg.py44240644editdlrm
helpers.py168280644editdlrm
importer.py17890644editdlrm
log.py44320644editdlrm
netinfo.py231150644editdlrm
patcher.py11300644editdlrm
persistence.py26050644editdlrm
registry.py10450644editdlrm
safeyaml.py79050644editdlrm
settings.py20410644editdlrm
signal_handler.py18260644editdlrm
simpletable.py19760644editdlrm
ssh_util.py212110644editdlrm
stages.py353110644editdlrm
subp.py135580644editdlrm
templater.py59650644editdlrm
temp_utils.py32680644editdlrm
type_utils.py7260644editdlrm
url_helper.py286280644editdlrm
user_data.py148410644editdlrm
util.py926220644editdlrm
version.py5960644editdlrm
warnings.py39320644editdlrm
__init__.py00644editdlrm
Edit: /snap/core18/2979/usr/lib/python3/dist-packages/cloudinit/event.py (2097B)
# This file is part of cloud-init. See LICENSE file for license information. """Classes and functions related to event handling.""" from enum import Enum from typing import Dict, Set from cloudinit import log as logging 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 # vi: ts=4 expandtab