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__/volume.cpython-310.pyc
o

ckF[�?�@s�ddlmZddlmZddlmZmZmZmZm	Z	ddl
mZddlm
Z
ddlZddlZddlZddlZddlmZddlZGdd	�d	e�ZGd
d�de�ZdS)�)�print_function)�Model)�StringProperty�IntegerProperty�ListProperty�ReferenceProperty�CalculatedProperty)�Server)�propgetN)�closingc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�CommandLineGettercCs6|�dd�s|j�d�}tj|tjjd�|d<dSdS)N�region�region_name)�choices)�get�cls�
find_propertyr
�boto�ec2�regions��self�params�prop�r�4/usr/lib/python3/dist-packages/boto/manage/volume.py�
get_region%s�zCommandLineGetter.get_regioncCs4|�dd�stdd|jjd�}t�|�|d<dSdS)N�zonezEC2 Availability Zone)�name�verbose_namer)rrr�
get_all_zonesr
rrrr�get_zone*s��zCommandLineGetter.get_zonecC�.|�dd�s|j�d�}t�|�|d<dSdS)Nr�rrrr
rrrr�get_name0��zCommandLineGetter.get_namecCs.|�dd�stddd�}t�|�|d<dSdS)N�size�	Size (GB))rr)rrr
rrrr�get_size5r%zCommandLineGetter.get_sizecCr")N�mount_pointr#rrrr�get_mount_point:r%z!CommandLineGetter.get_mount_pointcCr")N�devicer#rrrr�
get_device?r%zCommandLineGetter.get_devicecCsT||_|�|�|d��|_|�|�|�|�|�|�|�|�|�|�dS)Nr
)	rr�connectrr!r$r(r*r,)rrrrrrrDs




zCommandLineGetter.getN)
�__name__�
__module__�__qualname__rr!r$r(r*r,rrrrrr#srcs�eZdZedddd�Zeddd�Zeddd�Zedd�Zed	d
d�Zedd�Z	e
ed
�Ze
eddd�Zededd�Zededd�Zededd�Zedd��Zedd��ZdMdd�ZdMdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�ZdMd*d+�Z dNd-d.�Z!dMd/d0�Z"d1d2�Z#d3d4�Z$d5d6�Z%d7d8�Z&d9d:�Z'd;d<�Z(d=d>�Z)dOd?d@�Z*dNdAdB�Z+dCdD�Z,dEdF�Z-dGdH�Z.dN�fdIdJ�	Z/dKdL�Z0�Z1S)P�VolumeT�Name)�required�uniquerz
EC2 Region)r3rzEC2 ZonezMount Point)rzDevice Namez/dev/sdp)r�default)r3)�	item_type�volumeszServer Attached To)�collection_namerzVolume State)r�calculated_type�
use_methodzAttachment Stater'c	Ks�t�}|�||�|�d�}|��}|�d�}|�d�}|�||j�}|�}||_|j|_|�d�|_|�d�|_|�d�|_	|j|_
|j|_|��|S)Nr
rr&rr)r+)
rrr-�
create_volumerr�id�	volume_idr)r+r�	zone_name�put)	rr�getterr
rrr&�
ebs_volume�vrrr�create`s"


z
Volume.createcCsbd}tj�|�}|�|g�}t|�dkr/|d}|�}|j|_||_|jj|_	|j
|_|��|S)N�r)
rr�connect_to_region�get_all_volumes�lenr<r=rr
rrr>r?)rrr=r�volr�rsrBrrr�create_from_volume_idts
zVolume.create_from_volume_idNcCs|��d}|�|||�S)N���)�
get_snapshots�create_from_snapshot)rrr&�snapshotrrr�create_from_latest_snapshot�sz"Volume.create_from_latest_snapshotcCs�||jkr|j}|��}|jdus|jdkr#|�|jg�d}|j|_|�||j|�}t�}|j|_|j	|_||_
|j|_|j|_|j
|_
|j|_|��|S)N�r)r&�get_ec2_connectionr>rFr=rr;r1rr<rr)r+rr?)rrrNr&r�current_volumerArBrrrrM�s"
zVolume.create_from_snapshotcCs8|jr|jjSt|d�r|jdurtj�|j�|_|jS)Nr)�serverr�hasattrrrEr�rrrrrQ�s
zVolume.get_ec2_connectioncC�"|��}|�|jg�}|d��S�Nr)rQrFr=�volume_state�rrrIrrr�
_volume_state��zVolume._volume_statecCrVrW)rQrFr=�attachment_staterYrrr�_attachment_state�r[zVolume._attachment_statecCs2t|d�s|��}|�|jg�}|dj|_|jS)N�__sizer)rTrQrFr=r&�
_Volume__sizerYrrr�_size�s

zVolume._sizecCs|jr|j�d�dSdS)Nzxfsprogs xfsdump)rS�installrUrrr�install_xfs�s�zVolume.install_xfscCst|��}|��}|jg|j}g}|D]}|j|vr/|jdkr/tj�|j�|_	d|_
|�|�q|jdd�d�|S)zO
        Returns a list of all completed snapshots for this volume ID.
        z100%TcSst|j|j�S�N)�cmp�date)�x�yrrr�<lambda>�sz&Volume.get_snapshots.<locals>.<lambda>)rd)
rQ�get_all_snapshotsr=�past_volume_ids�progressr�utils�parse_ts�
start_timere�keep�append�sort)rrrI�all_vols�snapsrNrrrrL�s


�zVolume.get_snapshotscCsJ|jdkrtd�dS|r||_|��|��}|�|j|jj|j�dS)N�attachedzalready attached)	r\�printrSr?rQ�
attach_volumer=�instance_idr+)rrSrrrr�attach�s
z
Volume.attachFcCs\|j}|dks|dus|dkrtd�dS|��}|�|j|jj|j|�d|_|��dS)N�	available�	detachingzalready detached)	r\rurQ�
detach_volumer=rSrwr+r?)r�force�staterrrr�detach�sz
Volume.detachcCsX|jdur	td��|r|}n|j��}|�d|j�}|s!|��|d�d�r*dSdS)N�0server attribute must be set to run this commandzxfs_check %srDzbad superblock magic number 0FT)rS�
ValueError�get_cmdshell�runr+�close�
startswith)r�use_cmd�cmd�statusrrr�checkfs�s

zVolume.checkfscCs�|jdur	td��t|j����0}|j��}|�|j�s8tj�d|j�t	�
d�|�|j�rWd�dSWd�dS1sCwYdS)Nrz+%s still does not exist, waiting 10 seconds�
)rSr�rr��existsr+r�log�info�time�sleep)rr�rrr�wait�s


��"�zVolume.waitcCs�|jdur	td��d}t|j����$}|�|�s.tj�d�|�d|j	�}Wd�|SWd�|S1s9wY|S)Nrz
make_fs...zmkfs -t xfs %s)
rSr�rr�r�rr�r�r�r+)rr�r�rrr�format�s


��
��z
Volume.formatcCs2|jdur	td��tj�d�t|j����y}|j��}|�|j�s1tj�d�|�	d|j�nCtj�d�|�	d�}|d�
d�}|D].}|�
�}|rs|d	|jkrs|d
|jkrs|�	d|j�|�	d|d
�|�	d
�nqE|�	d|j|jf�|�	d|j�Wd�dS1s�wYdS)Nr�handle_mount_pointzmaking directoryzmkdir %szdirectory exists alreadyzmount -lrD�
�rz	umount %sz
mount %s /tmpzchmod 777 /tmpzmount %s %sz
xfs_growfs %s)rSr�rr�r�rr��isdirr)r��splitr+)rr�r��lines�line�trrr�mount�s.



�"�zVolume.mountcCs:||_|��|��|��|��|��|��dSrc)rSr?rbrxr�r�r�)rrSrrr�
make_readyszVolume.make_readycC�|jr|j�d|j�SdS)Nz/usr/sbin/xfs_freeze -f %s�rSr�r)rUrrr�freeze$��z
Volume.freezecCr�)Nz/usr/sbin/xfs_freeze -u %sr�rUrrr�unfreeze(r�zVolume.unfreezecCs�zMz'|��|jdur|���|j�}n|jj�|j�}tj�d|j	|f�Wnt
y?tj�d�tj�t���YnwW|�
�}|SW|�
�}|S|�
�}|YS)Nz!Snapshot of Volume %s created: %szSnapshot error)r�rSrQ�create_snapshotr=rrr�r�r�	Exception�	traceback�
format_excr�)rrNr�rrrrN,s$
����zVolume.snapshotcCsxg}|D]5}|r|r|j|kr|j|kr|�|�q|r'|j|kr&|�|�q|r4|j|kr3|�|�q|�|�q|Src)rerp)rrs�
start_date�end_date�l�snaprrr�get_snapshot_range=s 
�

�

�zVolume.get_snapshot_rangecCs�|��}t|�dkr|S|dd�}tj�|djj�}tj|j|j|j|jd�}tj	ddd�}t
|||�|�||||�}t
|�|sH|Sd	}|D]}|rZ||jjkrZd
|_qL|jj}qL|rx|dj}	|	�
�dkrxtj	|	�
�d�}
|	|
}	|�||	|dj�}t|�dkr�|dd	�D]}d
|_q�tdd�D]!}|�||	||	�}
t|
�dkr�|
dd	�D]}d
|_q�|	|}	q�|j||	d
�}d	}|D]}|r�||jjkr�d
|_q�|jj}q�|r�|D]}|js�tj�d||j|jf�|��q�|S)a1
        Trim the number of snapshots for this volume.  This method always
        keeps the oldest snapshot.  It then uses the parameters passed in
        to determine how many others should be kept.

        The algorithm is to keep all snapshots from the current day.  Then
        it will keep the first snapshot of the day for the previous seven days.
        Then, it will keep the first snapshot of the week for the previous
        four weeks.  After than, it will keep the first snapshot of the month
        for as many months as there are.

        r�rDrKr)�year�month�day�tzinfo�i)�days�secondsNF)r��)r�zDeleting %s(%s) for %s)rLrG�datetime�nowrer�r�r�r��	timedeltarur�ro�weekday�rangerr�r�r�delete)rr�rsr��midnight�one_week�
previous_week�current_dayr��
week_boundary�delta�partial_week�i�weeks_worth�	remainder�
current_monthrrr�trim_snapshotsMs^
�



�zVolume.trim_snapshotscC�dSrcr)rr&rrr�grow��zVolume.growcCr�rcr)rrNrrr�copy�r�zVolume.copycCr�rcr)rrerrr�get_snapshot_from_date�r�zVolume.get_snapshot_from_datecs2|r|��|��}|�|j�tt|���dSrc)r~rQ�
delete_volumer=�superr1r�)r�delete_ebs_volumer��	__class__rrr��s
z
Volume.deletecCr�rcrrUrrr�archive�szVolume.archiverc)F)NN)2r.r/r0rrrr>r)r+r=r�strrjrr	rSrrXr\�intr&�classmethodrCrJrOrMrQrZr]r`rbrLrxr~r�r�r�r�r�r�r�rNr�r�r�r�r�r�r��
__classcell__rrr�rr1Nsb


����










	

Cr1)�
__future__r�boto.sdb.db.modelr�boto.sdb.db.propertyrrrrr�boto.manage.serverr	�boto.manager
�
boto.utilsr�boto.ec2r�r��
contextlibrr��objectrr1rrrr�<module>s+

https://t.me/RX1948 - 2025