o Hcf@sddlmZmZmZmZmZddlmZmZm Z m Z m Z ddl m Z ddlmZmZddlmZmZmZeZGddde jZGdd d eZGd d d eZGd d d eZGdddeZGdddeZdS))AnyDictOptionalTupleType)apt event_loggermessagessystemutil)repo)EntitlementWithMessage UAEntitlement)MessagingOperationsMessagingOperationsDictStaticAffordancec@seZdZdZejZejZej Z ej j Z dZdZdZdZdZdefddZdeeeeffd d Zedeed ffd d Zedeed ffddZede fddZ!dddZ"dS)RealtimeKernelEntitlementzrealtime-kernelzubuntu-pro-realtime-kernel.gpgTFUbuntuRealtimeKernelreturncCs(tjt|jtdgd}t||S)z%Check if system needs to be rebooted.zlinux-.*-realtime)installed_pkgsinstalled_pkgs_regex)r should_rebootsetpackagesevent needs_reboot)selfreboot_requiredr@/usr/lib/python3/dist-packages/uaclient/entitlements/realtime.py_check_for_reboots  z+RealtimeKernelEntitlement._check_for_rebootcCstjttjttjttjtiSN)GenericRealtime variant_nameNvidiaTegraRealtimeRaspberryPiRealtimeIntelIotgRealtimerrrr _get_variants$s z'RealtimeKernelEntitlement._get_variants.cCs>ddlm}m}ddlm}t|tjt|tjt|tj fS)Nr)FIPSEntitlementFIPSUpdatesEntitlement)LivepatchEntitlement) uaclient.entitlements.fipsr)r*uaclient.entitlements.livepatchr+r r REALTIME_FIPS_INCOMPATIBLE"REALTIME_FIPS_UPDATES_INCOMPATIBLEREALTIME_LIVEPATCH_INCOMPATIBLE)rr)r*r+rrrincompatible_services,s z/RealtimeKernelEntitlement.incompatible_servicescCstjdddffS)NcSstSr!)r is_containerrrrrFsz>RealtimeKernelEntitlement.static_affordances..F)r #REALTIME_ERROR_INSTALL_ON_CONTAINERr'rrrstatic_affordancesAs z,RealtimeKernelEntitlement.static_affordancescCsLd}|jstjtj|jddfg}d}|js!tjtj|jdfg}||dS)NT)msg assume_yesdefault)r6r7) pre_enable pre_disable) access_onlyr prompt_for_confirmationr REALTIME_PROMPTr7purgeREALTIME_PRE_DISABLE_PROMPT)rr9r:rrr messagingKs(  z#RealtimeKernelEntitlement.messagingNcCs@t|jtt}|rtt|tjj |j ddSdS)N)title) rr intersectionrget_installed_packages_namesremove_packageslistr DISABLE_FAILED_TMPLformatrA)rrrrrrDms  z)RealtimeKernelEntitlement.remove_packages)rN)#__name__ __module__ __qualname__namer REALTIME_TITLErAREALTIME_DESCRIPTION descriptionREALTIME_HELP_TEXT help_texturlsREALTIME_HOME_PAGE help_doc_url repo_key_fileapt_noninteractivesupports_access_onlysupports_purgeoriginboolr rstrrrr(propertyrr r1rr5rr@rDrrrrrs,   !rcs.eZdZedeedfffdd ZZS)RealtimeVariantr.cs(tfddjD}tj|S)Ncs*g|]\}}t|tjjj|jdqS))servicevariant)r r REALTIME_VARIANT_INCOMPATIBLErGrA).0rKclsr'rr |sz9RealtimeVariant.incompatible_services..)tupleother_variantsitemssuperr1)rincompatible_variants __class__r'rr1ys   z%RealtimeVariant.incompatible_services)rHrIrJr[rr r1 __classcell__rrrhrr\xs$r\c@$eZdZdZejZejZdZ dZ dS)r"genericTN) rHrIrJr#r REALTIME_GENERIC_TITLErAREALTIME_GENERIC_DESCRIPTIONrN is_variantcheck_packages_are_installedrrrrr" r"c@rk)r$z nvidia-tegraTN) rHrIrJr#r REALTIME_NVIDIA_TITLErAREALTIME_NVIDIA_DESCRIPTIONrNrorprrrrr$rqr$c@rk)r%raspiTN) rHrIrJr#r REALTIME_RASPI_TITLErAREALTIME_RASPI_DESCRIPTIONrNrorprrrrr%rqr%c@sLeZdZdZejZejZdZ dZ de e e fdeeeejffddZdS)r&z intel-iotgTplatform_checksrcCs@tj}|dg}||vrdSdtjj|j|d|dfS)Ncpu_vendor_ids)TNF,)rAvendorsupported_vendors) r get_cpu_info vendor_idgetr INAPPLICABLE_VENDOR_NAMErGrAjoin)rrwr}rxrrrverify_platform_checkss  z(IntelIotgRealtime.verify_platform_checksN)rHrIrJr#r REALTIME_INTEL_TITLErAREALTIME_INTEL_DESCRIPTIONrNrorprrZrrrYr NamedMessagerrrrrr&s r&N)typingrrrrruaclientrrr r r uaclient.entitlementsr uaclient.entitlements.baser ruaclient.typesrrrget_event_loggerrRepoEntitlementrr\r"r$r%r&rrrrs i