https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/boto/manage/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/boto/manage/__pycache__/server.cpython-310.pyc
o

ckF[gU�@s�dZddlZddlmZddlmZmZddlm	Z	ddl
mZmZm
Z
mZddlmZddlmZdd	lmZddlZddlZdd
lmZddlmZddlmZmZgd
�ZGdd�de�Z Gdd�de�Z!Gdd�de	�Z"dS)z)
High-level abstraction of an EC2 server
�N)�IObject)�BotoConfigPath�Config)�Model)�StringProperty�IntegerProperty�BooleanProperty�CalculatedProperty)�propget)�Zone)�KeyPair)�closing)�EC2ResponseError)�six�StringIO)�m1.smallzm1.largez	m1.xlarge�	c1.mediumz	c1.xlargez
m2.2xlargez
m2.4xlargec@s<eZdZddd�Zdd�Zdd�Zdd	�Z	
	ddd
�Zd
S)�Bundler�rootcCs*ddlm}||_||_|||d�|_dS)Nr��	SSHClient)�uname)�boto.manage.cmdshellr�serverr�
ssh_client)�selfrrr�r�4/usr/lib/python3/dist-packages/boto/manage/server.py�__init__-szBundler.__init__cCsrtd�|j��tj�|�\}}d||_|j�||j�tj�|�\}}d||_|j�||j�td�dS)Nz5	copying cert and pk over to /mnt directory on serverz/mnt/%s�...complete!)	�printr�	open_sftp�os�path�split�remote_key_file�put_file�remote_cert_file)r�key_file�	cert_filer#�namerrr�	copy_x5093s


zBundler.copy_x509cCs�d}|jdkr	d}|d7}|d|j|jf7}|d|jjj7}|d|7}|d|7}|d	7}|jjd
ks<|jjdkrB|d7}|S|d
7}|S)N�r�sudo zec2-bundle-vol z-c %s -k %s z-u %s z-p %s z-s %d z-d /mnt rrz-r i386z	-r x86_64)rr'r%r�_reservation�owner_id�
instance_type)r�prefix�size�ssh_key�commandrrr�bundle_image>s
�zBundler.bundle_imagecCsZd}|jdkr	d}|d7}|d|7}|d|7}|d|jjj7}|d|jjj7}|S)	Nr,rr-zec2-upload-bundle z-m /mnt/%s.manifest.xml z-b %s z-a %s z-s %s )rr�ec2�aws_access_key_id�aws_secret_access_key)r�bucketr1r3r4rrr�
upload_bundleNs
zBundler.upload_bundleNTc	Cs`t�}	|s
|	�d�}|s|	�d�}|s|	�d�}|s|	�d�}|s&|	�d�}|s-|j��}|�||�|s8t�}|�dt	�|�d�|rK|�d�|�|�
|||��|�d	�|�|�|||��|�d	�|�d
t	�|�d�|��}
t
d�t
|
�|j�|
�}t
d
|d�t
d
|d�t
d�t
d�|jjj|d||fd�|_|jS)NzName of S3 bucketzPrefix for AMI filezPath to RSA private key filezPath to RSA public cert filezSize (in MB) of bundled imagezsudo mv %s /mnt/boto.cfg; z0mv ~/.ssh/authorized_keys /mnt/authorized_keys; zhistory -c; z; zsudo mv /mnt/boto.cfg %s; z.mv /mnt/authorized_keys ~/.ssh/authorized_keysz3running the following command on the remote server:z	%sr�rzregistering image...z%s/%s.manifest.xml)r*�image_location)r�
get_string�get_filename�get_intr�get_ssh_key_filer+r�writerr5r:�getvaluer r�runr6�register_image�image_id)rr9r1r(r)r2r3�fp�
clear_history�iobjectr4�trrr�bundleYsH










zBundler.bundle�r)NNNNNNNT)�__name__�
__module__�__qualname__rr+r5r:rJrrrrr+s
�rc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�CommandLineGettercCs8g}|j��D]}|j�d�dkr|�|j|f�q|S)N�pyamir)r6�get_all_images�location�find�append)r�my_amis�amirrr�get_ami_list�s�zCommandLineGetter.get_ami_listcCsb|�dd�}t|t�rtj�|�}||d<|s(|j�d�}tj|tjj	d�|d<|d�
�|_dS)N�region�region_name)�choices)�get�
isinstance�
basestring�botor6�
get_region�cls�
find_propertyr
�regions�connect)r�paramsrX�proprrrr_�s
zCommandLineGetter.get_regioncC�.|�dd�s|j�d�}t�|�|d<dSdS)Nr*�r[r`rar
�rrdrerrr�get_name���zCommandLineGetter.get_namecCrf)N�descriptionrgrhrrr�get_description�rjz!CommandLineGetter.get_descriptioncCs0|�dd�stddtd�}t�|�|d<dSdS)Nr0�
Instance Type�r*�verbose_namerZ)r[r�
InstanceTypesr
rhrrr�get_instance_type�s��z#CommandLineGetter.get_instance_typecCs.|�dd�stddd�}t�|�|d<dSdS)N�quantityzNumber of Instances�r*ro)r[rr
rhrrr�get_quantity�rjzCommandLineGetter.get_quantitycCs4|�dd�stdd|jjd�}t�|�|d<dSdS)N�zonezEC2 Availability Zonern)r[rr6�
get_all_zonesr
rhrrr�get_zone�s��zCommandLineGetter.get_zonecCs|d}|s<|�dd�}|stddd�}t�|�}z|j�|g�}t|�dkr-d}|d|d<Wn	ty7Ynw|rdSdS)NFrV�AMIrsr;Tr)r[rr
r6rQ�lenr)rrd�validrVre�rsrrr�
get_ami_id�s 
���zCommandLineGetter.get_ami_idcCsl|�dd�}t|t�r |j��}|D]
}|j|kr|}||d<q|s4tdd|jjd�}t�|�|d<dSdS)N�groupzEC2 Security Grouprn)r[r\r]r6�get_all_security_groupsr*rr
)rrdr}�
group_list�grerrr�	get_group�s


���zCommandLineGetter.get_groupcCsr|�dd�}t|t�r"|j��}|D]}|j|kr!|j}|j|d<q|s7tdd|jjd�}t�|�j|d<dSdS)N�keypairzEC2 KeyPairrn)r[r\r]r6�get_all_key_pairsr*rr
)rrdr��key_list�krerrr�get_key�s



���zCommandLineGetter.get_keycCsr||_|�|�|d��|_|�|�|�|�|�|�|�|�|�|�|�	|�|�
|�|�|�dS)NrX)r`r_rcr6rirlrqrwrtr|r�r�)rr`rdrrrr[�s







zCommandLineGetter.getN)rLrMrNrWr_rirlrqrtrwr|r�r�r[rrrrrO�s


rOcseZdZeddd�Zedd�Zedd�Zedd�Zedd�Ze	d	d
d�Z
ededd
�Z
ededd
�Zededd
�Zededd
�Zededd
�Zededd
�Zededd
�Zededd
�Zededd
�Zededd
�Zededd
�ZgZgZedd��ZedUdd��ZedVdd��Zed d!��Z dW�fd"d#�	Z!d$d%�Z"d&d'�Z#d(d)�Z$d*d+�Z%d,d-�Z&d.d/�Z'd0d1�Z(d2d3�Z)d4d5�Z*d6d7�Z+d8d9�Z,�fd:d;�Z-�fd<d=�Z.d>d?�Z/d@dA�Z0dBdC�Z1dDdE�Z2dFdG�Z3dHdI�Z4dJdK�Z5dLdM�Z6dXdOdP�Z7dYdQdR�Z8dSdT�Z9�Z:S)Z�ServerT�Name)�uniquero�Description)rozEC2 Region NamezEC2 Instance IDzEC2 Elastic IP AddresszIs This Server ProductionF)ro�defaultzAMI ID)ro�calculated_type�
use_methodzAvailability Zone NamezPublic DNS NamezPrivate DNS NamezSecurity GroupszPrimary Security Group NamezKey NamermzCurrent StatuszServer Launch TimezConsole OutputcCsj|�d�s
|�d�|�dd|�|�dd|�|�d�s"|�d�|�ddd�|�dd|jjj�dS)N�Credentialsr7r8�	DB_Server�db_type�SimpleDB�db_name)�has_section�add_section�set�_manager�domainr*)r`�cfgr7r8rrr�add_credentialss



zServer.add_credentialsNc	Ks|rt|d�}|�d�r |�d�D]}||vr|�d|�||<qt�}|�||�|�d�}|��}|�||j|j�|�d�}	|�d�}
|�d�}|�d�}|dkr[|�	d	d
|j
�t�}
|�|
�t
|t�rk|j
}t
|
t�rs|
j
}
|	jd|�dd�|
|g|�d
�||
��d�}g}d}|�d�}|j}|dur�|��dkr�|d}td�t�d�|��dkr�t�d�|��dks�|�|�td|�|D]<}|�}||_|dkr�|�d�dnt|�|_
|�d�|_|j
|_|j|_|r�|dkr�||_|� �|�!|�|d7}q�|S)aq
        Create a new instance based on the specified configuration file or the specified
        configuration and the passed in parameters.

        If the config_file argument is not None, the configuration is read from there.
        Otherwise, the cfg argument is used.

        The config file may include other config files with a #import reference. The included
        config files must reside in the same directory as the specified file.

        The logical_volume argument, if supplied, will be used to get the current physical
        volume ID and use that as an override of the value specified in the config file. This
        may be useful for debugging purposes when you want to debug with a production config
        file but a test Volume.

        The dictionary argument may be used to override any EC2 configuration values in the
        config file.
        )r#�EC2rXrVr�r}ruN�EBS�logical_volume_namer;rrr0)�	min_count�	max_count�key_name�security_groupsr0�	placement�	user_datar�
elastic_ipzEWaiting for instance to start so we can set its elastic IP address...��runningz.set the elastic IP of the first instance to %sr*r,rk)"rr��optionsr[rOrcr�r7r8r�r*rrAr\rrrCrB�	instances�__len__r �time�sleep�update�use_ipr6�strrkrY�id�instance_idr��putrT)r`�config_file�logical_volumer�rd�option�getterrXr6rV�kpr}ru�cfg_fp�reservation�l�ir�r��instance�srrr�create
st

�








�


�
 

z
Server.creater,c
Cs�tj��}|D]J}|��}z|�|g�}Wng}Yt|�dkrQ|�}||_||_||_|j|_||_	|d|_
|j
jD]
}	|	j|krH|	|_
q>|��|SqdS�Nr;r)r^r6rbrc�get_all_reservationsryr*rkrYr�r.r�r��	_instancer�)
r`r�r*rkrbrXr6r{r�r�rrr�create_from_instance_id^s.


��
zServer.create_from_instance_idc	Cs�g}tj��}|D]P}|��}|��}|D]C}|jD]=}zttj|j	d��tj
�d|j	�WqtyW|�}||_|j	|_
|j
|_|j	|_||_|��|�|�Yqwqq	|S)N)r�zServer for %s already exists)r^r6rbrcr�r��nextr�rSr��log�info�
StopIterationr*rYr�r.r�rT)	r`�serversrbrXr6r{r�r�r�rrr�create_from_current_instancesvs.

���z$Server.create_from_current_instancescsBtt|�j|fi|��d|_d|_d|_d|_d|_|��dS�N)	�superr�r�ssh_key_filer6�	_cmdshellr.r��
_setup_ec2)rr��kw��	__class__rrr�szServer.__init__c	Cs�|jr|jr|jrdS|jrZ|jr\tj��D]G}|j|jkrY|��|_|j	rY|jsYz&|j�
|j	g�}t|�dkrN|djD]}|j|j	krM|d|_||_q=Wqt
yXYqwqdSdSdSr�)r6r�r.r�rYr^rbr*rcr�r�ryr�r)rrXr{r�rrrr��s.

����zServer._setup_ec2cCs d}|jr|j��|jj}|S�Nr,)r�r��state)r�statusrrr�_status�s

zServer._statuscC�d}|jr	|jj}|Sr�)r��public_dns_name�r�hostnamerrr�	_hostname��zServer._hostnamecCr�r�)r��private_dns_namer�rrr�_private_hostname�r�zServer._private_hostnamecCr�r�)r�r0)r�itrrr�_instance_type�r�zServer._instance_typecCr�r�)r��launch_time)r�ltrrr�_launch_time�r�zServer._launch_timecCsd}|jr
|j��}|Sr�)r��get_console_output)r�corrr�_console_output�s
zServer._console_outputcCsg}|jr	|jj}|Sr�)r.�groups)r�gnrrr�_groups�r�zServer._groupscCs"|��}t|�dkr|djSdS)Nr;rr,)r�ryr�)rr�rrr�_security_group�s
zServer._security_groupcC�d}|jr	|jj}|Sr�)r�r�)rrurrr�_zone�r�zServer._zonecCr�r�)r�r�)r�knrrr�	_key_name�r�zServer._key_namecstt|���|��dSr�)r�r�r�r��rr�rrr��sz
Server.putcs |jrtd��tt|���dS�Nz Can't delete a production server)�
production�
ValueErrorr�r��deleter�r�rrr��sz
Server.deletecC�&|jrtd��|jr|j��dSdSr�)r�r�r��stopr�rrrr���
�zServer.stopcCr�r�)r�r�r��	terminater�rrrr��r�zServer.terminatecCs|jr
|j��dSdSr�)r��rebootr�rrrr��s�z
Server.rebootcCs&|jdkrt�d�|jdksdSdS)Nr�r�)r�r�r�r�rrr�waits

�zServer.waitcCsb|js.tj�d�}tj�|�r"tj�|d|j�}tj�|�r"||_|js.t�}|�	d�|_|jS)Nz~/.sshz%s.pemzPath to OpenSSH Key file)
r�r"r#�
expanduser�isdir�joinr��isfilerr>)r�ssh_dir�ssh_filerHrrrr@szServer.get_ssh_key_filecCs,|jsddlm}|��|�|�|_|jS)Nr)�cmdshell)r��boto.manager�r@�start)rr�rrr�get_cmdshells
zServer.get_cmdshellcCs
d|_dSr�)r�r�rrr�reset_cmdshells
zServer.reset_cmdshellcCs<t|����}|�|�}Wd�|S1swY|Sr�)r
r�rC)rr4�cmdr�rrrrCs
��z
Server.runrcCs|��t||�Sr�)r@r)rrrrr�get_bundlers
zServer.get_bundlercCs"ddlm}|��||||d�S)Nrr)r�ssh_pwd)rrr@)rrrrrrr�get_ssh_client#szServer.get_ssh_clientcCs|�d|�S)Nzapt-get -y install %s)rC)r�pkgrrr�install(szServer.install)NNN)r,r�rK)rN);rLrMrNrr*rkrYr�r�rr�r	r��ami_idrur��private_hostname�listr��security_groupr�r0r�r��open�console_output�packages�plugins�classmethodr�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r@r�rrCrrr�
__classcell__rrr�rr��sj





P
	

r�)#�__doc__�boto.ec2r^�boto.mashups.iobjectr�boto.pyami.configrr�boto.sdb.db.modelr�boto.sdb.db.propertyrrrr	r�r
�
boto.ec2.zoner�boto.ec2.keypairrr"r��
contextlibr
�boto.exceptionr�boto.compatrrrp�objectrrOr�rrrr�<module>s"Ue

https://t.me/RX1948 - 2025