o
    K&b
                     @   sz   d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ G dd dejZG dd	 d	eZG d
d deZdS )    )OptionalTupleUnion)util)repo)update_apt_and_motd_messages)CanDisableFailurec                       sV   e Zd ZdZdZddedef fddZ	ddeeede	f f f fd	d
Z
  ZS )ESMBaseEntitlementzhttps://ubuntu.com/security/esm)Zroszros-updatesFsilentreturnc                    s    t  j|d}|rt| j |S N)r
   )super_perform_enabler   cfg)selfr
   Zenable_performed	__class__ ;/usr/lib/python3/dist-packages/uaclient/entitlements/esm.pyr      s   
z"ESMBaseEntitlement._perform_enableNc                    s(   t  j|d\}}|rt| j ||fS r   )r   disabler   r   )r   r
   Zdisable_performedZfailr   r   r   r      s   
zESMBaseEntitlement.disable)F)__name__
__module____qualname__Zhelp_doc_urlZ_dependent_servicesboolr   r   r   r   r   __classcell__r   r   r   r   r	   	   s    r	   c                   @   sL   e Zd ZdZdZdZdZdZdZe	de
e fdd	Ze	defd
dZdS )ESMAppsEntitlementZUbuntuESMAppszesm-appszUA Apps: ESMz,UA Apps: Extended Security Maintenance (ESM)zubuntu-advantage-esm-apps.gpgTr   c                 C   s0   t  d }|dkrdS | jrt |rdS dS )z9All LTS with the exception of Trusty should pin esm-apps.seriestrustyNneverr   get_platform_infoZvalid_serviceZis_ltsr   r   r   r   r   repo_pin_priority$   s   
z$ESMAppsEntitlement.repo_pin_priorityc                 C   s,   t  d }|dkrdS | jrt |S dS )z7All LTSexcept Trusty remove APT auth files upon disabler   r   Fr   r!   r   r   r   disable_apt_auth_only0   s   
z(ESMAppsEntitlement.disable_apt_auth_onlyN)r   r   r   originnametitledescriptionrepo_key_fileZis_betapropertyr   strr"   r   r#   r   r   r   r   r      s    r   c                   @   sH   e Zd ZdZdZdZdZdZede	e
 fddZedefd	d
ZdS )ESMInfraEntitlementz	esm-infraZ	UbuntuESMzUA Infra: ESMz-UA Infra: Extended Security Maintenance (ESM)z%ubuntu-advantage-esm-infra-trusty.gpgr   c                 C   s   t t  d rdS dS )z9Once a release goes into EOL it is entitled to ESM Infra.r   r   Nr   Zis_active_esmr    r   r   r   r   r"   C   s   z%ESMInfraEntitlement.repo_pin_priorityc                 C   s   t t  d S )zUbuntu EOL releases are in active ESM.

        Leave unauthenticated APT sources on disk with never pinning to ensure
        visibility to UA ESM: Infra packages for MOTD/APT messaging.
        r   r,   r-   r   r   r   r#   J   s   z)ESMInfraEntitlement.disable_apt_auth_onlyN)r   r   r   r%   r$   r&   r'   r(   r)   r   r*   r"   r   r#   r   r   r   r   r+   <   s    r+   N)typingr   r   r   Zuaclientr   Zuaclient.entitlementsr   Zuaclient.jobs.update_messagingr   Zuaclient.statusr   ZRepoEntitlementr	   r   r+   r   r   r   r   <module>   s     