
    f                     &   d dl mZmZmZmZmZ d dlmZmZm	Z	m
Z
mZ d dlmZ d dlmZmZ d dlmZmZmZ  ej*                         Z G d dej.                        Z G d d	e      Z G d
 de      Z G d de      Z G d de      Z G d de      Zy)    )AnyDictOptionalTupleType)aptevent_loggermessagessystemutil)repo)IncompatibleServiceUAEntitlement)MessagingOperationsMessagingOperationsDictStaticAffordancec                      e Zd ZdZej
                  Zej                  Zej                  Z
ej                  j                  ZdZdZdZdZdZdefdZdeeee   f   fdZedeed	f   fd
       Zedeed	f   fd       Zede fd       Z!ddZ"y)RealtimeKernelEntitlementzrealtime-kernelzubuntu-pro-realtime-kernel.gpgTFUbuntuRealtimeKernelreturnc                     t        j                  t        | j                        t        dg            }t        j                  |       |S )z%Check if system needs to be rebooted.zlinux-.*-realtime)installed_pkgsinstalled_pkgs_regex)r   should_rebootsetpackageseventneeds_reboot)selfreboot_requireds     @/usr/lib/python3/dist-packages/uaclient/entitlements/realtime.py_check_for_rebootz+RealtimeKernelEntitlement._check_for_reboot   s@     ..t}}-!$&9%:!;
 	?+    c                     t         j                  t         t        j                  t        t        j                  t        t        j                  t        iS N)GenericRealtimevariant_nameNvidiaTegraRealtimeRaspberryPiRealtimeIntelIotgRealtimer   s    r!   _get_variantsz'RealtimeKernelEntitlement._get_variants$   s;    ((/,,.A,,.A**,=	
 	
r#   .c                     ddl m}m} ddlm} t        |t        j                        t        |t        j                        t        |t        j                        fS )Nr   )FIPSEntitlementFIPSUpdatesEntitlement)LivepatchEntitlement)
uaclient.entitlements.fipsr.   r/   uaclient.entitlements.livepatchr0   r   r
   REALTIME_FIPS_INCOMPATIBLE"REALTIME_FIPS_UPDATES_INCOMPATIBLEREALTIME_LIVEPATCH_INCOMPATIBLE)r   r.   r/   r0   s       r!   incompatible_servicesz/RealtimeKernelEntitlement.incompatible_services,   sW    	
 	I  !D!D  &;;  $h&N&N
 	
r#   c                 ,    t         j                  d dffS )Nc                  *    t        j                         S r%   )r   is_container r#   r!   <lambda>z>RealtimeKernelEntitlement.static_affordances.<locals>.<lambda>F   s    ++- r#   F)r
   #REALTIME_ERROR_INSTALL_ON_CONTAINERr+   s    r!   static_affordancesz,RealtimeKernelEntitlement.static_affordancesA   s"     <<-
 	
r#   c                     d }| j                   s/t        j                  t        j                  | j
                  ddfg}d }| j                  s.t        j                  t        j                  | j
                  dfg}||dS )NT)msg
assume_yesdefault)r?   r@   )
pre_enablepre_disable)access_onlyr   prompt_for_confirmationr
   REALTIME_PROMPTr@   purgeREALTIME_PRE_DISABLE_PROMPT)r   rB   rC   s      r!   	messagingz#RealtimeKernelEntitlement.messagingK   s     
 00'77&*oo#'	J zz 00'CC&*ooK %&
 	
r#   Nc                    t        | j                        j                  t        t        j                                     }|rHt        j
                  t        |      t        j                  j                  | j                               y y )N)title)r   r   intersectionr   get_installed_packages_namesremove_packageslistr
   DISABLE_FAILED_TMPLformatrK   )r   r   s     r!   rN   z)RealtimeKernelEntitlement.remove_packagesm   sf    t}}%220023
 X,,33$**3E r#   )r   N)#__name__
__module____qualname__namer
   REALTIME_TITLErK   REALTIME_DESCRIPTIONdescriptionREALTIME_HELP_TEXT	help_texturlsREALTIME_HOME_PAGEhelp_doc_urlrepo_key_fileapt_noninteractivesupports_access_onlysupports_purgeoriginboolr"   r   strr   r   r,   propertyr   r   r6   r   r=   r   rI   rN   r:   r#   r!   r   r      s    D##E//K++I==33L4MN#F4 
tCm)<$<= 
 
u-@#-E'F 
 
( 
E*:C*?$@ 
 
 
	 
 
Br#   r   c                   8     e Zd Zedeedf   f fd       Z xZS )RealtimeVariantr   .c                    t        | j                  j                         D cg c]D  \  }}t        |t        j
                  j                  | j                  |j                              F c}}      }t        | $  |z   S c c}}w )N)servicevariant)
tupleother_variantsitemsr   r
   REALTIME_VARIANT_INCOMPATIBLErQ   rK   superr6   )r   rU   clsincompatible_variants	__class__s       r!   r6   z%RealtimeVariant.incompatible_servicesy   s     % "&!4!4!:!:!< D# $::AA $

CII B 
!
 w,/DDDs   A	B
)rR   rS   rT   re   r   r   r6   __classcell__)rr   s   @r!   rg   rg   x   s*    Eu-@#-E'F E Er#   rg   c                   H    e Zd ZdZej
                  Zej                  ZdZ	dZ
y)r&   genericTN)rR   rS   rT   r'   r
   REALTIME_GENERIC_TITLErK   REALTIME_GENERIC_DESCRIPTIONrX   
is_variantcheck_packages_are_installedr:   r#   r!   r&   r&      s(    L++E77KJ#' r#   r&   c                   H    e Zd ZdZej
                  Zej                  ZdZ	dZ
y)r(   znvidia-tegraTN)rR   rS   rT   r'   r
   REALTIME_NVIDIA_TITLErK   REALTIME_NVIDIA_DESCRIPTIONrX   rx   ry   r:   r#   r!   r(   r(      s(    !L**E66KJ#' r#   r(   c                   H    e Zd ZdZej
                  Zej                  ZdZ	dZ
y)r)   rpiTN)rR   rS   rT   r'   r
   REALTIME_RASPI_TITLErK   REALTIME_RASPI_DESCRIPTIONrX   rx   ry   r:   r#   r!   r)   r)      s(    L))E55KJ#' r#   r)   c                       e Zd ZdZej
                  Zej                  ZdZ	dZ
deeef   deeeej"                     f   fdZy)r*   z
intel-iotgTplatform_checksr   c                     t        j                         j                  }|j                  dg       }||v rydt        j
                  j                  | j                  |dj                  |            fS )Ncpu_vendor_ids)TNF,)rK   vendorsupported_vendors)	r   get_cpu_info	vendor_idgetr
   INAPPLICABLE_VENDOR_NAMErQ   rK   join)r   r   r   r   s       r!   verify_platform_checksz(IntelIotgRealtime.verify_platform_checks   sr     '')33	(,,-=rB&(;;BBjj "%((>": C   r#   N)rR   rS   rT   r'   r
   REALTIME_INTEL_TITLErK   REALTIME_INTEL_DESCRIPTIONrX   rx   ry   r   rd   r   r   rc   r   NamedMessager   r:   r#   r!   r*   r*      sZ    L))E55KJ#' #CH~	tXh3344	5r#   r*   N)typingr   r   r   r   r   uaclientr   r	   r
   r   r   uaclient.entitlementsr   uaclient.entitlements.baser   r   uaclient.typesr   r   r   get_event_loggerr   RepoEntitlementr   rg   r&   r(   r)   r*   r:   r#   r!   <module>r      s    3 3 > > & I  	&%%'f 4 4 fRE/ E"(o ((/ ((/ ( r#   