/
var
/
opt
/
nydus
/
ops
/
customer_local_ops
/
control_panel
/
__pycache__
/
up file
home
� <�j,] � � � d dl mZmZ d dlZd dlZd dlZd dlZd dlZd dlZd dl m Z d dlmZ d dl mZmZmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z" d dl#m$Z$ d dl%m&Z&m'Z'm(Z( d d l)m*Z* ejV e,� Z-d Z.dZ/ G d� d ee$� Z0 G d� dee0� Z1 G d� dee1� Z2 G d� dee1� Z3 G d� dee1� Z4 G d� dee1� Z5 G d� dee1� Z6 G d� dee0� Z7 G d� dee7� Z8 G d� dee7� Z9 G d � d!ee7� Z: G d"� d#ee7� Z; G d$� d%ee7� Z< G d&� d'ee7� Z= G d(� d)e e7� Z> G d*� d+e!e7� Z? G d,� d-e"e7� Z@y).� )�Dict�AnyN)�IntEnum)� FileInput)�OpType�ResourceType�NydusResult)� AlmaLinux8� AlmaLinux9�AlmaLinux10�Linux�CentOS�CentOS6�CentOS7�Debian�Debian8�Debian10�Debian11�Debian12�Debian13� Ubuntu1604� Ubuntu2004� Ubuntu2204� Ubuntu2404)�OSPlesk)� runCommand�run_uapi_command�run_multiple_uapi_commands)�Retryz/opt/psaz/usr/local/psac � � e Zd ZdZej ZeegZ dZ g d�Zdefd�Z dd�deded eeef defd �Zdd�deded ededed eeef defd�Zdd�ded eeef defd�Zdd�ded eeef defd�Zdd�ded eeef defd�Zdd�deded eeef defd�Zdd�deded eeef defd�Z ddeded eeef defd�Zdd�deded eeef defd�Zy)� LinuxPleskz� Plesk Customer Local Ops for the Linux OS. All function names should contain 'plesk' so as not to override the OS ops N)zWThe Plesk administrator password cannot be changed until the server cloning is finishedzJNo connection could be made because the target machine actively refused itzCould not resolve host�returnc � � | j �| j S | j D ]K }t j j |� s�#t j |� || _ | j c S t d� �)zdFind the installation directory for plesk :return: full path to plesk installation zplesk path could not be found)� plesk_dir�PLESK_INSTALL_LOCATIONS�os�path�isdir�LOG�info�RuntimeError)�self�locs �]/opt/nydus/tmp/pip-target-hb7welcc/lib/python/customer_local_ops/control_panel/linux_plesk.py� get_plesk_dirzLinuxPlesk.get_plesk_dir- sb � � �>�>�%��>�>�!��/�/�C��w�w�}�}�S�!����� �!$����~�~�%� 0� �:�;�;� ��intermediate_result�activation_key�argsr2 c �� � t j dt | � � d}d}| j |� }t j d|� t |d|gdd� \ }}} | j ||| ||�� S )a Run license utility on local vm with activation key :param activation_key: Key value passed back from license plesk op on hfs executor :param intermediate_result: Dict containing metadata for retries :return: tuple with success, error data zinstall plesk license on '%s'� license_plesk�licensezfull command: %sz --installzset Plesk Licenser1 )r) r* �str�get_path_pleskr �_result_handler) r, r3 r2 r4 �op_name�command�full_command� exit_code�outs�errss r. r6 zLinuxPlesk.license_plesk@ s} � � ���0�#�d�)�<�!�����*�*�7�3�����#�\�2� 0�,��^�1\�1D�o�!W�� �4���#�#�I�t�T�7�Xk�#�l�lr0 �vm_ip�vm_resource� plesk_user� plesk_passc �� � t j d� | j }t j | j |� � }| j t |� | } | j d� } dj | � }t |d|d�� \ }} }|dk7 rd}nd }d dj | j d� � � fd| | j j | |||�� fd|fddj | j d� �� fdg}| | j r|ddj |�� fdgz }| | j r|dgz }t ||d|�� \ }} }| j || |||�� S )a� Enable plesk on local vm :param vm_ip: External IP address of the VM :param vm_resource: The resource name for the third-party hosting provider :param plesk_user: User name to be used on Plesk instance :param plesk_pass: Password to be used on Plesk instance :param intermediate_result: Dict containing metadata for retries :raises DecryptError: if there is a problem with decrypting the password :return: tuple with success, error data zenable plesk� init_confz{} --check-configuredzCheck Plesk configuredT�� use_shellr z--initz--updatezset minimum password strengthz.{server_pref} -u -min_password_strength medium�server_pref)rI zsetup Plesk)� init_conf_cmd�init_conf_setup_flagrC �passwordzcheck configz set Poweruserz{set_poweruser_cmd} --on� poweruser)�set_poweruser_cmd)zset auto updatesz}plesk db "INSERT INTO misc(param, val) VALUES('automaticSystemPackageUpdates', 'true') ON DUPLICATE KEY UPDATE val = 'true';"zhide internal ipzTsed -i'' 's/blacklist=".*"/blacklist="{vm_ip}"/' /usr/local/psa/admin/conf/panel.ini)rA )z reread ipszplesk bin ipmanage --reread)zdisable session ip checkzwplesk db "INSERT INTO misc(param,val) VALUES('disable_check_session_ip', 'true') ON DUPLICATE KEY UPDATE val = 'true';")rH �omit_stringr1 )r) r* �OP_ENABLE_PLESK�shlex�quote�decrypt� PLESK_OPS_RESOURCE_ATTRIBUTE_MAPr r9 �formatr � SETUP_CMD�RUN_HIDE_INTERNAL_IP�RUN_DISABLE_SESSION_IP_CHECKr r: )r, rA rB rC rD r2 r4 r; �password_arg�ops_maprJ �check_configured_cmdr>