File: //lib/python3.6/site-packages/awscli/customizations/codedeploy/__pycache__/install.cpython-36.pyc
3
�T_m � @ sT d dl Z d dlZd dlZd dlZd dlmZ d dlmZmZm Z G dd� de�Z
dS )� N)�BasicCommand)�validate_region�validate_s3_location�validate_instancec @ sd e Zd ZdZdZddddd�dd d
dd�d
dd
dd�gZdd� Zdd� Zdd� Zdd� Z dd� Z
dS )�Install�installzMConfigures and installs the AWS CodeDeploy Agent on the on-premises instance.zconfig-filez--config-file <path>TzBRequired. The path to the on-premises instance configuration file.)�nameZsynopsisZrequired� help_textzoverride-config�
store_trueFz@Optional. Overrides the on-premises instance configuration file.)r �action�defaultr zagent-installerz--agent-installer <s3-location>z2Optional. The AWS CodeDeploy Agent installer file.c C s� |}| j |_t||� t|� |jj� | j|� | j|� y| j|� | j |� W n> t
k
r� } z"tjj
� tjjdj|�� W Y d d }~X nX d S )Nz�ERROR
{0}
Install the AWS CodeDeploy Agent on the on-premises instance by following the instructions in "Configure Existing On-Premises Instances by Using AWS CodeDeploy" in the AWS CodeDeploy User Guide.
)Z_sessionZsessionr r �systemZvalidate_administrator�_validate_override_config�_validate_agent_installer�_create_config�_install_agent� Exception�sys�stdout�flush�stderr�write�format)�selfZparsed_argsZparsed_globals�params�e� r �/usr/lib/python3.6/install.py� _run_main= s
zInstall._run_mainc C s$ t jj|jj�r |j r td��d S )Nz�The on-premises instance configuration file already exists. Specify --override-config to update the existing on-premises instance configuration file.)�os�path�isfiler
�CONFIG_PATHZoverride_config�RuntimeError)r r r r r r T s z!Install._validate_override_configc C sh t |d� d|kr dj|j�|_d|krDdj|jj�|_|jj|_n |jjd�d }|j|d � |_d S )NZagent_installer�bucketzaws-codedeploy-{0}�keyz
latest/{0}�/� ) r r Zregionr$ r
Z INSTALLERr% Z installer�rfind)r r �startr r r r ] s
z!Install._validate_agent_installerc C s� t jjd� ytj|jj� W n2 tk
rP } z|jtj kr@|�W Y d d }~X nX |j
|jjkrrtj
|j
|jj� t jjd� d S )Nz8Creating the on-premises instance configuration file... zDONE
)r r r r �makedirsr
Z
CONFIG_DIR�OSError�errnoZEEXISTZconfig_filer"