
    ܍~c1                         d Z ddlmZ ddlmZmZ ddlmZ  ej	        e
          Z G d de          Z G d de          Zd	ed
eeee         f         fdZdS )z0Classes and functions related to event handling.    )Enum)DictSet)logc                       e Zd ZdZd ZdS )
EventScopenetworkc                     | j         S Nvalueselfs    1/usr/lib/python3/dist-packages/cloudinit/event.py__str__zEventScope.__str__   
    z    N)__name__
__module____qualname__NETWORKr    r   r   r   r      s*         G    r   r   c                   (    e Zd ZdZdZdZdZdZd ZdS )	EventTypezCEvent types which can generate maintenance requests for cloud-init.bootzboot-new-instancezboot-legacyhotplugc                     | j         S r   r   r   s    r   r   zEventType.__str__#   r   r   N)	r   r   r   __doc__BOOTBOOT_NEW_INSTANCEBOOT_LEGACYHOTPLUGr   r   r   r   r   r      s@        MM D+KG    r   r   user_configreturnc                    i }|                                  D ]\  }}	 t          |          }n@# t          $ r3}t                              dt          |          |           Y d}~Nd}~ww xY w	 d |d         D             }nB# t          $ r5}t                              dt          |          |           g }Y d}~nd}~ww xY wt          |          ||<   |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                 ,    g | ]}t          |          S r   )r   ).0xs     r   
<listcomp>z&userdata_to_events.<locals>.<listcomp>>   s    CCC1)A,,CCCr   when)itemsr   
ValueErrorLOGwarningstrset)r#   update_configscope
scope_list	new_scopee
new_valuess          r   userdata_to_eventsr7   '   s    M(..00 3 3z	"5))II 	 	 	KK@A  
 HHHH		CC
60BCCCJJ 	 	 	KK@A  
 JJJJJJ	 $'z??i  s,   -
A*)A%%A*.B
C +B;;C N)r   enumr   typingr   r   	cloudinitr   logging	getLoggerr   r-   r   r   dictr7   r   r   r   <module>r>      s    6 6               $ $ $ $ $ $g!!              "!D !T*c)n2L-M ! ! ! ! ! !r   