|9e8>ddlmZddlmZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z ddl Z ddlmZddlmZmZmZddlmZddlmZdd lmZd d lmZd d lmZd d lmZmZmZd dl m!Z!m"Z"m#Z#m$Z$m%Z%d dl&m'Z'm(Z(d dl)m*Z*d dl+m,Z,m-Z-m.Z.Gdde/Z0dS))print_function)absolute_importN)AnyOptionalDictNoReturn)FormattedException) run_commandExternalProgramFailedget_cl_version)get_package_db_errors) is_ubuntu) NoSuchModule)acquire_config_access)Config)run_installation ALL_MODULESget_supported_modules) WizardStatus ModuleStatusCRASH_LOG_PATHFILE_MARKER_PATH MAIN_LOG_PATH)CancelModuleExceptionInstallationFailedException)parse_cloudlinux_wizard_opts)is_background_process_runningrun_background setup_loggerceZdZdZejejejgZej ejej gZ dZ dZ edZdZddZdZd Zd Zd Zd Zd ZdZdZdZdZeddZdS)CloudlinuxWizardzAMain class for working with Wizard that exposes high level logic.cnd|_t|_tdt|_dS)Nz wizard.main)_optsr_supported_modulesr rlogselfs F/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwizard/wizard.py__init__zCloudlinuxWizard.__init__Cs, "7"9"9 }==ct||_ |jjdkr||r#|jjs|dd||jjrtn| |jj n|jjdkrJ||jj r| nq|n\|jjdkr ||jjn,|jjdkr|nt$|jjd vr|s$|jjdkr<|s(|||d S#t,$r[}|jd t3|||j|j|jd Yd }~d Sd }~wt:$r|d dYd St<$r[}|jdt3||dtAj!Yd }~d Sd }~wwxYw)zv CL Wizard main function :param argv: command line arguments for wizard :return: None installzInstallation already finishedrresult exit_code)optionsstatuscancelfinish)r-r3z;Got an error while running cloudlinux-wizard, message: '%s')r/contextdetailsr0Nz!0..000:&S$&&&&44TZ=Q4RRRR%11%%''':%1,,......0000%11001BCCCC%11--////))J(,AAA5577B $009V9V9X9X0..000,,...  ' ' ) ) ) ) )!    HNNMsSVxx     ' '{CKXY (         +     ' 'U (          H  GS R R R  ' '@!,.. (          s,G#G;; K&AI$K& K& AK!!K&cJtjtSN)ospathisfilerr+r)r9z)CloudlinuxWizard.is_installation_finishedsw~~.///r+c* tjt|jddS#t t f$rJ}|jdt|| ddYd}~dSd}~wwxYw)NzWizard execution completez:Wizard 'finish' command called more than once, error: '%s'z-Wizard 'finish' command called more than oncerr.) rVmknodrr&infoOSErrorIOErrorwarningrKr;)r(rRs r)rEz)CloudlinuxWizard.create_completion_markers  H% & & & HMM5 6 6 6 6 6!    H  LcRUhh     ' 'FRS (           s37B?B  BNctjdd}|dt5}t r|dd|||t|j}||_ dddn #1swxYwY|d|dS)Nz --no-asynczMUnable to start a new installation because a background task is still workingrr.success)r/pid) sysrQappendrrr; set_modulesrrb worker_pid)r(r1cmdconfigrfs r)r>z,CloudlinuxWizard.run_background_installations hqqqk <   " $ $ +-.. ++9, """7+++(,,0J *F  + + + + + + + + + + + + + + + ##9*#EEEEEsABB #B cRt|ddSdS)z; Check that wizard supports current system NzCould not identify the CloudLinux version. Restart your system. If you have the same problem again - contact CloudLinux support.r/)r r;r's r)r8z!CloudlinuxWizard._validate_systemsD    #  ' '. (      $ #r+ctrdgd} t|}|jd|dS#t$r&}|jd|Yd}~dSd}~wwxYwdS)z Prepare the enviroment before performing the installation. In its current form, this function only updates the package lists if run on Ubuntu, does nothing on other OS variants. )zapt-getz-qupdatezapt-get update output: %sz!Error during apt-get update: '%s'N)rr r&r\r rJr(rgoutrRs r)r<z*CloudlinuxWizard._prepare_for_installations ;; I---C I!#&& :C@@@@@( I I IBCHHHHHHHHH I  I Is*A A0 A++A0c&|j|jS)zGet path to module log file)r%LOG_FILE)r( module_names r)_get_module_log_pathz%CloudlinuxWizard._get_module_log_paths&{3<z8CloudlinuxWizard._get_initial_status..s@( S !5!5!7!7r+)rxunsuppored_by_cpN)r r;r%itemslistsetr)r( error_messages r)rAz$CloudlinuxWizard._get_initial_statuss .//    ' '} ' = = = = =  ' ',0,C,I,I,K,K"&c+&6&6T=T9U9U&U!V!V (     r+c|jd|t5}||}||jvr=||t j|jd|n,|jd||t|| ddddS#1swxYwYdS)z@Remove module from queue or print the error if it's not possiblez0Trying to cancel the installation of module '%s')rq new_statez.Module '%s' installation successfully canceledzGUnable to cancel module '%s' installation, because it is in status '%s'N) r&r\rr{CANCELLABLE_MODULE_STATUSESset_module_statusr CANCELLEDr_r)r(rDrhr2s r)rCz,CloudlinuxWizard._cancel_module_installations(  H&QQQ " $ $ <--f55F999(( &,2H) NPVWWWW  3  ,FF;;;X  < < < < < < < < < < < < < < < < < z.1+OOF6T77OOOOOOr+)rrstatusesvaluesallr(rhrs` r)rGz)CloudlinuxWizard.is_all_modules_installed's# $ $ 6FO224455H 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6OOOOhOOOOOOs'AA Ac2d}tj|sdS|ddg}|jd|t |}t tjd}|r| dSdS)z= Runs cagefsctl --force-update in background z/usr/sbin/cagefsctlNz--force-updatez --wait-lockz2Starting cagefs force-update in the background: %sCL_TEST_SYSTEM) rVrWrXr&r\rboolrr communicate)r( cagefsctl_binrgcagefsctl_procis_test_environments r)rIz(CloudlinuxWizard.run_cagefs_force_update3s. w~~m,,  F. >  JCPPP',,"2:>>2B#C#CDD  )  & & ( ( ( ( ( ) )r+c|j tjS tj|jtjS#tj$rt|j }tfd|Drtj cYStd|Dr'td|Dstj cYStjcYSwxYw)Nc3*K|] }|jvVdSrUrrs r)rz5CloudlinuxWizard._get_wizard_state..Trr+c3JK|]}|tjtjfvVdSrU)rr}rrr2s r)rz5CloudlinuxWizard._get_wizard_state..XsF|2L4JKKr+c34K|]}|tjfvVdSrU)r INSTALLINGrs r)rz5CloudlinuxWizard._get_wizard_state..[s-VV6&\%<$>>VVVVVVr+)rfrIDLEpsutilProcess IN_PROGRESS NoSuchProcessrrrrDONEanyr}rrs` r)rzz"CloudlinuxWizard._get_wizard_stateCs   $$ $ , N6, - - -& + +%# ( ( ( FO224455HOOOOhOOOOO )#(((("* +VVXVVVVV +$****' ' ' '! (s;AC(>C( C('C(rarc |tjd}||ttj|ddt j|dS)z Print data in default format for web and exit :param dict extra: extra fields for the response, usually we expect 'context' here )r/ timestampT)indent sort_keysN)timerlprintjsondumpsrcexit)r/r0extrarLs r)r;z'CloudlinuxWizard._print_result_and_exitas^$$)++>>u djd;;;<<< r+rU)rar)__name__ __module__ __qualname____doc__rPENDINGr}rr INSTALLEDr~rr*rS staticmethodr9rEr>r8r<rrrBrArCrHrGrIrzr;rYr+r)r"r"2sxKK # ! >>> FFFP00\0   FFFF,    I I I===JJJ:$<<<( L L L P P P))) ,,,<   \   r+r")1 __future__rrrrVrcrrOtypingrrrrrclcommonr clcommon.utilsr r r r clcommon.lib.cleditionrclwizard.configrrhrrrxrrr constantsrrrrr exceptionsrrparserrutilsrrr objectr"rYr+r)rs)&%%%%%&&&&&& 000000000000 '''''' 100000,,,,,,(((((())))))IIIIIIIIIIKJJJJJJJ000000zzzzzvzzzzzr+