gJ9ddlZddlZddlZddlZddlZddlmZmZmZm Z ddl Z ddl m Z ddl mZmZmZddl mZmZddlmZddlmZdd lmZdd lmZmZmZdd lmZmZmZm Z m!Z!dd l"m#Z#m$Z$dd l%m&Z&ddl'm(Z(m)Z)m*Z*GddZ+dS)N)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_modulesrrlogselfs F/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwizard/wizard.py__init__zCloudlinuxWizard.__init__>s, "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+r1z;Got an error while running cloudlinux-wizard, message: '%s')r-contextdetailsr.Nz z#y00%%'''00224:;K//>!0..000:&S$&&&&44TZ=Q4RRRR%11%%''':%1,,......0000%11001BCCCC%11--////)) $(===1133> $009V9V9X9X0..000,,...  ' ' ) ) ) ) )!    HNNMsSVxx     ' '{CKXY (         +     ' 'U (          H  GS R R R  ' '@!,.. (          s,G#G;; K&AI$K& K& AK!!K&cJtjtSN)ospathisfilerr)r'r7z)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,) rTmknodrr$infoOSErrorIOErrorwarningrIr9)r&rPs r'rCz)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) sysrOappendrrr9 set_modulesrr` worker_pid)r&r/cmdconfigrds 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 r9r%s r'r6z!CloudlinuxWizard._validate_systemsD    #  ' '. (      $ #r)ctrfgd} t|}|jd|dS#t$r(}|jd||Yd}~dSd}~wwxYwgd} t|}|jd|dS#t$r(}|jd||Yd}~dSd}~wwxYw) z Prepare the enviroment before performing the installation. This function updates the package lists if run on Ubuntu, expires Yum cache when running on RHEL-based systems. )zapt-getz-qupdatezapt-get update output: %sz!Error during apt-get update: '%s')exc_infoN)yumz-qycleanz expire-cachez!yum clean expire-cache output: %sz)Error during yum clean expire-cache: '%s')r rr$rZr rHr&reoutrPs r'r:z*CloudlinuxWizard._prepare_for_installations+ ;; _---C W!#&& :C@@@@@( W W WBCRUVVVVVVVVV W:99C _!#&& BCHHHHH( _ _ _JCZ]^^^^^^^^^ _s/*A A2 A--A2:*B&& C0CCc&|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))ryunsuppored_by_cpN)r r9r#itemslistsetr)r& error_messages r'r?z$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')rr new_statez.Module '%s' installation successfully canceledzGUnable to cancel module '%s' installation, because it is in status '%s'N) r$rZrr|CANCELLABLE_MODULE_STATUSESset_module_statusr CANCELLEDr]r)r&rBrfr0s r'rAz,CloudlinuxWizard._cancel_module_installations(  H&QQQ " $ $ <--f55F999(( &,2H) NPVWWWW  3  ,FF;;;X  < < < < < < < < < < < < < < < < < z.3+OOF6T77OOOOOOr))rrstatusesvaluesallr&rfrs` r'rEz)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) rTrUrVr$rZrboolrr communicate)r& cagefsctl_binrecagefsctl_procis_test_environments r'rGz(CloudlinuxWizard.run_cagefs_force_update5s. w~~m,,  F. >  JCPPP',,"2:>>2B#C#CDD  )  & & ( ( ( ( ( ) )r)c|j tjS tj|jn#tj$rt |j}tfd|Drtj cYStd|Dr'td|Dstj cYStj cYSwxYwtjS)Nc3*K|] }|jvVdSrSrrs r'rz5CloudlinuxWizard._get_wizard_state..Vrr)c3JK|]}|tjtjfvVdSrS)rr~rrr0s r'rz5CloudlinuxWizard._get_wizard_state..ZsF|2L4JKKr)c34K|]}|tjfvVdSrS)r INSTALLINGrs r'rz5CloudlinuxWizard._get_wizard_state..]s-VV6&\%<$>>VVVVVVr))rdrIDLEpsutilProcess NoSuchProcessrrrrDONEanyr~r IN_PROGRESSrs` r'r{z"CloudlinuxWizard._get_wizard_stateEs   $$ $ ( N6, - - - -# ( ( ( FO224455HOOOOhOOOOO )#(((("* +VVXVVVVV +$****' ' ' '! ($''s0AC>C CCr_rc |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)timerjprintjsondumpsraexit)r-r.extrarJs r'r9z'CloudlinuxWizard._print_result_and_exitcs^$$)++>>u djd;;;<<< r)rS)r_r)__name__ __module__ __qualname____doc__rPENDINGr~rr INSTALLEDrrr(rQ staticmethodr7rCr<r6r:rsr@r?rArFrErGr{r9rWr)r'r r -sxKK # ! >>> EEEN00\0   FFFF,   ___,===JJJ:$<<<( L L L P P P))) (((<   \   r)r ),rrTrarrMtypingrrrrrclcommonrclcommon.utilsrr r r r clwizard.configr rfrrryrrr constantsrrrrr exceptionsrrparserrutilsrrrr rWr)r'rs 000000000000 '''''' <;;;;;;;(((((())))))IIIIIIIIIIKJJJJJJJ000000AAAAAAAAAAr)