3 \¼meã@srdZddlZddlmZddlmZmZejeƒZ Gdd„deƒZ Gdd„deƒZ e ee ee fd œd d „Z dS) z0Classes and functions related to event handling.éN)ÚEnum)ÚDictÚSetc@seZdZdZdd„ZdS)Ú EventScopeZnetworkcCs|jS)N)Úvalue)Úself©rú/usr/lib/python3.6/event.pyÚ__str__szEventScope.__str__N)Ú__name__Ú __module__Ú __qualname__ZNETWORKr rrrr r src@s(eZdZdZdZdZdZdZdd„ZdS) Ú EventTypezCEvent types which can generate maintenance requests for cloud-init.Zbootzboot-new-instancez boot-legacyZhotplugcCs|jS)N)r)rrrr r "szEventType.__str__N) r r r Ú__doc__ZBOOTZBOOT_NEW_INSTANCEZ BOOT_LEGACYZHOTPLUGr rrrr rs r)Ú user_configÚreturnc Cs¾i}x´|jƒD]¨\}}y t|ƒ}Wn6tk rX}ztjdt|ƒ|ƒwWYdd}~XnXydd„|dDƒ}Wn8tk r¨}ztjdt|ƒ|ƒg}WYdd}~XnXt|ƒ||<qW|S)aConvert 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 z.%s! Update data will be ignored for '%s' scopeNcSsg|] }t|ƒ‘qSr)r)Ú.0Úxrrr ú =sz&userdata_to_events..Zwhen)ÚitemsrÚ ValueErrorÚLOGZwarningÚstrÚset)rZ update_configZscopeZ scope_listZ new_scopeÚeZ new_valuesrrr Úuserdata_to_events&s(  r)rZloggingÚenumrZtypingrrZ getLoggerr rrrÚdictrrrrr Ús