%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_ubuntu_pro.cpython-312.pyc

�

���f�6�
�r�UdZddlZddlZddlZddlmZmZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZdd	lmZd
Zeddg�Zd
dgedgee�zd�Zeed<ej4e�ZdZdZdZde fd�Z!de fd�Z"d%defd�Z#d%d�Z$de
fd�Z%de de&fd�Z'de fd�Z(de fd �Z)d!e*d"ede
d#eddf
d$�Z+y)&z1ubuntu_pro: Configure Ubuntu Pro support services�N)�Any�List)�urlparse)�subp�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCEzhttps://ubuntu.com/prozubuntu-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_sectionc�L�d|vry|d}t|t�s8dt|�j��}tj|�t
|��d|vry|d}t|t�s8dt|�j��}tj|�t
|��y)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�msgrs    �@/usr/lib/python3/dist-packages/cloudinit/config/cc_ubuntu_pro.py�validate_schema_featuresr*+s�����$���:�&�H��h��%���X��'�'�(�
*�	�	�	�	�#���3����H�,��"�#8�9���)�4�0���/�0�9�9�:�
<�	�	�	�	�#���3���
1��
pro_configc��g}t|j��D]U\}}|tvrtj	d|��%|��(	t|�}|jdvr|jd|����W|r)tdjdj|����y#ttf$r|jd|���Y��wxYw)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_urls     r)�supplemental_schema_validationr?Fs����F��Z�-�-�/�0�A�
��U��,�,��K�K�F��
�
�
�]��	A�!�%��J�� � �(9�9��
�
�C�C�5�I���A�&��3�:�:�4�9�9�V�;L�M�
�	
����
�+�	A��M�M�9�#��?�@�	A�s�-B � #C�Cc�Z�|�yt|t�s"tdt|�j�d���t|�g}t
|j��D]�\}}d}i}|�tjd|�ddd|g}nd|�d�}tjd|�tjd	|�r|�d
tj|���}n|�d
|��}ddd|g}d|dd
|gzi}	tj|fi|����|rQ|D]\}
}tj'd|
|��tdj)dj+d�|D�����y#tj$rA}t|�}	|�|	j!|t"�}	|j%||	f�Yd}~��Id}~wwxYw)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): {}�, c3�DK�|]\}}dj|����y�w)z"{}"N)r9)�.0�param�_s   r)�	<genexpr>z!set_pro_config.<locals>.<genexpr>�s����M�8�5�!�&�-�-��.�M�s� )r r!r&r"r#r?r1r2r$�debug�re�search�escaper�ProcessExecutionError�str�replacerr6r4r9r:)r,�
enable_errorsr<r=�redacted_key_value�subp_kwargs�
config_cmd�	key_value�e�err_msgrKr%s            r)�set_pro_configr\ms�������j�$�'����z�"�+�+�,�-3�
3�
�	
�
#�:�.��M��Z�-�-�/�0�1�
��U�!�����=��I�I�3�S�9���7�C�8�J�$'�5�	�!2���I�I�.�0B�C��y�y���&�"�e�1�R�Y�Y�u�%5�$6�7�	�"�e�1�U�G�,�	���5�)�<�J�&�
�3�B��;M�:N�(N�O�K�	1��I�I�j�0�K�0�!1�,�)�	N�L�E�5��K�K�>��u�M�	N��A�H�H��	�	�M�}�M�M�
�
�	
����)�)�	1��!�f�G�!�-�!�/�/�%��:��� � �#�w��0�0��		1�s�*E�F*�)6F%�%F*c�0�|�g}ndt|t�rtjd�|g}n;t|t�s+tjdt|�j�g}|rddd|g}ndd|g}|ddtgz}tjdd	j|��	tj|d
dh|��|sygd�|z}	tj|dd
dh��\}}		t!j"|�}
g}|
j'dg�D]5}|ddk(rtjd|d��%|j)|��7|r~g}|D]Z}|j'd�}
|
�|j)|
�d|
�d|d��}nd|d�d|d��}tjt|��\tddj|�z��y#tj$rO}t|�j|t�}d
|��}tjt|�t|�|�d}~wwxYw#tj$r#}tddj|�z�|�d}~wwxYw#t j$$r}td|���|�d}~wwxYw) 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 servicesrA�attachz--no-auto-enablerGzAttaching to Ubuntu Pro. %s� r�)�rcsrFzFailure attaching Ubuntu Pro:
)rA�enablez--assume-yesz--format�jsonT�)�captureraz!Error while enabling service(s): rHzPro response was not json: r;�message_codezservice-already-enabledzService `%s` already enabled.�servicezFailure enabling `z`: �messagezFailure of type `r"z(Failure enabling Ubuntu Pro service(s): )r rSr$r4�listr"r#rrNr:rrRrTr�logexcr&rc�loads�JSONDecodeError�getr6)�tokenrb�
attach_cmd�redacted_cmdrZ�errr(�cmd�
enable_stdoutrL�enable_resprU�error_servicesrgs              r)�
configure_prorv�s���
�~���	�F�C�	 ����
5�	
����
���
%����
0���L�!�!�	
�
����X�'9�5�A�
��X�u�-�
��c�r�?�h�Z�/�L��I�I�+�S�X�X�l�-C�D�'��	�	�*�1�a�&�L�A���
?�&�
H�C���9�9�S�$�Q��F�C��
�q���j�j��/��<!#�M����x��,�"���~��";�;��I�I�5�s�9�~�F�����S�!�	"��$&�� �	"�C��g�g�i�(�G��"��%�%�g�.�*�7�)�3�s�9�~�6F�G��)�#�f�+��c�#�i�.�9I�J���K�K��S�!�	"��6��i�i��'�
(�
�	
���o�%�%�'��!�f�n�n�U�H�-��/��u�5�����C����3��Q�&��	'���%�%���/�$�)�)�F�2C�C�
��	���������)�-��9�
��	���sI�+G�H5�.I.�H2�#A
H-�-H2�5I+�I&�&I+�.J�J�J�cloudc�@�tjd�ry	|jj�	|jjdg�y#t$rtjtd��wxYw#t$rtjtd��wxYw)z.Install ubuntu-advantage-tools if not present.rANzPackage update failedzubuntu-advantage-toolsz(Failed to install ubuntu-advantage-tools)	r�which�distro�update_package_sources�	Exceptionrrjr$�install_packages)rws r)�maybe_install_ua_toolsr~�s����z�z�%����
���+�+�-��
���%�%�'?�&@�A��	�����C�0�1�
���
�����C�C�D�
��s�A�A8�%A5�8%B�returnc�^�t|jdi�jdd��}|ryddlm}ddlm}	t
jtjd|��}|j
S#|$r9}tjd	|�tjt�Yd}~yd}~wwxYw)
NrrFr)�UserFacingError)�should_auto_attachz6Checking if the instance can be attached to Ubuntu Pro)�logfuncr(�funcz%Error during `should_auto_attach`: %s)r'rm�uaclient.api.exceptionsr��4uaclient.api.u.pro.attach.auto.should_auto_attach.v1r�r�log_timer$rNr4�ERROR_MSG_SHOULD_AUTO_ATTACH)rrr�r��result�exs      r)�_should_auto_attachr�
s�������
�B�'�+�+�,A�5�I�����8��	�����I�I�H�#�
���$�$�$��	���	�	�9�2�>����0�1����s�&A.�.B,�3/B'�'B,c��|jd�}|s"d}tj|�t|��|jd�}|r%tj	ddj|��t
||jd���y)Nrnz8`ubuntu_pro.token` required in non-Pro Ubuntu instances.�enable_betaz<Ignoring `ubuntu_pro.enable_beta` services in Pro attach: %srHrb)rnrb)rmr$r%r&rNr:rv)rrnr(r�s    r)�_attachr�)so���O�O�G�$�E��H���	�	�#���3����/�/�-�0�K���	�	�J��I�I�k�"�	
���k�o�o�h�&?�@r+c��ddlm}m}ddlm}m}|j
d�}|j
d�}|||��}	tjtjd|d|i�	�y#|$r|�|�tjd
�YyYy|$r5}d|j��}	tj|	�t|	�|�d}~wwxYw)Nr)�AlreadyAttachedErrorr�)�FullAutoAttachOptions�full_auto_attachrbr�)rbr�zAttaching to Ubuntu Pro�options)r�r(r��kwargsz�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�rmrr�r$rNr4r(r%r&)
rr�r�r�r�rbr�r�r�r(s
          r)�_auto_attachr�8s���N���_�_�X�
&�F��/�/�-�0�K�#����G�(��
�
��I�I�)�!��w�'�		
�� ���"�f�&8��K�K�6�
�'9��(�1�"�&�&��:���	�	�#���3��R�'��(�s�)A(�(C�
C�0B>�>C�name�cfg�argsc�F�d}ttj|��}|rXt|�dkDrt	ddj|�z��tjddj|��||d}d|vr |rtjd|d�|d}|�tjd|�yt|t�s8d	t|�j��}tj|�t	|��d
|vr"d}tj|�t	|��t|�t|j!d��t#|�tjd
�t%|�rt'|�y|j)�dhkst+|�yy)NrdzLUnable to configure Ubuntu Pro. Multiple deprecated config keys provided: %srHz^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"rBzETo discover more log info, please check /var/log/ubuntu-advantage.logr)ri�DEPRECATED_KEYS�intersection�lenr&r:r$r4rNr r!r"r#r%r~r\rmr*r�r��keysr�)r�r�rwr�r�
deprecatedr(s       r)�handler�^s����K��o�2�2�3�7�8�J���z�?�Q���%�'+�y�y��'<�=��
�	���
@��I�I�j�!�	
�
�*�Q�-�(���s����K�K�M��1�
�
��,�'�����	�	�K��	
�	�
��T�
*���[�!�*�*�+�
-�	�	�	�	�#���3����[� �
 �	�	�	�	�#���3����5�!��;�?�?�8�,�-��[�)��I�I�O���;�'��[�!��
�
�
�J�<�
/����0r+)N),�__doc__rc�loggingrO�typingrr�urllib.parser�	cloudinitrr�cloudinit.cloudr�cloudinit.configr	�cloudinit.config.schemar
�cloudinit.settingsr�PRO_URLrEr�rir�__annotations__�	getLoggerr#r$rr�r3r!r*r?r\rvr~r'r�r�r�rSr��r+r)�<module>r�s(��8���	��!� �!�#�.�+�
"���)�+=�>�?����z�� ,�~��_�0E�E�	��j���g����!����&���� �$� �6$
�t�$
�N)
�s�)
�Xa
�H
�%�
� %�T�%�d�%�8A��A�#(�d�#(�LB��B�6�B�%�B�t�B��Br+

Zerion Mini Shell 1.0