Mini Shell
3
{)c�| � @ s� d dl Z d dlZd dlZddlmZ ddlmZ ddlmZ ddlmZ ddlm Z ddlm
Z
dd lmZm
Z
dd
lmZ d dlZejd�Zdd
lmZ ddlmZ ddlmZ ddlmZ G dd� de�ZdS )� N� )� callbacks)�errors)�util)�flags)�log_method_call)�udev)�
get_format�DeviceFormat)�Size�blivet� )�Device)�NetworkStorageDevice)�LINUX_SECTOR_SIZE)�LUKS_METADATA_SIZEc st e Zd ZdZdZdZdZdZdZdZ dZ
dZddiZd�� fd d
� Z
� fdd�Ze� fd
d��Zedd� �Zedd� �Zedd� �Zedd� �Zedd� �Zejdd� �Z� fdd�Zdd� Zdd� Zd d!� Zed"d#� d$d#� d%d&�Zd'd(� Ze� fd)d*��Zed+d,� �Zd-d.� Zed/d0� �Z ed1d2� �Z!ed3d4� �Z"d5d6� Z#d�d7d8�Z$ed9d:� �Z%e%jd;d:� �Z%ed<d=� �Z&e&jd>d=� �Z&d�d?d@�Z'd�dAdB�Z(d�dCdD�Z)dEdF� Z*d�dGdH�Z+d�dIdJ�Z,d�dKdL�Z-d�dMdN�Z.dOdP� Z/dQdR� Z0dSdT� Z1dUdV� Z2dWdX� Z3dYdZ� Z4d[d\� Z5d]d^� Z6d�d_d`�Z7d�dbdc�Z8d�ddde�Z9dfdg� Z:dhdi� Z;edjd#� dkd#� dld&�Z<dmdn� Z=edodp� �Z>d�dqdr�Z?edsdt� �Z@edudv� �ZAedwdx� �ZBdydz� ZCed{d|� �ZDed}d~� �ZEdd�� ZFd�d�� ZGd�d�� ZHed�d#� d�d#� d�d&�ZId�d�d��ZJed�d�� �ZKed�d�� �ZLed�d�� �ZMed�d�� �ZNed�d�� �ZOed�d�� �ZPed�d�� �ZQed�d�� �ZRed�d�� �ZSed�d�� �ZTd�d�� ZUd�d�� ZV� ZWS )��
StorageDevicea A generic storage device.
A fully qualified path to the device node can be obtained via the
path attribute, although it is not guaranteed to be useful, or
even present, unless the StorageDevice's setup method has been
run.
Fr z/dev�name�_renameN� c sd t |t�r|g}| | _|| _|| _td�| _| j rr|rr|jrrtt j
|�|j�}|t j
|�krrtjd|||� |}t
t j
|��| _| j| _| jr�| jnt
d�| _t j
|�| _t j
|�| _|
| _|p�d| _|p�d| _|
| _d| _d| _d| _| j o�| j|� �rtd| ��tt| �j||d� || _t j!| j�| _"d| _#g | _$| j�r`| j%�r`| j&� | j'� 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 uuid: universally unique identifier (device -- not fs)
:type uuid: str
:keyword sysfs_path: sysfs device path
:type sysfs_path: str
:keyword major: the device major
:type major: int
:keyword minor: the device minor
:type minor: int
:keyword serial: the ID_SERIAL_SHORT for this device
:type serial: str
:keyword vendor: the manufacturer of this Device
:type vendor: str
:keyword model: manufacturer's device model string
:type model: str
:keyword bus: the interconnect this device uses
:type bus: str
NzB%s: using size %s instead of %s to accommodate format minimum sizer r FTz&%s is not a valid name for this device)�parents)(�
isinstancer �exists�uuid�
sysfs_pathr �_format�min_size�maxr Znumeric_type�log�infor �_size�_target_size�
_current_size�major�minor�_serial�_vendor�_model�bus� _readonly�
_protected�
_controllable�
is_name_valid�
ValueError�superr �__init__�format�copy�deepcopy�original_formatZ
fstab_commentZdevice_links�status�update_sysfs_path�update_size)�selfr �fmtr �sizer# r$ r r r �serial�vendor�modelr( r )� __class__� �/usr/lib/python3.6/storage.pyr/ C sF "
zStorageDevice.__init__c sB d}| j sd}d|| jtt| �j� f }| jjr>|d| j 7 }|S )NZexistingznon-existentz%s %s %sz with %s)r r9 r. r �__str__r0 �type)r7 Zexist�s)r= r>