
    }f                         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e      Z
 G d de      Zd	ed
ee
ee   f   fdZy)z0Classes and functions related to event handling.    N)Enum)DictSetc                       e Zd ZdZd Zy)
EventScopenetworkc                     | j                   S Nvalueselfs    1/usr/lib/python3/dist-packages/cloudinit/event.py__str__zEventScope.__str__       zz    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y)	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 D+KGr   r   user_configreturnc                    i }| j                         D ];  \  }}	 t        |      }	 |d   D cg c]  }t        |       }}t        |      ||<   = |S # t        $ r*}t        j	                  dt        |      |       Y d}~nd}~ww xY wc c}w # t        $ r,}t        j	                  dt        |      |       g }Y d}~}d}~ww xY w)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' scopeNwhen)itemsr   
ValueErrorLOGwarningstrr   set)r"   update_configscope
scope_list	new_scopeex
new_valuess           r   userdata_to_eventsr3   &   s     M(..0 3z	"5)I	0:60BC1)A,CJC $'z?i '3* %  	KK@A
 	 D 	KK@A
 J	s>   ABB	B	B BB	B	C"B>>C)r   loggingenumr   typingr   r   	getLoggerr   r(   r   r   dictr3   r   r   r   <module>r9      s\    6   g!  "!D !T*c)n2L-M !r   