MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyo
�
d�bc@sddlZddlZddlZddlZddlZddlmZddljj	Z	ddl
mZddljj
Z
ddlmZmZddljjjZddljjjZddlmZddlmZddlmZdZd	Zd
efd��YZdS(i����N(tsleep(tustr(t	add_eventtWALAEventOperation(tResourceDiskError(t
get_osutil(t
AGENT_NAMEsDATALOSS_WARNING_README.txtsMWARNING: THIS IS A TEMPORARY DISK.

Any data stored on this drive is SUBJECT TO LOSS and THERE IS NO WAY TO RECOVER IT.

Please do not use this disk for storing any personal or application data.

For additional details to please refer to the MSDN documentation at :
http://msdn.microsoft.com/en-us/library/windowsazure/jj672979.aspx
tResourceDiskHandlercBszeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
ed	��Zd
�Z
d�ZRS(cCst�|_tj�|_dS(N(Rtosutiltconftget_resourcedisk_filesystemtfs(tself((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyt__init__1scCs#tjd|j�}|j�dS(Nttarget(t	threadingtThreadtruntstart(Rtdisk_thread((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pytstart_activate_resource_disk5scCsMd}tj�r!|j�}n|dk	rItj�rI|j|�ndS(N(tNoneR	tget_resourcedisk_formattactivate_resource_disktget_resourcedisk_enable_swaptenable_swap(Rtmount_point((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyR9sc	Cs�tjd�yrtj�}|j|�}tjj|t�}yt	j
|t�Wn#tk
ry}tj
d|�nX|SWnKtk
r�}tjd|�tdtdtdt|�dtj�nXdS(NsActivate resource disks%Failed to write data loss warning:{0}s!Failed to mount resource disk {0}tnamet
is_successtmessagetop(tloggertinfoR	tget_resourcedisk_mountpointtmount_resource_disktostpathtjointDATALOSS_WARNING_FILE_NAMEtfileutilt
write_filetDATA_LOSS_WARNINGtIOErrortwarnRterrorRRtFalseRRtActivateResourceDiskR(RRtwarning_filete((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyRAs 
	cCsWtjd�y tj�}|j||�Wn#tk
rR}tjd|�nXdS(NsEnable swapsFailed to enable swap {0}(RR R	tget_resourcedisk_swap_size_mbtcreate_swap_spaceRR,(RRtsize_mbR0((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyRSs
cCsAtjdj|�dt�r=tjdj|�dt�ndS(Ns
sfdisk -R {0}tchk_errsblockdev --rereadpt {0}(t	shellutilRtformatR-(Rtdevice((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pytreread_partition_table[scCs|jjd�}|dkr-td��ndj|�}|d}tjd�d}|jj||�}|r�tj	d||�|Syt
j|dd�WnGtk
r�}d	j||�}tj
|�td
|d|��nXtj	d�tjd
j|��}|dr:tdj||d���nd}	|jdkrXd}	ndj|j||	�}
d|dkr�tj	d�g|djd�D]}tjd|�r�|^q�}tj	dt|��t|�dkrOtj	d�xJtdt|�d�D]/}
tj	d|
�tjdj||
��qWtj	d�tjdj|��tj	d|
�tj|
�qOn�tj	d�|jd td!d"j|��}|dj�}|d#kr?|jd$kr?tj	d%�|jd td!d&j|��|j|�tj	d|
�tj|
�ntj	d'|�tj�}|j|||�}d(}xJtjj|�r�|dkr�tj	d)||�t d(�|d8}qyWtjj|�s�td*j|���ntj	d+|�tj|d,t�\}}|d-krL|j!d.�d/krLtj"d0|�n�|dkr�tj"d1�|j|�tj|d,t�\}}|r�tj"d2|�tj|
�tj|�\}}|r�td3j|||���q�q�ntj	d4|||j�|S(5Nisunable to detect disk topologys/dev/{0}t1tmounts,Resource disk [{0}] is already mounted [{1}]tmodei�s1Failed to create mount point directory [{0}]: {1}tmsgtinnersExamining partition tablesparted {0} printis/Could not determine partition info for {0}: {1}tFtxfstfsmkfs.{0} -{2} {1}tgpts GPT detected, finding partitionss
s
^\s*[0-9]+sFound {0} GPT partition(s).sRemoving old GPT partitionssRemove partition {0}sparted {0} rm {1}sCreating new GPT partitions!parted {0} mkpart primary 0% 100%sFormat partition [{0}]s(GPT not detected, determining filesystemtsuppress_messaget
option_strs{0} 1 -nt7tntfssCThe partition is formatted with ntfs, updating partition type to 83s{0} 1 83sThe partition type is {0}is3Waiting for partition [{0}], {1} attempts remainingsPartition was not created [{0}]sMount resource disk [{0}]R4i sis already mountedi����s"Could not mount resource disk: {0}sNFailed to mount resource disk. Retry mounting after re-reading partition info.sJFailed to mount resource disk. Attempting to format and retry mount. [{0}]s<Could not mount {0} after syncing partition table: [{1}] {2}s,Resource disk {0} is mounted at {1} with {2}(#Rtdevice_for_ide_portRRR6R5trun_get_outputtget_mount_pointRR R'tmkdirtOSErrorR,RtsplittretmatchtlentrangeRtchange_partition_typetTruetstripR-R8R	tget_resourcedisk_mountoptionstget_mount_stringR#R$texistsRtfindR+(RRR7t	partitiont
mount_listtexistingtoseR<trettforce_optiontmkfs_stringtxtpartstitptypet
mount_optionstmount_stringtattemptstoutput((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyR"`s�
	


		

 

	
	
		"	
!

	
		
cCs�d}dj||rdnd|�}tj|dtdt�\}}|dkr�tjd|�d	}dj||rdnd|�}tj|dt�\}}n|dkr�tjd
|�ntjd|||�||fS(s|
            use sfdisk to change partition type.
            First try with --part-type; if fails, fall back to -c
        s--part-typessfdisk {0} {1} {2}s-ftR4tlog_cmdis6sfdisk with --part-type failed [{0}], retrying with -cs-cs
{0} succeededs{0} failed [{1}: {2}](R6R5RGR-RQRR R,(RRBRCt
option_to_usetcommandterr_codeRe((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyRP�s*	
	cCs?|dk	r%dj|j|||�Sdj|j||�SdS(Nsmount -t {0} -o {1} {2} {3}smount -t {0} {1} {2}(RR6R(RRbRWR((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyRT�scCs�||kr�tjj|�r�tjj|�|kr�tjd�tj|�j}|tjtj	B@r�|tjtj	B@}tjdj
||��tj||�ntSt
S(NsSwap already enabledsChanging mode of {0} to {1:o}(R#R$tisfiletgetsizeRR tstattst_modetS_IRWXGtS_IRWXOR6tchmodRQR-(tswapfiletswaplisttsizet
swapfile_mode((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pytcheck_existing_swap_files!

cCsQ|d}|d}tjj|d�}tjd�d}|j|||�rUdStjj|�r�tjj|�|kr�tj	d�tj
dj|�dt�tj
|�ntjj|�stj	d�|j||d�tj
d	j|��ntj
d
j|��r4tdj|���ntj	dj||��dS(
NiRrs	swapon -sisRemove old swap filesswapoff {0}R4sCreate swap files
mkswap {0}s
swapon {0}s{0}sEnabled {0}KB of swap at {1}(R#R$R%R5RGRvRkRlRR RR6R-tremovetmkfileR(RRR3tsize_kbRtRrRs((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyR2s"

*

c
Cs t|t�st|�}n|dkrBtdj|���ntjj|�rdtj|�nd}tj	|f�}|j
dkratjdkr&d}zcyKtj|tjtjBtjBtjtjB�}tj|d|�dSWntk
rnXWd|dk	r"tj|�nXntjdj||��}|dkrQ|Stjd�nd	d}d}t||�}|dkr�tj|j|||��d
>}nt||�}	|	dkr�|tj|j|	d|��7}n|dkrtjd�n
tjd�|S(s�
        Create a non-sparse file of that size. Deletes and replaces existing
        file.

        To allow efficient execution, fallocate will be tried first. This
        includes
        ``os.posix_fallocate`` on Python 3.3+ (unix) and the ``fallocate``
        command
        in the popular ``util-linux{,-ng}`` package.

        A dd fallback will be tried too. When size < 64M, perform
        single-pass dd.
        Otherwise do two-pass dd.
        isInvalid swap size [{0}]R?text4iNu"umask 0077 && fallocate -l {0} {1}s*fallocate unsuccessful, falling back to ddi@iisBumask 0077 && dd if=/dev/zero bs={0} count={1} conv=notrunc of={2}iis
dd successfulsdd unsuccessful(sxfsRz(iii(t
isinstancetintRR6R#R$RkRwR5tquoteRtsystversion_infoRtopentO_CREATtO_WRONLYtO_EXCLRmtS_IRUSRtS_IWUSRtposix_fallocatet
BaseExceptiontcloseRRR R,(
RtfilenametnbytesR[tfn_shtfdtdd_maxbstdd_cmdtblockstremains((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyRx3sP

%%
(t__name__t
__module__R
RRRRR8R"RPRTtstaticmethodRvR2Rx(((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyR0s							|	!		( R#RLRmR~RttimeRtazurelinuxagent.common.loggertcommonRtazurelinuxagent.common.futureRtazurelinuxagent.common.confR	tazurelinuxagent.common.eventRRt%azurelinuxagent.common.utils.fileutiltutilsR't&azurelinuxagent.common.utils.shellutilR5t azurelinuxagent.common.exceptionRtazurelinuxagent.common.osutilRtazurelinuxagent.common.versionRR&R)tobjectR(((sO/usr/lib/python2.7/site-packages/azurelinuxagent/daemon/resourcedisk/default.pyt<module>s"