o .&aC@sddlZddlZddlZddlmZddlmZddlmZm Z e e Z dZ dZGdddeZd d Zd d ZGd dde ZdS)N) check_call)ignore_user_entered_signals)ServiceOperationCLIOperationCaller)z#SessionManagerPlugin is not found. z3Please refer to SessionManager Documentation here: z3http://docs.aws.amazon.com/console/systems-manager/z session-manager-plugin-not-foundz/The task provided in the request was not found.cseZdZfddZZS)ECSExecuteCommandcstt|}d|j_|S)N)superrcreate_help_command_operation_model output_shape)self help_command __class__J/usr/lib/python3/dist-packages/awscli/customizations/ecs/executecommand.pyr&sz%ECSExecuteCommand.create_help_command)__name__ __module__ __qualname__r __classcell__rrr rr$src Csf||gd}|jdi|}|d}|stt|ddd}|D]}||dkr0|dSq"dS)N)clustertasksrr containersname runtimeIdr)describe_tasks ValueErrorTASK_NOT_FOUND) clientcontainer_nametask_id cluster_namedescribe_tasks_paramsdescribe_tasks_responserresponse containerrrrget_container_runtime_id-s  r%cCsT|ddd}|ddd}|d}t||||}d|||}d|i}|S)N clusterArn/taskArn containerNamez ecs:{}_{}_{}Target)splitr%format)r#rr rrcontainer_runtime_idtargetssm_request_paramsrrrbuild_ssm_request_paramaters=sr1c@seZdZddZdS)ExecuteCommandCallerc Cs z^tdg|jj||j|j|jd}|jd i|}|jj}|jj dur)|jj nd}|jj} t ||} t tdt |d|d|t | | gWdWdS1sWwYWdSty} z| jtjkrztjddd tdtWYd} ~ dSd} ~ ww) Nzsession-manager-plugin) region_name endpoint_urlverifysession StartSessionrz#SessionManagerPlugin is not presentT)exc_infor)r_session create_clientregionr4 verify_sslexecute_commandmetar3profiler1rjsondumpsOSErrorerrnoENOENTloggerdebugrjoin ERROR_MESSAGE) r service_nameoperation_name parametersparsed_globalsrr#r3 profile_namer4r0exrrrinvokeMsJ        zExecuteCommandCaller.invokeN)rrrrPrrrrr2Ls r2)loggingrArD subprocessr awscli.compatrawscli.clidriverrr getLoggerrrFrIrrr%r1r2rrrrs