HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/awscli/customizations/codedeploy/__pycache__/systems.cpython-36.pyc
3

�T_��@snddlZddlZddlZdZGdd�d�ZGdd�de�ZGdd�de�ZGd	d
�d
e�ZGdd�de�ZdS)
�Nzcodedeploy.onpremises.ymlc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�SystemzgOnly Ubuntu Server, Red Hat Enterprise Linux Server and Windows Server operating systems are supported.cCs |j|_|jjd|jd�|_dS)N�s3)Zregion_name)�sessionZ
create_client�regionr)�self�params�r�/usr/lib/python3.6/systems.py�__init__szSystem.__init__cCstd��dS)N�validate_administrator)�NotImplementedError)rrrr	r"szSystem.validate_administratorcCstd��dS)N�install)r)rrrrr	r
%szSystem.installcCstd��dS)N�	uninstall)r)rrrrr	r(szSystem.uninstallN)�__name__�
__module__�__qualname__ZUNSUPPORTED_SYSTEM_MSGr
rr
rrrrr	rs
rc@sDeZdZdZdZdjee�ZdZdd�Zdd�Z	d	d
�Z
dd�Zd
S)�Windowsz C:\ProgramData\Amazon\CodeDeployzconf.onpremises.ymlz{0}\{1}zcodedeploy-agent.msicCstjjj�std��dS)Nz.You must run this command as an Administrator.)�ctypesZwindllZshell32Z
IsUserAnAdmin�RuntimeError)rrrr	r2szWindows.validate_administratorc
Csd|kr|j|_tjdddddgtjtjd�}|j�\}}d}|jd	kr^||kr^td
j|���|j	j
|j|jd�}t
|jd��}|j|d
j��WdQRXtjdj|j�dddgdd�tjdddddg�tjdddddgtjtjd�}|j�\}}d|k�r
td��dS)N�	installerzpowershell.exez-CommandzStop-Servicez-Name�codedeployagent)�stdout�stderrz;Cannot find any service with service name 'codedeployagent'rz,Failed to stop the AWS CodeDeploy Agent:
{0})�Bucket�Key�wb�Bodyz.\{0}z/quietz/lz".\codedeploy-agent-install-log.txtT)�shellzRestart-ServicezGet-ServiceZRunningz:The AWS CodeDeploy Agent did not start after installation.)r�	INSTALLER�
subprocess�Popen�PIPE�communicate�
returncoder�formatr�
get_object�bucket�key�open�write�read�
check_call)rr�process�output�error�	not_found�response�frrr	r
8sF




zWindows.installcCs\tjdddddgtjtjd�}|j�\}}d}|jdkrB|j�n||krXtd	j|���dS)
Nzpowershell.exez-CommandzStop-Servicez-Namer)rrz;Cannot find any service with service name 'codedeployagent'rz,Failed to stop the AWS CodeDeploy Agent:
{0})rr r!r"r#�
_remove_agentrr$)rrr,r-r.r/rrr	ros


zWindows.uninstallcCsJtjdddddddgtjtjd�}|j�\}}|jd	krFtd
j|���dS)NZwmic�product�wherezname="CodeDeploy Host Agent"Zcallrz/nointeractive)rrrz1Failed to uninstall the AWS CodeDeploy Agent:
{0})rr r!r"r#rr$)rr,r-r.rrr	r2�s

zWindows._remove_agentN)rrr�
CONFIG_DIR�CONFIG_FILEr$�CONFIG_PATHrrr
rr2rrrr	r,s7rc@sTeZdZdZeZdjee�ZdZdd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dd�ZdS)�Linuxz/etc/codedeploy-agent/confz{0}/{1}r
cCstj�dkrtd��dS)Nrz"You must run this command as sudo.)�os�geteuidr)rrrr	r�szLinux.validate_administratorcCs�d|kr|j|_|j|�|j|�|jj|j|jd�}t|jd��}|j	|dj
��WdQRXtjdddj
|j�g�|jj�}tjj�}|j|d<|j|d	<|j|d
<|jdk	r�|j|d<tjdj
|j�dg|d
�dS)Nr)rrrr�chmodz+xz./{0}Z
AWS_REGIONZAWS_ACCESS_KEY_IDZAWS_SECRET_ACCESS_KEYZAWS_SESSION_TOKEN�auto)�env)rr�_update_system�_stop_agentrr%r&r'r(r)r*rr+r$rZget_credentialsr9�environ�copyrZ
access_keyZ
secret_key�token)rrr0r1ZcredentialsZenvironmentrrr	r
�s&








z
Linux.installcCs"|j|�}|jdkr|j|�dS)Nr)r?r#r2)rrr,rrr	r�s

zLinux.uninstallcCstd��dS)NZ
preinstall)r)rrrrr	r>�szLinux._update_systemcCstd��dS)NZremove_agent)r)rrrrr	r2�szLinux._remove_agentcCsLtjdddgtjtjd�}|j�\}}|jdkrH|j|krHtdj|���|S)NZservicezcodedeploy-agent�stop)rrrz,Failed to stop the AWS CodeDeploy Agent:
{0})rr r!r"r#�
not_found_msgrr$)rrr,r-r.rrr	r?�s
zLinux._stop_agentN)rrrr5�DEFAULT_CONFIG_FILEr6r$r7rrr
rr>r2r?rrrr	r8�sr8c@s$eZdZdd�Zdd�Zdd�ZdS)�UbuntucCs&tjdddg�tjddddg�dS)Nzapt-getz-y�updater
zruby2.0)rr+)rrrrr	r>�szUbuntu._update_systemcCstjdddg�dS)NZdpkgz-rzcodedeploy-agent)rr+)rrrrr	r2�szUbuntu._remove_agentcCsd|_tj||�S)Nz&codedeploy-agent: unrecognized service)rDr8r?)rrrrr	r?�szUbuntu._stop_agentN)rrrr>r2r?rrrr	rF�srFc@s$eZdZdd�Zdd�Zdd�ZdS)�RHELcCstjddddg�dS)N�yumz-yr
Zruby)rr+)rrrrr	r>�szRHEL._update_systemcCstjddddg�dS)NrIz-yZerasezcodedeploy-agent)rr+)rrrrr	r2�szRHEL._remove_agentcCsd|_tj||�S)Nz<Redirecting to /bin/systemctl stop  codedeploy-agent.service)rDr8r?)rrrrr	r?�szRHEL._stop_agentN)rrrr>r2r?rrrr	rH�srH)	rr9rrErrr8rFrHrrrr	�<module>sk>