
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
\me                 @   sr   d Z ddlZddlmZ ddlmZmZ ejeZ	G dd deZ
G dd deZeee
ee f d	d
dZdS )z0Classes and functions related to event handling.    N)Enum)DictSetc               @   s   e Zd ZdZdd ZdS )
EventScopeZnetworkc             C   s   | j S )N)value)self r   /usr/lib/python3.6/event.py__str__   s    zEventScope.__str__N)__name__
__module____qualname__ZNETWORKr
   r   r   r   r	   r      s   r   c               @   s(   e Zd ZdZdZdZdZdZdd ZdS )		EventTypezCEvent types which can generate maintenance requests for cloud-init.Zbootzboot-new-instancezboot-legacyZhotplugc             C   s   | j S )N)r   )r   r   r   r	   r
   "   s    zEventType.__str__N)	r   r   r   __doc__ZBOOTZBOOT_NEW_INSTANCEZBOOT_LEGACYZHOTPLUGr
   r   r   r   r	   r      s   r   )user_configreturnc              C   s   i }x| j  D ]\}}yt|}W n6 tk
rX } ztjdt|| wW Y dd}~X nX ydd |d D }W n8 tk
r } ztjdt|| g }W Y dd}~X nX t|||< qW |S )a  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
    z.%s! Update data will be ignored for '%s' scopeNc             S   s   g | ]}t |qS r   )r   ).0xr   r   r	   
<listcomp>=   s    z&userdata_to_events.<locals>.<listcomp>Zwhen)itemsr   
ValueErrorLOGZwarningstrset)r   Zupdate_configZscopeZ
scope_listZ	new_scopeeZ
new_valuesr   r   r	   userdata_to_events&   s(    r   )r   Zloggingenumr   Ztypingr   r   Z	getLoggerr   r   r   r   dictr   r   r   r   r	   <module>   s   

