wo4hJddlZddlZddlZddlmZddlmZmZddlm Z ddl m Z ddl m Z mZmZddlZddlZddlmZddlmZdd lmZdd lmZmZmZmZmZd Zd Z ddZ! ddee ddffdZ"dde ee fdZ#eddZ$dZ% ddZ&dS)N)suppress) lru_cachewraps)chain)Path)OptionalTuple Generator) SimpleRpc)run_in_executor)ValidationError) AV_PID_PATHIM360_NON_RESIDENT_PID_PATHIM360_RESIDENT_PID_PATHantivirus_modeis_centos6_or_cloudlinux6ctjrtnt}|rt j}tt5t| }tr1tj |dj}||kotj|cdddS#1swxYwYdS)z/Check if non-resident agent instance is runningrNF)renabledrrexistsosgetpidr Exceptionint read_textrpsutilProcesschildrenpid pid_exists)rpc_process_pid_path current_pidrs T/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/rpc_tools/utils.pyrpc_is_runningr#s &-N 3N""$$Aikk i  A A*446677C(** <nS))2244Q7;+%@&*;C*@*@  A A A A A A A A A A A A A A A A 5sA:CC!$C!ctjrtStjrMt j}ttj}||kotj |SdS)z&Check if the agent instance is runningF) ConfigSOCKET_ACTIVATIONr#rrrrrrrr)r!rs r" is_runningr'+sl  %''=ikk )35566k!> ', 6D MM  K. . 6  Mr(cg}t|D]$}|t|%tt |SN)rKappendr=dictr)rAr) base_paths r"prepare_schemarRWsM F%e,,//  l9--.... v  r(c<tfd}|S)NcdKttjfdd{VS)NciSrN)argsfkwargssr"z.wrapper..csaa.@.@.@r()r asyncioget_event_loop)rWrYrXs``r"wrapperz*run_in_executor_decorator..wrapper`sW$  " $ $&@&@&@&@&@&@         r()r)rXr]s` r"run_in_executor_decoratorr^_s3 1XX    X Nr(cg}|D]w}|d|d|} } | r,|r*||| | N||| |xt|} t|} | dkr/| | kr)||| | |rt |iS)aP :param list affected: IPs that were changed during operation :param list of tuples || list of str not_affected: IPs & it's listnames that weren't changed during operation :param list all_list: list of all IPs that take place in operation :param str success_warning: msg if IP was changed :param str failure_warning: msg if IPs wasn't changed and it's absent in any other lists :param str in_another_list_warning: msg if IPs wasn't changed , however it present in another list :return list of st warnings: msg to be printed reclistnamerL)getrOformatlenr ) affected not_affected dest_listnameall_listsuccess_warningfailure_warningin_another_list_warningwarningsitemrecordra num_deleted total_nums r"generate_warningsrqis*HKK;](K(K  K/ K OO3::68LL M M M M OOO226=II J J J Jh--KH I1}}k11..{IFFGGG(h''' Ir()Nr)rN)'r.r[r contextlibr functoolsrr itertoolsrpathlibrtypingrr r r1r defence360agent.contracts.configr r%$defence360agent.model.simplificationr "defence360agent.rpc_tools.validater defence360agent.utilsrrrrrr#r'r=r,rKrRr^rqrVr(r"r{s  &&&&&&&&---------- @@@@@@@@@@@@>>>>>>$    ) ) ) )#tT4   HU4[1     1   "!&&&&&&r(