Mini Shell

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

3

{)c��@s~ddlZddlmZddlmZddlmZddlmZddl	m
Z
ddlZejd�Z
d	d
lmZee
�Gdd�de��ZdS)
�N)�
add_metaclass�)�errors)�log_method_call)�get_device_format_class)�SynchronizedABCMetaZblivet�)�
StorageDevicecs�eZdZdZejdd�dd�Zejdd�dd�Z�fdd	�Zddd�Z	�fd
d�Z
ejdd��Zdd�Z
ejdd��Zdd�Zddd�Z�ZS)�ContainerDevicea� A device that aggregates a set of member devices.

        The only interfaces provided by this class are for addition and removal
        of member devices -- one set for modifying the member set of the
        python objects, and one for writing the changes to disk.

        The member set of the instance can be manipulated using the methods
        :meth:`~.ParentList.append` and :meth:`~.ParentList.remove` of the
        instance's :attr:`~.Device.parents` attribute.

        :meth:`add` and :meth:`remove` remove a member from the container's on-
        disk representation. These methods should normally only be called from
        within :meth:`.deviceaction.ActionAddMember.execute` and
        :meth:`.deviceaction.ActionRemoveMember.execute`.
    cCsdS)N�)�srr�/usr/lib/python3.6/container.py�<lambda>8szContainerDevice.<lambda>z+The type of member devices' required format)�doccCsdS)Nr)rrrr
r:sz7The container UUID attribute in the member format classcs8t|j�|_|js"tjd|j��tt|�j||�dS)Nzcannot find '%s' class)r�_format_class_name�format_classrZStorageError�superr
�__init__)�self�args�kwargs)�	__class__rr
r=szContainerDevice.__init__TcCs�|jstjd�dSt|j|j�s6tjd|j|�dSt|j|j�}|jrf|sX|jrftjd�dS|rx|jjrxdS||jk}|r�|r�d||jfS|r�|r�d||jfSdS)a Whether the member's array UUID has the proper relationship
            with its array's UUID.

            :param member: the member device to add
            :type member: :class:`.StorageDevice`
            :param bool expect_equality: if True, expect UUIDs to be equal, otherwise, expect them to be unequal
            :param bool require_existence: if True, checking UUIDs is only meaningful if member format exists
            :returns: error msg if the UUIDs lack the correct relationship
            :rtype: str or NoneType
        z7No attribute name corresponding to member's array UUID.NzcAttribute name (%s) which specifies member format's array UUID does not exist for this object (%s).zAt least one UUID missing.z8Member format's UUID %s does not match expected UUID %s.z1Member format's UUID %s matches expected UUID %s.)	�_format_uuid_attr�log�info�hasattr�formatZwarning�getattr�existsZuuid)r�member�expect_equality�require_existenceZmember_fmt_uuidZuuids_equalrrr
�_verify_member_uuidDs$




z#ContainerDevice._verify_member_uuidcsRt||j|jd�t|j|j�s(td��|j|�}|r>td��tt|�j	|�dS)z� Add a parent device to the container.

            :param parent: the parent device to add
            :type parent: :class:`.StorageDevice`

            This operates on the in-memory model and does not alter disk
            contents at all.
        )�parentzparent has wrong formatz&cannot add parent with mismatched UUIDN)
r�name�
isinstancerr�
ValueErrorr"rr
�_add_parent)rr#�error)rrr
r'ns	
zContainerDevice._add_parentcCs
t��dS)z� Device-type specific code to add a member to the container.

            :param member: the member device to add
            :type member: :class:`.StorageDevice`

            This method writes the member addition to disk.
        N)�NotImplementedError)rrrrr
�_add�s	zContainerDevice._addcCs\|jstjd��|j|dd�}|r8tjd||�td��|j|�||jkrX|jj	|�dS)z� Add a member to the container.

            :param member: the member device to add
            :type member: :class:`.StorageDevice`

            This method writes the member addition to disk.
        zdevice has not been createdF)r zcannot re-add member: %s (%s)z9cannot add members that are already part of the containerN)
rr�DeviceErrorr"rr(r&r*�parents�append)rrr(rrr
�add�s


zContainerDevice.addcCs
t��dS)z� Device-type specific code to remove a member from the container.

            :param member: the member device to remove
            :type member: :class:`.StorageDevice`

            This method writes the member removal to disk.
        N)r))rrrrr
�_remove�s	zContainerDevice._removecCsnt||j|jd�|js"tjd��|j|dd�}|rJtjd||�t	d��|j
|�||jkrj|jj|�dS)z� Remove a member from the container.

            :param member: the member device to remove
            :type member: :class:`.StorageDevice`

            This method writes the member removal to disk.
        )�statuszdevice has not been createdF)r!z!cannot remove non-member: %s (%s)z8cannot remove members that are not part of the containerN)
rr$r0rrr+r"rr(r&r/r,�remove)rrr(rrr
r1�s


zContainerDevice.removeNcCsdS)Nr)rZnewsizerrr
�update_size�szContainerDevice.update_size)TT)N)�__name__�
__module__�__qualname__�__doc__�abc�abstractpropertyrrrr"r'�abstractmethodr*r.r/r1r2�
__classcell__rr)rr
r
%s


*r
)r7Zsixr�rZstorage_logrZformatsrZthreadsrZloggingZ	getLoggerrZstorager	r
rrrr
�<module>s