Mini Shell

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

3

�Mf�'�@s�ddlZejdd�ddlmZddlZddlmZddlmZddl	m
Z
dd	lmZdd
lm
Z
ddlZejd�Zdd
lmZddlmZmZed�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�N�BlockDevz2.0)r�)�errors)�util)�log_method_call)�udev)�availabilityZblivet�)�
StorageDevice)�LINUX_SECTOR_SIZE�get_majors_by_device_typez
device-mappercs�eZdZdZdZdZejejgZ	d�fdd�	Z
d	d
�Ze�fdd��Z
ed
d��Zedd��Zedd��Zdd�Zdd�Zdd�Z�fdd�Zedd��Z�ZS)�DMDevicez A device-mapper device �dmz/dev/mapperNF�c

	s.tt|�j|||||||	d�||_||_dS)aQ
            :param name: the device name (generally a device node's basename)
            :type name: str
            :keyword exists: does this device exist?
            :type exists: bool
            :keyword size: the device's size
            :type size: :class:`~.size.Size`
            :keyword parents: a list of parent devices
            :type parents: list of :class:`StorageDevice`
            :keyword fmt: this device's formatting
            :type fmt: :class:`~.formats.DeviceFormat` or a subclass of it
            :keyword sysfs_path: sysfs device path
            :type sysfs_path: str
            :keyword dm_uuid: device-mapper UUID (see note below)
            :type dm_uuid: str
            :type str uuid: device UUID (see note below)
            :keyword target: device mapper table/target name (eg: "linear")
            :type target: str

            .. note::

                The dm_uuid is not necessarily persistent, as it is based on
                map name in many cases. The uuid, however, is a persistent UUID
                stored in device metadata on disk.
        )�fmt�size�exists�uuid�parents�
sysfs_pathN)�superr
�__init__�target�dm_uuid)
�self�namerrrrrrrr)�	__class__��/usr/lib/python3.6/dm.pyr7s

zDMDevice.__init__cCs$tj|�}|d|j|jd�7}|S)Nz,  target = %(target)s  dm_uuid = %(dm_uuid)s)rr)r
�__repr__rr)r�srrrrXs
zDMDevice.__repr__cs$tt|�j}|j|j|jd��|S)N)rr)rr
�dict�updaterr)r�d)rrrr!^sz
DMDevice.dictcCs|jS)z4 Return the device specifier for use in /etc/fstab. )�path)rrrr�
fstab_specdszDMDevice.fstab_speccCs|jS)z& This device's device-mapper map name )r)rrrr�map_nameiszDMDevice.map_namecCsNytjj|jdd�Stjk
rH}zdt|�kr6dS�WYdd}~XnXdS)NTzNot running as rootF)�blockdevrZ
map_existsr&�DMError�str)r�errr�statusnszDMDevice.statuscCs0t||j|jd�|js"tjd��tjj|j�S)z9 Return the dm-X (eg: dm-0) device node for this device. )r+zdevice has not been created)	rrr+rrZDeviceErrorr'rZnode_from_name)rrrr�get_dm_node{s
zDMDevice.get_dm_nodecCsBt||jd�tjddd|jg�}|r6tjd|j��tj�dS)N)r�kpartxz-az-sz$partition activation failed for '%s')	rrr�run_programr$rr(r�settle)r�rcrrr�setup_partitions�s
zDMDevice.setup_partitionscCs�t||jd�tjddd|jg�}|r6tjd|j��tj�xFt	j
d�D]8}|jd}|j|�rJ|t|�d�j
�rJtjj|�qJWdS)N)rr-z-dz-sz&partition deactivation failed for '%s'z/dev/mapper/�p)rrrr.r$rr(rr/�os�listdir�
startswith�len�isdigitr'r�remove)rr0Zdev�prefixrrr�teardown_partitions�s
zDMDevice.teardown_partitionscs4||jkrdSt||j|jd�tt|�j|�dS)z Set the device's map name. N)r+)�_namerrr+rr
�	_set_name)r�value)rrrr<�s
zDMDevice._set_namecCs
|jdS)z This device's backing device. r)r)rrrr�slave�szDMDevice.slave)NNNNNFNr)�__name__�
__module__�__qualname__�__doc__�_typeZ_dev_dirrZ
KPARTX_APPZBLOCKDEV_DM_PLUGINZ_external_dependenciesrr�propertyr!r%r&r+r,r1r:r<r>�
__classcell__rr)rrr
-s" 
r
c@s^eZdZdZdZdZddd�Zddd	�Zd
d�Zddd
�Z	ddd�Z
ddd�Zedd��Z
dS)�DMLinearDevicez	dm-linearTNFrcCs,|std��tj|||||||d|d�	dS)a�
            :param name: the device name (generally a device node's basename)
            :type name: str
            :keyword exists: does this device exist?
            :type exists: bool
            :keyword size: the device's size
            :type size: :class:`~.size.Size`
            :keyword parents: a list of parent devices
            :type parents: list of :class:`StorageDevice`
            :keyword fmt: this device's formatting
            :type fmt: :class:`~.formats.DeviceFormat` or a subclass of it
            :keyword sysfs_path: sysfs device path
            :type sysfs_path: str
            :keyword dm_uuid: device-mapper UUID
            :type dm_uuid: str
        z.DMLinearDevice requires a backing block deviceZlinear)rrrrrrrN)�
ValueErrorr
r)rrrrrrrrrrrr�s
zDMLinearDevice.__init__cCsBt||j||j|jd�|jjt}tjj	|j|jj
||j�dS)z Open, or set up, a device. )�origr+�controllableN)rrr+rIr>Zcurrent_sizerr'rZ
create_linearr$r)rrHZslave_lengthrrr�_setup�s

zDMLinearDevice._setupcCstj|�|j�tj�dS)N)r
�_post_setupr1rr/)rrrrrK�s
zDMLinearDevice._post_setupcCs*|j�tj�tjj|j�tj�dS)N)r:rr/r'rr8r)r�	recursiverrr�	_teardown�szDMLinearDevice._teardowncCstj||d�dS)N)rL)r
�teardown)rrLrrr�
deactivate�szDMLinearDevice.deactivatecCs8t||j|j|jd�|j|d�s&dStjd|j�dS)z  Close, or tear down, a device. )r+rI)rLNz$not tearing down dm-linear device %s)rrr+rIZ
_pre_teardown�log�debug)rrLrrrrN�s

zDMLinearDevice.teardowncCs|jS)N)Zmodel)rrrr�description�szDMLinearDevice.description)NNNFNr)F)F)F)N)r?r@rArCZ_partitionableZ_is_diskrrJrKrMrOrNrDrRrrrrrF�s




	rFc@s"eZdZdZdZdZd	dd�ZdS)
�
DMCryptDevicez A dm-crypt device zdm-cryptTNFrc
Cstj|||||||dd�dS)ae
            :param name: the device name (generally a device node's basename)
            :type name: str
            :keyword exists: does this device exist?
            :type exists: bool
            :keyword size: the device's size
            :type size: :class:`~.size.Size`
            :keyword parents: a list of parent devices
            :type parents: list of :class:`StorageDevice`
            :keyword fmt: this device's formatting
            :type fmt: :class:`~.formats.DeviceFormat` or a subclass of it
            :keyword sysfs_path: sysfs device path
            :type sysfs_path: str
        Zcrypt)rrrrrrN)r
r)rrrrrrrrrrrr�szDMCryptDevice.__init__)NNNFrN)r?r@rArBrC�
_encryptedrrrrrrS�s
rSc@s"eZdZdZdZdZd	dd�ZdS)
�DMIntegrityDevicez A dm-integrity device zdm-integrityTNFrc
Cstj|||||||dd�dS)ae
            :param name: the device name (generally a device node's basename)
            :type name: str
            :keyword exists: does this device exist?
            :type exists: bool
            :keyword size: the device's size
            :type size: :class:`~.size.Size`
            :keyword parents: a list of parent devices
            :type parents: list of :class:`StorageDevice`
            :keyword fmt: this device's formatting
            :type fmt: :class:`~.formats.DeviceFormat` or a subclass of it
            :keyword sysfs_path: sysfs device path
            :type sysfs_path: str
        Z	integrity)rrrrrrN)r
r)rrrrrrrrrrrrszDMIntegrityDevice.__init__)NNNFrN)r?r@rArBrCrTrrrrrrUs
rU)ZgiZrequire_versionZ
gi.repositoryrr'r3rrrZstorage_logrrZtasksrZloggingZ	getLoggerrPZstorager
�librrZ	DM_MAJORSr
rFrSrUrrrr�<module>s"
vB