AlkantarClanX12

Your IP : 3.129.69.134


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/clpackages/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/clpackages/__pycache__/packages.cpython-311.pyc

�

".gM7����ddlZddlZddlmZddlmZmZmZmZddl	m
Z
mZddlm
Z
mZddlmZddlmZddlmZmZmZdd	lmZdd
lmZmZmZddlmZGd
�d��ZdS)�N)�Feature)�admin_packages�is_admin�is_panel_feature_supported�resellers_packages)�
MySQLGovernor�MySQLGovException)�print_dictionary�replace_params)�CloudlinuxLicenseLib)�LvectlException)�ClQuotaException�
ClQuotaLib�QuotaDisabledException)�
LveCtlPackage)�DEFAULT_PACKAGE�is_active_reseller_limits�lve�)�parse_cloudlinux_packages_optsc�N�eZdZdZgd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
dd�Zdd
�ZdS)�CloudlinuxPackagesz4
    Class for run cloudlinux-packages commands
    )
�speed�nproc�pmem�vmem�
maxEntryProcs�io�iops�inodes�	mysql-cpu�mysql-ioc��d|_i|_t��|_t	t
j��rt��nd|_t	t
j	��rt��nd|_dS)NF)�_is_json�_optsr�_clquota_pack_librr�LVEr�_lvectl_pack_lib�GOVERNORr�_mysql_governor)�selfs �py/clpackages/packages.py�__init__zCloudlinuxPackages.__init__ sc����
���
�!+�����3M�g�k�3Z�3Z� d�
����`d���2L�W�M]�2^�2^�h�}����dh�����c��t��}|���sd|_|�ddi��Sd|v|_|�|��|_|j�d��r*tj��s|�ddi��|jdr|�	��S|�
��S)z$
        Run command action
        T�resultzCloudlinux license isn't validz--json�--for-resellerzLerror: reseller limits are not supported, can not use --for-reseller option.�set)r�get_license_statusr$�_error_and_exit�_parse_argsr%�getr�reseller_limit_supported�_set_run�_get_run)r+�argv�licences   r,�runzCloudlinuxPackages.run's���'�(�(���)�)�+�+�	V� �D�M��'�'��3S�(T�U�U�U� �D�(��
��%�%�d�+�+��
��:�>�>�*�+�+�	�C�4P�4R�4R�	�� � ��h�"�
�
�
��:�e��	#��=�=�?�?�"��}�}���r.c�~�t||j��\}}|s"|�t|����|S)z%
        Parse CLI arguments
        )rr$r4r)r+r:�status�datas    r,r5zCloudlinuxPackages._parse_args;sB��6�d�D�M�J�J�����	7�� � ���!5�!5�6�6�6��r.c�
���|j}t|dt��r|d�d��nd�t	�fd�|jD����}i}|jd}d}|jd�2|jd����d��}g}ttj
��rb	|j�|||jd��}n9#t$r,}|�|j|jd	���Yd}~nd}~wwxYw|d
�r�|j���sd|d<i|d
<d|d
d<�nc|j���sd|d<i|d
<d|d
d<�n3	|j�|��}nc#t($r.}i}i|d
<t|��|d
d<d|d<Yd}~n0d}~wt*$r }i}|j|d<|j|d<Yd}~nd}~wwxYwttj
��r0|D],}	|	d}
|
|vr|�|
��|	dd
<�-nkd�t/�����D��d�t3��D��zddiz�|�fd�|���D��z
}d|d<ttj
��r;g}|D]6}	d|	ddi|	dd<|�|	d���7ttj���r|j���r�d|d<	|jd�|jd|vr}|j�|jd��}|D]U}	|	d}|t>krd}||vr:||d|	ddd<||d |	dd d<�VnI#t@$r<}|ddkr&d|d<d
|vri|d
<t|��|d
d<Yd}~nd}~wwxYw|D]�}	|	d}
|ds|
d=|
dd=|
dikr|
d=|d!s|
d!=|d"sd"|
vr|
d"=|d#s|
d$=|d%sd%|
vr|
d%=|d s|
d d=|
d ikr|
d =|d&sd&|
vr|
d&=|d's"d|
dvr|
dd=|
dikr|
d=|d(s&d |
vr"d|
d vr|
d d=|
d ikr|
d =��tC|��|d)<||d<|�"|��d*S)+z#
        Run 'get' command
        z--limits�,Nc3�*�K�|]
}|�p|�vfV��dS�N�)�.0�k�lks  �r,�	<genexpr>z.CloudlinuxPackages._get_run.<locals>.<genexpr>Ls3�����M�M�a�A�2�v�0��b��1�M�M�M�M�M�Mr.�
--provider�	--package�unicode-escapez--human-readable-numbers�r0�contextr �error�quota�errorsz'LVE Manager/quota package not installedz#Quotas not activated on this system�warningrM�package�limitsc�$�i|]
\}}|D]}||���SrDrD)rE�reseller�packagesrRs    r,�
<dictcomp>z/CloudlinuxPackages._get_run.<locals>.<dictcomp>~sC��,�,�,�.�H�h�^f�,�,�SZ� ��,�,�,�,r.c��i|]}|d��S)�rootrD)rErRs  r,rWz/CloudlinuxPackages._get_run.<locals>.<dictcomp>�s'�����,3�����r.�default�c�j��g|]/\}}|dkr|nt��|d��dd|id���0S)rZr[Fr )rR�provider�
enabledLimitsrS)rr6)rE�package_name�
inodes_limits�package_to_resellerss   �r,�
<listcomp>z/CloudlinuxPackages._get_run.<locals>.<listcomp>�sg���&�&�&�8�L�-�8D�y�7P�7P�|�|�Ve�(<�(@�(@��r�(R�(R�-2�'/��&?�	��&�&�&r.�disabled�mySqlGov�allr�cpu�enabled�mysqlrrrr�eprrr!r"�itemsr)#r%�
isinstance�str�split�dict�_LIMITS_KEYS�encode�decoderrr'r(�get_reseller_package_limitsr
r4�messagerMr&�is_clquota_present�is_clquota_activatedrr�poprrjr�appendr)r*�is_governor_present�get_package_limitsrr	�len�_print_data)r+�o�limits_keysr0�
reseller_namer_�
packages_data�e�quotas_dict�package_data�package_name_quota�
package_names�package_limits_governor�limits_dictrGras              @@r,r9zCloudlinuxPackages._get_runEs%����

�J��)3�A�j�M�3�)G�)G�
Q�Q�z�]�
 �
 ��
%�
%�
%�T���M�M�M�M�4�;L�M�M�M�M�M�����
�<�0�
����:�k�"�.��:�k�2�9�9�;�;�B�B�CS�T�T�L�$&�
�%�g�k�2�2�	R�
R� $� 5� Q� Q�R_�P\�PT�PZ�[u�Pv�!x�!x�
�
��#�
R�
R�
R��$�$��	�a�i�%P�%P�Q�Q�Q�Q�Q�Q�Q�Q�����
R�����x� �/	��)�<�<�>�>�.
�")��w��#%��x� �,U��x� ��)�)��+�@�@�B�B�)
�")��w��#%��x� �,Q��x� ��)�)�
2�"&�"8�"T�"T�Ua�"b�"b�K�K��-�.�.�.�"$�K�')�F�8�$�03�A���F�8�$�W�-�&-�F�7�O�O�O�O�O�O�����'�2�2�2�"$�K�()�	�F�9�%�()�	�F�9�%�%�%�%�%�%�����2����.�g�k�:�:��(5�c�c��-9�)�-D�*�-��<�<�?J���Oa�?b�?b�L��2�8�<��c�,�,�2D�2F�2F�2L�2L�2N�2N�,�,�,���7E�7G�7G����,�
#�B��,(�(�"�&�&�&�&�<G�;L�;L�;N�;N�&�&�&��M�(��z��%�g�k�2�2�	>��M� -�
>�
>��16��X�8N�w�8W�0X��X�&�u�-��$�$�\�)�%<�=�=�=�=�%�g�&6�7�7�	>�D�<P�<d�<d�<f�<f�	>�!*�F�:��
>��:�k�*�2�d�j��6M�Q^�6^�6^�.2�.B�.U�.U�VZ�V`�al�Vm�.n�.n�+�(5�p�p��'3�I�'>��'�?�:�:�+4�L�'�+B�B�B�E\�]i�Ej�kp�Eq�L��2�5�9�'�B�D[�\h�Di�jn�Do�L��2�4�8��A����$�
>�
>�
>��*�%��2�2�)0�F�:�&��v�-�-�+-��x�(�7:�1�v�v��x�(��4����������
>����*�%	*�%	*�L�&�x�0�K��w�'�
+���(���&�u�-��u�%��+�+�#�E�*��v�&�
(���'��v�&�
(�6�[�+@�+@���'���/�
&���%��w�'�
)�G�{�,B�,B���(��t�$�
*���%�e�,��t�$��*�*�#�D�)��v�&�
(�6�[�+@�+@���'��{�+�
+��;�u�;M�0M�0M���&�w�/��u�%��+�+�#�E�*��z�*�
*�t�{�/B�/B�w�R]�^b�Rc�Gc�Gc���%�g�.��t�$��*�*�#�D�)���m�,�,��w��)��y������ � � ��qsU�'C6�6
D,�"D'�'D,�F4�4
H�>$G'�'
H�4H�H�BO7�7
P=�2P8�8P=c
��|jd}|j�d��}|�8t|��s)t|��s|�dd|id���|jd����d��}i}|j}ttj	���rt|d	|d
|d|d|d
|d|dg��r�|d	|d
|d|d|d|d
|dd�}|�|||��d�|���D��}	|j
�|||��n9#t$r,}|�|j|jd���Yd}~nd}~wwxYw|dr\	|j�||d��n9#t&$r,}|�|j|jd���Yd}~nd}~wwxYwttj��r�|d�|d�}|j���rd	|j�||d|d��n:#t0f$r,}|�|j|jd���Yd}~nd}~wwxYw|�|��dS)z#
        Run 'set' command
        rIr1Nz5error: reseller limits for %(reseller)s are disabled.rUrLrJrKz--speedz--pmemz--vmemz--maxEntryProcsz--nprocz--ioz--iops)rrrrrrrc��i|]
\}}|�||��SrCrD)rE�key�values   r,rWz/CloudlinuxPackages._set_run.<locals>.<dictcomp>�s#��W�W�W�Z�S�%�U�EV�c�5�EV�EV�EVr.z--inodesz--mysql-cpuz
--mysql-ior)r%r6rrr4rprqrrr'�any�%_check_hoster_permissions_for_packagerjr(�set_reseller_package_limitsr
rsrMr&rr)r*rx�set_package_limitsr	r{)r+r~�for_resellerr_r0r|rSr�s        r,r8zCloudlinuxPackages._set_run�s`���
�<�0�
��z�~�~�&6�7�7���#�H�\�,B�,B�#�(��6�6�$�� � �Q�&�
�6�"�"�
�
�
��z�+�.�5�5�7�7�>�>�?O�P�P�����J��%�g�k�2�2�	R�s�
�y�\�1�X�;��(��Q�7H�5I�1�Y�<�YZ�[a�Yb�de�fn�do�p�8
�8
�	R� !��|�Q�x�[��&�	���k�A�>O�<P� ��|�Q�x�[�B�B�F�

�6�6�|�\�S`�a�a�a�X�W�6�<�<�>�>�W�W�W�F�
R��%�A�A�-�Q]�_e�f�f�f�f��"�
R�
R�
R��$�$��	�a�i�%P�%P�Q�Q�Q�Q�Q�Q�Q�Q�����
R����
�Z�=�	R�
R��&�B�B�<�QR�S]�Q^�_�_�_�_��#�
R�
R�
R��$�$��	�a�i�%P�%P�Q�Q�Q�Q�Q�Q�Q�Q�����
R����&�g�&6�7�7�	R��}�%�1�Q�|�_�5P��(�<�<�>�>�6Q�
R��$�7�7��a�
�FV�XY�Zf�Xg�h�h�h�h��%�(�
R�
R�
R��$�$��	�a�i�%P�%P�Q�Q�Q�Q�Q�Q�Q�Q�����
R����	
���� � � ��qsH�!E>�>
F4�"F/�/F4�!G"�"
H�,"H�H�(J�J>�"J9�9J>c�h�|�-t|��r d}|�|d|id���dSdSdS)NzMerror: hoster cannot manage package limits for reseller's package %(package)srRrL)rr4)r+r�r_r~rss     r,r�z8CloudlinuxPackages._check_hoster_permissions_for_packagesh����$=�m�$L�$L��=�G�� � �G�.7��-F�"H�"H�
I�
I�
I�
I�
I� ���r.F�successc��t|t��r)|�|tj��d���t	||jp|��dS)z�
        Output data wrapper
        :param: `dict` data - data for output to stdout
        :param: `bool` force_json - always output json format
        )r0�	timestampN)rkrn�update�timer
r$)r+r?�
force_jsonr0s    r,r{zCloudlinuxPackages._print_datasT���d�D�!�!�	F��K�K�6��	���D�D�E�E�E���t�}�:�
�;�;�;�;�;r.rc�~�|jr9|�dtj��i��t|d��nh	t	t|d��|�di��z��n-#t$r }t	d|�d|�d���Yd}~nd}~wwxYwtj	|��dS)	z�
        Print error and exit
        :param dict message: Dictionary with keys "result" as string and optional "context" as dict
        r�Tr0rMzError: z [�]N)
r$r�r�r
�printrlr6�KeyError�sys�exit)r+rs�
error_coder�s    r,r4z"CloudlinuxPackages._error_and_exit$s���
�=�	1��N�N�K�����5�6�6�6��W�d�+�+�+�+�
1��c�'�(�+�,�,�w�{�{�9�b�/I�/I�I�J�J�J�J���
1�
1�
1��/��/�/�W�/�/�/�0�0�0�0�0�0�0�0�����
1�����������s�9A<�<
B&�B!�!B&N)Fr�)r)
�__name__�
__module__�__qualname__�__doc__ror-r<r5r9r8r�r{r4rDr.r,rrs���������x�w�w�L�i�i�i����(���T�T�T�l5�5�5�nI�I�I�<�<�<�<�
�
�
�
�
�
r.r) r�r��clcommon.constr�clcommon.cpapirrrr�clcommon.librr	�	cli_utilsr
r�	cllicenser�cllimitsr
�cllimits.clquota_librrr�
clpackagesr�	lvectllibrrr�cl_packages_arg_parserrrDr.r,�<module>r�s?���
�
�
�����"�"�"�"�"�"�c�c�c�c�c�c�c�c�c�c�c�c�9�9�9�9�9�9�9�9�6�6�6�6�6�6�6�6�*�*�*�*�*�*�$�$�$�$�$�$�U�U�U�U�U�U�U�U�U�U�$�$�$�$�$�$�E�E�E�E�E�E�E�E�E�E�A�A�A�A�A�A�W�W�W�W�W�W�W�W�W�Wr.