4:20 # ˆl–Ðz¾”ji?u4 \¸î*bÑ¿Ç ƒÆÅÄ # 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 #ˆl–äY>” je¶…8 Cq§nµ1hßÈ ƒt.7ÇÆÅýa ´iF)ã@sšdZgd¢ZddlZdZdZdZeeZdZedd Zd Z d Z eee eZ dd d „Z ddl ZddlmZiZGdd„dƒZe ¡Gdd„dƒZdS)anA collection of string constants. Public module variables: whitespace -- a string containing all ASCII whitespace ascii_lowercase -- a string containing all ASCII lowercase letters ascii_uppercase -- a string containing all ASCII uppercase letters ascii_letters -- a string containing all ASCII letters digits -- a string containing all ASCII decimal digits hexdigits -- a string containing all ASCII hexadecimal digits octdigits -- a string containing all ASCII octal digits punctuation -- a string containing all ASCII punctuation characters printable -- a string containing all ASCII characters considered printable ) Ú ascii_lettersÚascii_lowercaseÚascii_uppercaseÚcapwordsÚdigitsÚ hexdigitsÚ octdigitsÚ printableÚ punctuationÚ whitespaceÚ FormatterÚTemplateéNz ÚabcdefghijklmnopqrstuvwxyzÚABCDEFGHIJKLMNOPQRSTUVWXYZÚ 0123456789ZabcdefZABCDEFÚ01234567z !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~cCs|pd dd„| |¡Dƒ¡S)a‘capwords(s [,sep]) -> string Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. If the optional second argument sep is absent or None, runs of whitespace characters are replaced by a single space and leading and trailing whitespace are removed, otherwise sep is used to split and join the words. ú css|]}| ¡VqdS©N)Ú capitalize)Ú.0Úx©rú/usr/lib64/python3.9/string.pyÚ 0ózcapwords..)ÚjoinÚsplit)ÚsÚseprrrr%s r)ÚChainMapcsZeZdZdZdZdZdZejZ ‡fdd„Z dd„Z d d „Z e fd d „Ze fd