AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 18.118.137.139
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/977/root/usr/libexec/lsm.d/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /proc/977/root/usr/libexec/lsm.d/find_unused_lun.pyo
�
/�P`c@s�ddlZddlZddlZddlZddlmZmZmZmZd�Z	d�Z
d�Zd�Zd�Z
d�Zd	�Zed
kr�e�ndS(i����N(tClienttLsmErrortErrorNumbert	LocalDiskcCs$tjj|�tjjd�dS(Ns
(tsyststderrtwrite(tmsg((s%/usr/libexec/lsm.d/find_unused_lun.pytprint_stderrscCs�y*tj|tj�}tj|�tSWnStk
r}|jtjkrRtS|jtj	kryt
tjd��q��nXdS(s
    The manpage of open(2):
        There is one exception: on Linux 2.6 and later, O_EXCL can be used
        without O_CREAT if pathname refers to a block device.  If the block
        device is in use by the system (e.g., mounted), open() fails with the
        error EBUSY.
    Even when disk has partitions, when all partitions are not used, this
    function still treats it as free disk.
    When specific disk or its partition is used by LVM, if there is no data
    stored in it, this function still treats it as free disk.
    s(Permission deny, try sudo or run as rootN(
tostopentO_EXCLtclosetTruetOSErrorterrnotEBUSYtFalsetEACCESRRtPERMISSION_DENIED(tblk_pathtfdterr((s%/usr/libexec/lsm.d/find_unused_lun.pytis_free_disk s
	cCs�|td�}d|}ytj|�}Wntk
rAdSXt|�dkrXdS|d}d|}d|}t|�� }|j�jd�s�dSWdQXt|��}|j�j�SWdQXdS(	s�
    Use `/sys/block/sdX/holders/dm-0/dm/name` to get mpath name,
    use `/sys/block/sdf/holders/dm-0/dm/uuid` to check whether holder is
    multipath.
    s/dev/s/sys/block/%s/holdersiis/sys/block/%s/dm/names/sys/block/%s/dm/uuidsmpath-N(	tlenR	tlistdirtFileNotFoundErrortNoneR
treadt
startswithtstrip(Rtblk_nametsysfs_holder_foldertholderstholder_nametsysfs_dm_name_pathtsysfs_dm_uuid_pathtf((s%/usr/libexec/lsm.d/find_unused_lun.pyt	get_mpath:s 





cCs$t|�}|r td|�StS(Ns/dev/mapper/%s(R&RR(Rt
mpath_name((s%/usr/libexec/lsm.d/find_unused_lun.pytis_free_multipathSscCs�|j�}i}i}x'|D]}|jr|||j<qqWx�tj�D]�}t|�smt|�rOytj|�}Wn.tk
r�}|jt	j
kr�qOn�nX||kr�td|�qOn||||<qOqOW|j�S(s>
    Return a list of lsm.Volume objects.
    Unused here means the LUN/volume meets one of following conditions:
        * the block device representing LUN/Volume could be opened with O_EXCL,
          which means its block is completely free.
        * The block device is used as PV of LVM, but not been used.
    s<Found free disk %s, but not managed by libstoragemgmt plugin(
tvolumestvpd83RtlistRR(t	vpd83_getRtcodeRt
NO_SUPPORTRtvalues(tctvolstvpd83_to_vol_hasht
free_vol_dicttvolt	disk_pathR*tlsm_err((s%/usr/libexec/lsm.d/find_unused_lun.pytfind_unused_lunZs(
	cCs�i|jd6|jd6|jd6|jd6||jjd6}tj|j�}|r�||d<t|d�}|r�d||d	<q�n|S(
Ntidtnametwwidt	system_idtsystem_namet	blk_pathsis/dev/mapper/%st	mpath_blk(R8R9R*R;Rtvpd83_searchR&(R4tsys_dicttdR=R'((s%/usr/libexec/lsm.d/find_unused_lun.pyt
format_vol{s




cCs�tjd�}tjd�}|dkr=td�d}nt||�}t|�}|srtd�t�n|j�}i}x|D]}|||j<q�Wtdt	|��x+|D]#}t
jt||�dd�GHq�WdS(	Nt
LSMCLI_URItLSMCLI_PASSWORDs4LSMCLI_URI environment not defined, using 'local://'slocal://sDidn't find any free LUNs
Found %d free LUN(s):
tindenti(
R	tgetenvRRRR7texittsystemsR8RtjsontdumpsRB(turitpasswordR0t	free_volstsyssR@tlsm_sysR4((s%/usr/libexec/lsm.d/find_unused_lun.pytmain�s"
	



t__main__(R	RRIRtlsmRRRRRRR&R(R7RBRPt__name__(((s%/usr/libexec/lsm.d/find_unused_lun.pyt<module>s"					!		

Anon7 - 2022
AnonSec Team