Mini Shell

Direktori : /lib/python3.6/site-packages/blivet/devices/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/blivet/devices/__pycache__/stratis.cpython-36.opt-1.pyc

3

{)c}%�@s�ddlZddlZejd�ZddlmZddlmZddlm	Z	ddl
mZmZdd	l
mZdd
lmZddlmZGdd
�d
e�ZGdd�de�ZdS)�NZblivet�)�
StorageDevice�)�stratis_info)�log_method_call)�DeviceError�StratisError)�Size)�availability)�
devicelibscs(eZdZdZdZdZddgZdZdZe	j
e	jgZ�fdd	�Z
ed
d��Zedd
��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd��Zejdd��Zedd��Zdd�Zeed�Zed d!��Z�fd"d#�Zd$d%�Z�fd&d'�Zd(d)�Zd0�fd*d+�	Z d1�fd,d-�	Z!d.d/�Z"�Z#S)2�StratisPoolDevicez A stratis pool device zstratis poolF�stratisdzstratis-cliz/dev/stratisTcs@|jdd�|_|jdd�|_|jdd�|_tt|�j||�dS)a
            :encrypted: whether this pool is encrypted or not
            :type encrypted: bool
            :keyword passphrase: device passphrase
            :type passphrase: str
            :keyword key_file: path to a file containing a key
            :type key_file: str
        �	encryptedF�
passphraseN�key_file)�pop�
_encrypted�_StratisPoolDevice__passphrase�	_key_file�superr�__init__)�self�args�kwargs)�	__class__��/usr/lib/python3.6/stratis.pyr.s	zStratisPoolDevice.__init__cCs|jdd�S)z# A list of this pool block devices N)�parents)rrrr�	blockdevs=szStratisPoolDevice.blockdevscCs|jdd�S)z' A list of this pool block filesystems N)Zchildren)rrrr�filesystemsBszStratisPoolDevice.filesystemscCstdd�|jD��S)z The size of this pool css|]}|jVqdS)N)�size)�.0�parentrrr�	<genexpr>Ksz)StratisPoolDevice.size.<locals>.<genexpr>)�sumr)rrrrr GszStratisPoolDevice.sizecCs4|jr*tj|j�}|s$td|j��|jS|jSdS)Nz'Failed to get information about pool %s)�existsr�
get_pool_info�namerZ
physical_sizer )r�	pool_inforrr�_physical_sizeMsz StratisPoolDevice._physical_sizecCstjjdd�|jD�|j�S)NcSsg|]
}|j�qSr)r )r!�bdrrr�
<listcomp>Ysz9StratisPoolDevice._pool_metadata_size.<locals>.<listcomp>)r�stratisZ	pool_usedrr)rrrr�_pool_metadata_sizeWsz%StratisPoolDevice._pool_metadata_sizecCs0td�}x|jD]}||j7}qW||j7}|S)Nr)r	r�	used_sizer-)rZ
physical_usedZ
filesystemrrr�_physical_used\s

z StratisPoolDevice._physical_usedcCs|j|jS)z3 Free space in the pool usable for new filesystems )r)r/)rrrr�
free_spaceiszStratisPoolDevice.free_spacecCs|jS)z# True if this device is encrypted. )r)rrrrrnszStratisPoolDevice.encryptedcCs
||_dS)N)r)rrrrrrsscCs|jS)z. Path to key file to be used in /etc/crypttab )r)rrrrrwszStratisPoolDevice.key_filecCs
||_dS)z0 Set the passphrase used to access this device. N)r)rrrrr�_set_passphrase|sz!StratisPoolDevice._set_passphrase)�fsetcCs |jdkp|jotj|jtj�S)N�)r3N)rr�os�access�R_OK)rrrr�has_key�s
zStratisPoolDevice.has_keycs(tt|�j�|jr$|jr$td��dS)Nz0cannot create encrypted stratis pool without key)rr�_pre_createrr7r)r)rrrr8�szStratisPoolDevice._pre_createcCsDt||j|jd�dd�|jD�}tjj|j||j|j|j	d�dS)z Create the device. )�statuscSsg|]
}|j�qSr)�path)r!r*rrrr+�sz-StratisPoolDevice._create.<locals>.<listcomp>)r'ZdevicesrrrN)
rr'r9rrr,Zcreate_poolrrr)rZbd_listrrr�_create�s
zStratisPoolDevice._createcsdtt|�j�d|j_tj|j�}|s4td|j��|j	|_	x"|j
D]}|j|j_|j	|j_qDWdS)NTz5Failed to get information about newly created pool %s)
rr�_post_create�formatr%rr&r'r�uuidr�	pool_name�	pool_uuid)rr(r")rrrr<�s
zStratisPoolDevice._post_createcCs$t||j|jd�tjj|j�dS)z Destroy the device. )r9N)rr'r9rr,Zremove_poolr>)rrrr�_destroy�szStratisPoolDevice._destroycsBtt|�j|d�|rdSx"|jD]}|j|j_|j|j_q"WdS)N)�new)	rr�add_hookrr'r=r?r>r@)rrBr")rrrrC�s
zStratisPoolDevice.add_hookcs:|r$x|jD]}d|j_d|j_qWtt|�j|d�dS)N)�	modparent)rr=r?r@rr�remove_hook)rrDr")rrrrE�s
zStratisPoolDevice.remove_hookcCstd|jg�S)Nzstratis.rootfs.pool_uuid=%s)�setr>)rrrr�dracut_setup_args�sz#StratisPoolDevice.dracut_setup_args)T)T)$�__name__�
__module__�__qualname__�__doc__�_type�
_resizable�	_packages�_dev_dirZ_format_immutabler
�STRATISPREDICTUSAGE_APP�STRATIS_DBUS�_external_dependenciesr�propertyrrr r)r-r/r0r�setterrr1rr7r8r;r<rArCrErG�
__classcell__rr)rrr$s8




	rcs�eZdZdZdZdZddgZdZej	ej
gZed�Z
d�fd	d
�	Z�fdd�Zed
d��Zedd��Zedd��Z�fdd�Zdd�Z�fdd�Zdd�Zdd�Z�ZS)�StratisFilesystemDevicez A stratis pool device zstratis filesystemFr
zstratis-cliz/dev/stratisz512 MiBNcsB|r$|djtjj|�kr$td��tt|�j|||||d�dS)NrzGcannot create new stratis filesystem, not enough free space in the pool)r'r r>rr%)r0rr,�filesystem_md_sizerrrVr)rr'rr r>r%)rrrr�sz StratisFilesystemDevice.__init__cs.|jdk	rd|jj|jfStt|�j�SdS)z This device's name. Nz%s/%s)�poolr'�_namerrV�	_get_name)r)rrrrZ�s
z!StratisFilesystemDevice._get_namecCs|jS)z8 The Stratis filesystem name (not including pool name). )rY)rrrr�fsname�szStratisFilesystemDevice.fsnamecCs|js
dS|jdS)Nr)r)rrrrrX�szStratisFilesystemDevice.poolcCsB|jstjj|j�Stj|jj|j	�}|s8t
d|j��|jSdS)z* Size used by this filesystem in the pool z-Failed to get information about filesystem %sN)r%rr,rWr r�get_filesystem_inforXr'r[rr.)r�fs_inforrrr.�sz!StratisFilesystemDevice.used_sizecsdt||j|j|j|d�t|t�s*td��|jsPtj	j
|�}||jjkrPt
d��tt|�j|�dS)N)r9r �newsizeznew size must of type Sizeznot enough free space in pool)rr'r9Z_size�
isinstancer	�
ValueErrorr%rr,rWrXr0rrrV�	_set_size)rr^Zmd_size)rrrra�s
z!StratisFilesystemDevice._set_sizecCs0t||j|jd�tjj|j|jj|j	d�dS)z Create the device. )r9)r'r@Zfs_sizeN)
rr'r9rr,Zcreate_filesystemr[rXr>r )rrrrr;�szStratisFilesystemDevice._createcsHtt|�j�tj|jj|j�}|s2td|j��|j	|_	|j
|j_
dS)Nz;Failed to get information about newly created filesystem %s)rrVr<rr\rXr'r[rr>r@r=)rr])rrrr<sz$StratisFilesystemDevice._post_createcCs*t||j|jd�tjj|jj|j�dS)z Destroy the device. )r9N)rr'r9rr,Zremove_filesystemrXr>)rrrrrAsz StratisFilesystemDevice._destroycCstd|jg�S)Nzroot=%s)rFr:)rrrrrGsz)StratisFilesystemDevice.dracut_setup_args)NNNF)rHrIrJrKrLrMrNrOr
rPrQrRr	Z	_min_sizerrZrSr[rXr.rar;r<rArGrUrr)rrrV�s"

rV)r4ZloggingZ	getLogger�logZstoragerZstatic_datarZstorage_logr�errorsrrr r	Ztasksr
r3rrrVrrrr�<module>s