%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/uaclient/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/uaclient/__pycache__/contract.cpython-312.pyc

�

�Hcf�{��v�ddlZddlZddlZddlmZddlmZmZmZm	Z	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZddlmZddlmZddlmZddlmZdd	lmZmZdd
l m!Z!ddl"m#Z#dZ$d
Z%d
Z&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.ddddd�Z/e
j`�Z1ejdejfe4��Z5edddg�Z6Gd�de!jn�Z8de9fd�Z:	d<d ed!ee;efd"ee;efd#e<d$e<d%dfd&�Z=		d=d ed'ee;efd(ee;efd#e<d$e<d%e
ee<ffd)�Z>d*ej~d%ej�fd+�ZAd,�ZBd ed%eefd-�ZCd ed.e;d%ee;effd/�ZDd ed%e<fd0�ZEd1ee;e;fd2ee;e;fd%eFfd3�ZG	d>d4ee;efd5e;d6e;de	e;d%eeFee;efff
d7�ZH		d?d'ee;efd8e	e;de	e;d%dfd9�ZId ed:ee;efd%ee6fd;�ZJy)@�N)�
namedtuple)�Any�Dict�List�Optional�Tuple)	�clouds�event_logger�
exceptions�http�messages�secret_manager�system�util�version)�_enabled_services)�_is_attached)�UAConfig)�ATTACH_FAIL_DATE_FORMAT)�attachment_data_file�machine_id_file)�
serviceclient)�get_user_or_root_log_file_pathz/v1/context/machines/tokenz3/v1/contracts/{contract}/context/machines/{machine}z
/v1/resourcesz3/v1/resources/{resource}/context/machines/{machine}z/v1/clouds/{cloud_type}/tokenz3/v1/contracts/{contract}/machine-activity/{machine}z/v1/contractz/v1/magic-attach����)�series_overrides�series�cloud�variant�EnableByDefaultService�namer!c��eZdZdZej
ejgd���	dd��Zde	e
effd�Zde
de	e
effd	�Z
ej
ejgd���d
ejfd��Z	dde
d
e
dee
de	e
effd�Zd�Zde
de	e
effd�Zde	e
effd�Zde
fd�Z	dde
de
dee
de	e
effd�Z	dde
de
dee
de	fd�Zd�Zy)�UAContractClient�contract_url)rrr)�retry_sleepsNc�<�|stj|j�}|j�}|j	ddj|�i�|j
�}|j�|d<||d�}t|�}|jt||��}|jdk(rtj��|jdk(rt|�|jdk7r0tjt|j|j �	��|j"}	t$j&j)|	j+d
d��|	j+dg�D]1}
t$j&j)|
j+d
d���3|	S)a}Requests machine attach to the provided machine_id.

        @param contract_token: Token string providing authentication to
            ContractBearer service endpoint.
        @param machine_id: Optional unique system machine id. When absent,
            contents of /etc/machine-id will be used.

        @return: Dict of the JSON response containing the machine-token.
        �
Authorization�	Bearer {}�lastAttachment��	machineId�activityInfo)�data�headers�i�����url�code�body�machineToken��resourceTokens�token)r�get_machine_id�cfgr0�update�format�_get_activity_info�	isoformat�_support_old_machine_info�request_url�API_V1_ADD_CONTRACT_MACHINEr5r�AttachInvalidTokenError�_raise_attach_forbidden_message�ContractAPIErrorr6�	json_dictr�secrets�
add_secret�get)�self�contract_token�
attachment_dt�
machine_idr0�
activity_infor/�backcompat_data�response�
response_jsonr:s           �3/usr/lib/python3/dist-packages/uaclient/contract.py�add_contract_machinez%UAContractClient.add_contract_machineDsl����.�.�t�x�x�8�J��,�,�.�������);�);�N�)K�L�M��/�/�1�
�*7�*A�*A�*C�
�&�'�'��G��3�D�9���#�#�'�o�w�$�
���=�=�C���4�4�6�6�
�]�]�c�
!�+�H�5��=�=�C���-�-�/��]�]��]�]��
�
!�*�*�
����)�)����n�b�1�	
�#�&�&�'7��<�	F�E��"�"�-�-�e�i�i���.D�E�	F����returnc��|j�}|jt|d|d|d|dd���}|jdk7r0t	j
t|j|j���|jS)	z=Requests list of entitlements available to this machine type.�architecturer�kernel�virt�rXrrYrZ)�query_paramsr2r3)r?rB�API_V1_AVAILABLE_RESOURCESr5rrFr6rG)rKrOrQs   rS�available_resourcesz$UAContractClient.available_resourcesos����/�/�1�
��#�#�&� -�n� =�'��1�'��1�%�f�-�	�$�
���=�=�C���-�-�.��]�]��]�]��
�
�!�!�!rUrLc�*�|j�}|jddj|�i�|jt|��}|j
dk7r0t
jt|j
|j���|jS)Nr)r*�r0r2r3)
r0r=r>rB�API_V1_GET_CONTRACT_USING_TOKENr5rrFr6rG)rKrLr0rQs    rS�get_contract_using_tokenz)UAContractClient.get_contract_using_token�s����,�,�.�������);�);�N�)K�L�M��#�#�+�W�$�
���=�=�C���-�-�3��]�]��]�]��
�
�!�!�!rU�instancec��|jtj|j��|j��}|j
dk7ry|jjdd�}|r+tj|�tj|���tjt|j
|j���|j}tjj!|jdd��|S)	z�Requests contract token for auto-attach images for Pro clouds.

        @param instance: AutoAttachCloudInstance for the cloud.

        @return: Dict of the JSON response containing the contract-token.
        )�
cloud_type)r/r2�messager8)�	error_msgr3�
contractToken)rB�,API_V1_GET_CONTRACT_TOKEN_FOR_CLOUD_INSTANCEr>re�identity_docr5rGrJ�LOG�debugr�InvalidProImagerFr6rrHrI)rKrcrQ�msgrRs     rS�%get_contract_token_for_cloud_instancez6UAContractClient.get_contract_token_for_cloud_instance�s����#�#�8�?�?�#�.�.�
@�
��&�&�	$�
���=�=�C���$�$�(�(��B�7�C���	�	�#�� �0�0�3�?�?��-�-�@��]�]��]�]��
�!�*�*�
����)�)����o�r�2�	
��rU�
machine_token�resourcerNc��|stj|j�}|j�}|j	ddj|�i�tj||��}|j||��}|jdk7r0tjt|j|j���|jjd�r|jd|jd<|j}|jdg�D]1}tjj!|jd	d
���3|S)a�Requests machine access context for a given resource

        @param machine_token: The authentication token needed to talk to
            this contract service endpoint.
        @param resource: Entitlement name.
        @param machine_id: Optional unique system machine id. When absent,
            contents of /etc/machine-id will be used.

        @return: Dict of the JSON response containing entitlement accessInfo.
        r)r*)rq�machiner`r2r3�expiresr9r:r8)rr;r<r0r=r>�"API_V1_GET_RESOURCE_MACHINE_ACCESSrBr5rrFr6rJrGrrHrI)	rKrprqrNr0r4rQrRr:s	         rS�get_resource_machine_accessz,UAContractClient.get_resource_machine_access�s#�� ��.�.�t�x�x�8�J��,�,�.�������);�);�M�)J�K�L�0�7�7��z�8�
���#�#�C��#�9���=�=�C���-�-�6��]�]��]�]��
�
�����	�*�,4�,<�,<�Y�,G�H���y�)� �*�*�
�"�&�&�'7��<�	F�E��"�"�-�-�e�i�i���.D�E�	F��rUc���|jjj}|jjj	d�}tj|j�}|j�}tj||��}|j�}|jddj|�i�|j|||��}|jdk7r,tj||j|j ���|j"rK|jj}|j"|d<|jjj%|�y	y	)
z�Report current activity token and enabled services.

        This will report to the contracts backend all the current
        enabled services in the system.
        r7��contractrsr)r*)r0r/r2r3r.N)r<�machine_token_file�contract_idrprJrr;r?�API_V1_UPDATE_ACTIVITY_TOKENr>r0r=rBr5rrFr6rG�write)rKr{rprN�request_datar4r0rQs        rS�update_activity_tokenz&UAContractClient.update_activity_token�s&���h�h�1�1�=�=�����.�.�2�2�>�B�
��*�*�4�8�8�4�
��.�.�0��*�1�1� �*�2�
���,�,�.�������);�);�M�)J�K�L��#�#�C��|�#�L���=�=�C���-�-��h�m�m�(�-�-��
���� �H�H�2�2�M�-5�,>�,>�M�.�)��H�H�'�'�-�-�m�<�rU�magic_tokenc�.�|j�}|jddj|�i�|jt|��}|j
dk(rt
j��|j
dk(rt
j��|j
dk7r0t
jt|j
|j���|j}gd�}|D]1}tjj|j|d	���3|S)
z�Request magic attach token info.

        When the magic token is registered, it will contain new fields
        that will allow us to know that the attach process can proceed
        r)r*r`r1�r2r3�r:�userCoderhr8)r0r=r>rB�"API_V1_GET_MAGIC_ATTACH_TOKEN_INFOr5r�MagicAttachTokenError�MagicAttachUnavailablerFr6rGrrHrIrJ)rKr�r0rQrR�
secret_fields�fields       rS�get_magic_attach_token_infoz,UAContractClient.get_magic_attach_token_info�s����,�,�.�������);�);�K�)H�I�J��#�#�.��$�
���=�=�C���2�2�4�4��=�=�C���3�3�5�5��=�=�C���-�-�6��]�]��]�]��
�
!�*�*�
�>�
�"�	L�E��"�"�-�-�m�.?�.?��r�.J�K�	L��rUc��|j�}|jt|d��}|jdk(rt	j
��|jdk7r0t	jt|j|j���|j}gd�}|D]1}tjj|j|d���3|S)z)Create a magic attach token for the user.�POST�r0�methodr�r2r3r�r8)
r0rB�API_V1_NEW_MAGIC_ATTACHr5rr�rFr6rGrrHrIrJ)rKr0rQrRr�r�s      rS�new_magic_attach_tokenz'UAContractClient.new_magic_attach_tokens����,�,�.���#�#�#���$�
���=�=�C���3�3�5�5��=�=�C���-�-�+��]�]��]�]��
�
!�*�*�
�>�
�"�	L�E��"�"�-�-�m�.?�.?��r�.J�K�	L��rUc���|j�}|jddj|�i�|jt|d��}|j
dk(rt
j��|j
dk(rt
j��|j
dk(rt
j��|j
dk7r0t
jt|j
|j�	��y
)z)Revoke a magic attach token for the user.r)r*�DELETEr�i�r1r�r2r3N)r0r=r>rB�API_V1_REVOKE_MAGIC_ATTACHr5r� MagicAttachTokenAlreadyActivatedr�r�rFr6)rKr�r0rQs    rS�revoke_magic_attach_tokenz*UAContractClient.revoke_magic_attach_token1s����,�,�.�������);�);�K�)H�I�J��#�#�&���$�
���=�=�C���=�=�?�?��=�=�C���2�2�4�4��=�=�C���3�3�5�5��=�=�C���-�-�.��]�]��]�]��
� rUr{c
�>�|stj|j�}|j�}|j	ddj|�i�tj||��}|j�}|j|d||d|d|d|dd	��
�}|jdk7r,tj||j|j���|jjd
�r|jd
|jd
<|jS)a|Get the updated machine token from the contract server.

        @param machine_token: The machine token needed to talk to
            this contract service endpoint.
        @param contract_id: Unique contract id provided by contract service
        @param machine_id: Optional unique system machine id. When absent,
            contents of /etc/machine-id will be used.
        r)r*rx�GETrXrrYrZr[)r�r0r\r2r3rt)rr;r<r0r=r>�API_V1_GET_CONTRACT_MACHINEr?rBr5rrFr6rJrG)rKrpr{rNr0r4rOrQs        rS�get_contract_machinez%UAContractClient.get_contract_machineHs����.�.�t�x�x�8�J��,�,�.�������);�);�M�)J�K�L�)�0�0� ��1�
���/�/�1�
��#�#���� -�n� =�'��1�'��1�%�f�-�	�	$�

���=�=�C���-�-��h�m�m�(�-�-��
������	�*�,4�,<�,<�Y�,G�H���y�)��!�!�!rUc�8�|stj|j�}|j�}|j	ddj|�i�||j
�d�}t|�}tj||��}|j||d|��}|jdk7r,tj||j|j���|jjd	�r|jd	|jd	<|jS)
a�Request machine token refresh from contract server.

        @param machine_token: The machine token needed to talk to
            this contract service endpoint.
        @param contract_id: Unique contract id provided by contract service.
        @param machine_id: Optional unique system machine id. When absent,
            contents of /etc/machine-id will be used.

        @return: Dict of the JSON response containing refreshed machine-token
        r)r*r,rxr�)r0r�r/r2r3rt)rr;r<r0r=r>r?rA�API_V1_UPDATE_CONTRACT_MACHINErBr5rrFr6rJrG)	rKrpr{rNr0r/rPr4rQs	         rS�update_contract_machinez(UAContractClient.update_contract_machiness�� ��.�.�t�x�x�8�J��,�,�.�������);�);�M�)J�K�L�#� �3�3�5�
��4�D�9��,�3�3� �*�4�
���#�#����o�$�
���=�=�C���-�-��h�m�m�(�-�-��
������	�*�,4�,<�,<�Y�,G�H���y�)��!�!�!rUc��tj�jtj�jtj�j
tj�tj�tj�tj�d�}t|j�jr�t|j�j}t!j"�}|jj$j&xstj(|j�|jj$j*|D�cgc]}|j,��c}|D�cic]%}|j.r|j,|j0��'c}|r|j2j5�ndd�}ni}i|�|�Scc}wcc}w)z9Return a dict of activity info data for contract requests)�distributionrYrrX�desktoprZ�
clientVersionN)�
activityID�
activityToken�	resources�resourceVariantsr+)r�get_release_infor��get_kernel_info�
uname_releaser�
get_dpkg_arch�
is_desktop�
get_virt_typer�get_versionrr<�is_attachedr�enabled_servicesr�readrz�activity_idr;�activity_tokenr#�variant_enabled�variant_name�attached_atr@)rK�machine_infor��attachment_data�servicerOs      rSr?z#UAContractClient._get_activity_info�sv��#�3�3�5�B�B��,�,�.�<�<��-�-�/�6�6�"�0�0�2��(�(�*��(�(�*�$�0�0�2�
������!�-�-�0����:�K�K��2�7�7�9�O�"�h�h�9�9�E�E�3��(�(����2�!%���!<�!<�!K�!K�:J�K�w�g�l�l�K�$4�%���.�.��L�L�'�"6�"6�6�%�'�$�/�/�9�9�;���M�"�M�
��
��
�	
��L��%s�G
�5*G
�N)�__name__�
__module__�__qualname__�cfg_url_base_attrr�retry�socket�timeoutrTr�strrr^rbr	�AutoAttachCloudInstancerorrvrr�r�r�r�r�r?�rUrSr%r%As���&���T�Z�Z����Y�7�8<�(�8�(�T"�T�#�s�(�^�"�("�s�"�t�C��H�~�"��T�Z�Z����Y�7��!�9�9��8��H%)�	$��$��$��S�M�	$�

�c�3�h��$�L$=�L�s��t�C��H�~��8��S�#�X���.�S��6%)�	)"��)"��)"��S�M�	)"�

�c�3�h��)"�^%)�	&"��&"��&"��S�M�	&"�

�&"�P&
rUr%�request_bodyc	��|jdi�}|jd�||jd�|jd�|jd�|jd�dtj�jd�d	�S)
a?
    Transforms a request_body that has the new activity_info into a body that
    includes both old and new forms of machineInfo/activityInfo

    This is necessary because there may be old ua-airgapped contract
    servers deployed that we need to support.
    This function is used for attach and refresh calls.
    r.r-rXr�rYr�Linux)r�rYr�type�release)r-r.rX�os)rJrr�r�)r�rOs  rSrArA�s���!�$�$�^�R�8�M�"�%�%�k�2�%�%�)�)�.�9�)�-�-�n�=�#�'�'��1�#�'�'��1���.�.�0�8�8�
�	
�
rUr<�past_entitlements�new_entitlements�allow_enablerrVc��ddlm}d}g}g}||�D]I}		||	}
g}	t||j	|	i�|
||��\}}|s�2|s�5t
j
|	��Kt
j|�t|�dkDretj t#||�D�	�cgc]9\}	}|	t$j&j)t+|�t-��	�f��;c}}	�
��|r4tj.|D�	cgc]}	|	t$j0f��c}	�
��y#t$rY��wxYw#tj$rJ}
tj|
�d}|j|	�tjd|	|
�Yd}
~
��sd}
~
wt$rY}
tj|
�|j|
�|j|	�tjd|	|
�Yd}
~
���d}
~
wwxYwcc}}	wcc}	w)a�Iterate over all entitlements in new_entitlement and apply any delta
    found according to past_entitlements.

    :param cfg: UAConfig instance
    :param past_entitlements: dict containing the last valid information
        regarding service entitlements.
    :param new_entitlements: dict containing the current information regarding
        service entitlements.
    :param allow_enable: Boolean set True if allowed to perform the enable
        operation. When False, a message will be logged to inform the user
        about the recommended enabled service.
    :param series_overrides: Boolean set True if series overrides should be
        applied to the new_access dict.
    r)�entitlements_enable_orderF)r<�orig_access�
new_accessr�rTz+Failed to process contract delta for %s: %rNz5Unexpected error processing contract delta for %s: %r)rg�log_path)�failed_services)�uaclient.entitlementsr��KeyError�process_entitlement_deltarJ�event�service_processedr�UbuntuProErrorrk�	exception�append�error�	Exception�services_failed�len�AttachFailureUnknownError�zipr
�UNEXPECTED_ERRORr>r�r�AttachFailureDefaultServices�!E_ATTACH_FAILURE_DEFAULT_SERVICES)r<r�r�r�rr��delta_error�unexpected_errorsr�r#�new_entitlement�deltas�service_enabled�er�s               rS�process_entitlements_deltar��s��*@��K����O�)�#�.�%.��	�.�t�4�O���	.�&?��-�1�1�$��;�*�)�!1�'�#�F�O�8�6��'�'��-�K%.�L
���/�*�
����!��2�2�(+�?�<M�'N�	�$�D�)�
��-�-�4�4�"%�i�.�!?�!A�5���	�
�	
�
��5�5�,����x�A�A�B��
�	
�
��c�	��	���(�(�	��M�M�!���K��"�"�4�(��I�I�=���
�
��
�	��M�M�!���$�$�Q�'��"�"�4�(��M�M�G���
�
��		��"	��sA�D �#D0�">G0
�>G6� 	D-�,D-�0G-�?F�G-�AG(�(G-r�r�c�<�ddlm}|rt|�tj||�}d}|r�|jdi�jd�}|s!|jdi�jd�}|st
j||���|jdi�jdi�jd	d
�}		||||	��}
|
||��}|j|||��}||fS#tj$r}tjd|�|�d
}~wwxYw)a,Process a entitlement access dictionary deltas if they exist.

    :param cfg: UAConfig instance
    :param orig_access: Dict with original entitlement access details before
        contract refresh deltas
    :param new_access: Dict with updated entitlement access details after
        contract refresh
    :param allow_enable: Boolean set True if allowed to perform the enable
        operation. When False, a message will be logged to inform the user
        about the recommended enabled service.
    :param series_overrides: Boolean set True if series overrides should be
        applied to the new_access dict.

    :raise UbuntuProError: on failure to process deltas.
    :return: A tuple containing a dict of processed deltas and a
             boolean indicating if the service was fully processed
    r��entitlement_factoryF�entitlementr�)�orig�new�entitlements�obligations�use_selectorr8�r<r#r!z3Skipping entitlement deltas for "%s". No such classN)r<�
assume_yes�r�)r�r��apply_contract_overridesr�get_dict_deltasrJr� InvalidContractDeltasServiceType�EntitlementNotFoundErrorrkrl�process_contract_deltas)
r<r�r�r�rr�r��retr#r!�ent_cls�excr�s
             rSr�r�9s&��0:�� ��,�
�
!�
!�+�z�
:�F�
�C�
����}�b�1�5�5�f�=����:�:�m�R�0�4�4�V�<�D���=�=� �j��
�

�N�N�>�2�.�
�S���
#�
�S���
$�	�
	�)�c��g�N�G��#�,�?���1�1���l�2�
���3�;����2�2�	��I�I�E�t�
��I��		�s�>C+�+D�>D�DrQc���|jjd�}|r�|d}|d}|dk(rB|djt�}t	j
|||djd����|dk(rB|djt�}t	j|||djd��	��|d
k(rt	j|���t	j��)N�info�
contractId�reasonzno-longer-effective�timez%m-%d-%Y)r{�date�contract_expiry_dateznot-effective-yet)r{r�contract_effective_dateznever-effective)r{)	rGrJ�strftimerr�AttachForbiddenExpired�AttachForbiddenNotYet�AttachForbiddenNever�AttachExpiredToken)rQr�r{rrs     rSrErEus������!�!�&�)�D���<�(���h����*�*���<�(�(�)@�A�D��3�3�'��%)�&�\�%:�%:�:�%F�	�
��*�
*���<�(�(�)@�A�D��2�2�'��(,�V��(=�(=�j�(I�	�
��(�
(��1�1�k�J�J�
�
'�
'�
)�)rUc���|jj}|j}|d}|ddd}t|�}|j	||��}|jj|�tjj�|jdi�jdt
j|��}tj
|�t|||jjd��y	)
aRequest contract refresh from ua-contracts service.

    :param cfg: Instance of UAConfig for this machine.

    :raise UbuntuProError: on failure to update contract or error processing
        contract deltas
    :raise ConnectivityError: On failure during a connection
    r7�machineTokenInfo�contractInfo�id)rpr{r-Fr�N)rzr�rpr%r�r}rr;�cache_clearrJrr�)r<�orig_entitlements�
orig_tokenrpr{�contract_client�resprNs        rS�refreshr�s����.�.�;�;���"�"�J��~�.�M��/�0��@��F�K�&�s�+�O��2�2�#��3��D���� � ��&�
���%�%�'����,�b�1�5�5��V�*�*�3�/��J����*�%�������+�+��	rUc�\�t|�}|j�}|jdg�S)zDQuery available resources from the contract server for this machine.r�)r%r^rJ)r<�clientr�s   rS�get_available_resourcesr�s+��
�c�
"�F��*�*�,�I��=�=��b�)�)rUr:c�:�t|�}|j|�S)z/Query contract information for a specific token)r%rb)r<r:rs   rS�get_contract_informationr�s��
�c�
"�F��*�*�5�1�1rUc��|j}|jj}|jdd�}|jdi�jdi�jdd�}|syt	|�}|j||�}|jdi�jdi�jdd�}|r|n|jj}|jj|k7ry|jj|�}	t|	j��D]/\}
}tj|j|
i�|�}|s�/yy)	Nr7r8rrr
F�effectiveToT)rprzr�rJr%r��contract_expiry_datetime�get_entitlements_from_token�sorted�itemsrr�)
r<rrrpr{rr�resp_expiry�
new_expiry�curr_entitlementsr#r�r�s
             rS�is_contract_changedr"�sO���"�"�J��.�.�;�;���N�N�>�2�6�M����)�2�.�	��^�R�	 �	��T�4���
��&�s�+�O��/�/�
�{�K�D����#�R�(�	��^�R�	 �	��]�D�	!���	�
�
#�
#�
<�
<��
���6�6�*�D���.�.�J�J����"(�(9�(?�(?�(A�!B����o��%�%��!�!�$��+�_�
�����rU�override_selector�selector_valuesc�~�d}|j�D]'\}}||f|j�vry|t|z
}�)|S)Nr)r�OVERRIDE_SELECTOR_WEIGHTS)r#r$�override_weight�selector�values     rS�_get_override_weightr*�sV���O�,�2�2�4�?���%��e��O�$9�$9�$;�;���4�X�>�>��?�
�rUr��series_namerec� �i}||d�}|r||d<|jdi�j|i�}|r||td<tj|j	dg��}|D]%}t|jd�|�}	|	s�!|||	<�'|S)N)rr r!rr�	overridesr()�popr&�copy�deepcopyrJr*)
r�r+rer!r-r$r�general_overrides�override�weights
          rS�_select_overridesr4�s����I�!,�z�B�O��%,��	�"�"���x��4�8�8��b�I����	�+�,>�?�@��
�
�k�o�o�k�2�&F�G��%�)��%��L�L��$�o�
��� (�I�f��)��rUrc��ddlm}tt|t�d|vg�stdj
|���|�tj�jn|}|�\}}|jdi�}t||||�}t|j��D][\}	}
|
j�D]C\}}|dj|�}
t|
t�r|
j|��<||d|<�E�]y)a�Apply series-specific overrides to an entitlement dict.

    This function mutates orig_access dict by applying any series-overrides to
    the top-level keys under 'entitlement'. The series-overrides are sparse
    and intended to supplement existing top-level dict values. So, sub-keys
    under the top-level directives, obligations and affordance sub-key values
    will be preserved if unspecified in series-overrides.

    To more clearly indicate that orig_access in memory has already had
    the overrides applied, the 'series' key is also removed from the
    orig_access dict.

    :param orig_access: Dict with original entitlement access details
    r)�get_cloud_typer�z?Expected entitlement access dict. Missing "entitlement" key: {}N)�uaclient.clouds.identityr6�all�
isinstance�dict�RuntimeErrorr>rr�rrJr4rrr=)r�rr!r6r+re�_�orig_entitlementr-�_weight�overrides_to_apply�keyr)�currents              rSr�r�s
��&8��
�;��-�}��/K�L�M��
��&��%�
�	
�-3�N����!�(�(���#�$�M�J��"���}�b�9��!��+�z�7��I�(.�i�o�o�.?�'@�	8�#��#�,�2�2�4�	8�J�C��!�-�0�4�4�S�9�G��'�4�(����u�%�38��M�*�3�/�	8�	8rUr�c���ddlm}g}|j�D]�\}}|jdi�jdd�}	||||��}||�}|jdi�jdi�}	|jd�}
|j
|	|
�s��|j�\}}|s��|jt||�	����|S#tj
$rY��wxYw)
Nrr�r�r�r8r�r��
resourceToken)r#r!)
r�r�rrJrr��_should_enable_by_default�
can_enabler�r")
r<r�r��enable_by_default_services�ent_name�	ent_valuer!r��entr�rCrEr<s
             rS�get_enabled_by_default_servicesrJAs���:�!#��+�1�1�3����)��-�-�
�r�2�6�6�~�r�J��	�)��h���G��c�l���m�m�M�2�6�:�:�=�"�M��!�
�
�o�6�
��(�(��m�D��N�N�,�M�J���*�1�1�*�%� '���#�0&�%��#�2�2�	��	�s�C�C'�&C')T)FTr�)NN)Kr/�loggingr��collectionsr�typingrrrrr�uaclientr	r
rrr
rrrr�-uaclient.api.u.pro.status.enabled_services.v1r�(uaclient.api.u.pro.status.is_attached.v1r�uaclient.configr�uaclient.defaultsr�uaclient.files.state_filesrr�
uaclient.httpr�uaclient.logrrCr�r�r]rurir|rar�r�r�r&�get_event_loggerr��	getLogger�replace_top_level_logger_namer�rkr"�UAServiceClientr%r:rAr��boolr�r��HTTPResponse�NamedMessagerErrrr"�intr*r4r�rJr�rUrS�<module>r^s1����
�"�3�3�
�
�
�L�A�$�5�L�'�7�;��9��:��-��9�#�0O�,�9��#1��%7�"�,��/����
��	��	&��%�%�'���g���:��:�:�8�D�E��$��v�y�1���
@
�}�4�4�@
�F�D��@"�W
�	�W
��C��H�~�W
��3��8�n�W
��	W
�
�W
�
�
W
�|�!�9�	�9��c�3�h��9��S�#�X��9��	9�
�9��4��:��
9�x*����*�
���*�:�D*��*�d�4�j�*�2�(�2�3�2�4��S��>�2�#�X�#�$�#�L	��C��H�~�	�8<�S�#�X��	��	� "�	��c�3�h��������c�]�	�

�#�t�C��H�~�
���>!�!�.8��c�3�h��.8��S�M�.8��c�]�.8�
�	.8�b&�	�&�!%�c�3�h��&�	�
 �!�&rU

Zerion Mini Shell 1.0