%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/states/zpool.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlmZej	e
�ZdZd�Z
dd�Zddddd�Zeed	�ZdS(
u"
States for managing zpools

:maintainer:    Jorge Schrauwen <sjorge@blackdot.be>
:maturity:      new
:depends:       salt.utils.zfs, salt.modules.zpool
:platform:      smartos, illumos, solaris, freebsd, linux

.. versionadded:: 2016.3.0
.. versionchanged:: 2018.3.1
  Big refactor to remove duplicate code, better type converions and improved
  consistancy in output.

.. code-block:: yaml

    oldpool:
      zpool.absent:
        - export: true

    newpool:
      zpool.present:
        - config:
            import: false
            force: true
        - properties:
            comment: salty storage pool
        - layout:
            - mirror:
              - /dev/disk0
              - /dev/disk1
            - mirror:
              - /dev/disk2
              - /dev/disk3

    partitionpool:
      zpool.present:
        - config:
            import: false
            force: true
        - properties:
            comment: disk partition salty storage pool
            ashift: '12'
            feature@lz4_compress: enabled
        - filesystem_properties:
            compression: lz4
            atime: on
            relatime: on
        - layout:
            - /dev/disk/by-uuid/3e43ce94-77af-4f52-a91b-6cdbb0b0f41b

    simplepool:
      zpool.present:
        - config:
            import: false
            force: true
        - properties:
            comment: another salty storage pool
        - layout:
            - /dev/disk0
            - /dev/disk1

.. warning::

    The layout will never be updated, it will only be used at time of creation.
    It's a whole lot of work to figure out if a devices needs to be detached, removed,
    etc. This is best done by the sysadmin on a case per case basis.

    Filesystem properties are also not updated, this should be managed by the zfs state module.

i(tabsolute_importtprint_functiontunicode_literalsN(tOrderedDictuzpoolcC@stjd�stdfStS(u
    Provides zpool state
    uzfs_supportu3The zpool state cannot be loaded: zfs not supported(t
__grains__tgettFalset__virtualname__(((s5/usr/lib/python2.7/site-packages/salt/states/zpool.pyt__virtual__Ws
cC@s�g}|r(tjj|�r(d}nt|t�r�xC|D]i}t|t�rl|jt||��q>|r�|ddkr�tjj	||�}n|j
|�q>Wn�t|t�rwx�|D]�}|jd�d}||}|dkr|j
|�nt|t�s$|jd�}nxI|D]A}|r_|ddkr_tjj	||�}n|j
|�q+Wq�Wnd}|S(u�
    Turn the layout data into usable vdevs spedcification

    We need to support 2 ways of passing the layout:

    .. code::
        layout_new:
          - mirror:
            - disk0
            - disk1
          - mirror:
            - disk2
            - disk3

    .. code:
        layout_legacy:
          mirror-0:
            disk0
            disk1
          mirror-1:
            disk2
            disk3

    iu/u-udisku N(tostpathtexiststNonet
isinstancetlistRtextendt_layout_to_vdevtjointappendtsplit(tlayoutt
device_dirtvdevstvdevt	vdev_typet	vdev_disktdisk((s5/usr/lib/python2.7/site-packages/salt/states/zpool.pyR`s0	



c
	C@s�i|d6id6d0d6dd6}itd6d0d6d0d6td	6}td
dkrad|d<ntd
d
kr~d|d<n|r�|j|�n|}|r�td|�}n|d0kr�i}n|r�td|�}n|d0kr�i}nt||d�}|r"|jd|�ntj	d||�tj	d||�tj	d||�tj	d||�t|d<t
dr�t|d<td|�r�d|d|<n|dr�dnd|d|<dj||d|�|d<n�td|�r_t|d<td|dt�}g}	|r�xZ|D]O}
|
|krZtj
d||
�q/n||
||
kr/|	j|
�q/q/Wnx�|	D]�}
td||
||
�}|dr�||dkr�i|d|<n||
|d||
<q�t|d<|ddkrd |d<nd!j|d|
�|d<q�W|dr�|drOd"nd#|d<q�nK|dr�td$|d%|d	d&|d�}|d|d<|dr�d|d|<d'j|�|d<q�n|dr�|r�tj	d(|�td)d%|d	d*|d+||�}|d|d<|drOd|d|<d,j|�|d<q�d-|krl|d-|d<q�d.j|�|d<n|dr�|r�d/j|�|d<n|S(1uE	
    ensure storage pool is present on the system

    name : string
        name of storage pool
    properties : dict
        optional set of properties to set for the storage pool
    filesystem_properties : dict
        optional set of filesystem properties to set for the storage pool (creation only)
    layout: dict
        disk layout to use if the pool does not exist (creation only)
    config : dict
        fine grain control over this state

    .. note::

        The following configuration properties can be toggled in the config parameter.
          - import (true) - try to import the pool before creating it if absent
          - import_dirs (None) - specify additional locations to scan for devices on import (comma-seperated)
          - device_dir (None, SunOS=/dev/dsk, Linux=/dev) - specify device directory to prepend for none
            absolute device paths
          - force (false) - try to force the import or creation

    .. note::

        It is no longer needed to give a unique name to each top-level vdev, the old
        layout format is still supported but no longer recommended.

        .. code-block:: yaml

            - mirror:
              - /tmp/vdisk3
              - /tmp/vdisk2
            - mirror:
              - /tmp/vdisk0
              - /tmp/vdisk1

        The above yaml will always result in the following zpool create:

        .. code-block:: bash

            zpool create mypool mirror /tmp/vdisk3 /tmp/vdisk2 mirror /tmp/vdisk0 /tmp/vdisk1

    .. warning::

        The legacy format is also still supported but not recommended,
        because ID's inside the layout dict must be unique they need to have a suffix.

        .. code-block:: yaml

            mirror-0:
              /tmp/vdisk3
              /tmp/vdisk2
            mirror-1:
              /tmp/vdisk0
              /tmp/vdisk1

    .. warning::

        Pay attention to the order of your dict!

        .. code-block:: yaml

            - mirror:
              - /tmp/vdisk0
              - /tmp/vdisk1
            - /tmp/vdisk2

        The above will result in the following zpool create:

        .. code-block:: bash

            zpool create mypool mirror /tmp/vdisk0 /tmp/vdisk1 /tmp/vdisk2

        Creating a 3-way mirror! While you probably expect it to be mirror
        root vdev with 2 devices + a root vdev of 1 device!

    unameuchangesuresultuucommentuimportuimport_dirsu
device_diruforceukerneluSunOSu/dev/dskuLinuxu/devuzfs.from_auto_dictiuzpool.present::%s::config - %suzpool.present::%s::vdevs - %su#zpool.present::%s::properties -  %su.zpool.present::%s::filesystem_properties -  %sutestuzpool.existsuuptodateuimporteducreatedustorage pool {0} was {1}u	zpool.gettparsableu0zpool.present::%s::update - unknown property: %su	zpool.setusetu*The following properties were not updated:u{0} {1}uproperties updateduno update neededuzpool.importtforcetdirustorage pool {0} was importeduzpool.present::%s::creatinguzpool.createt
propertiestfilesystem_propertiesustorage pool {0} was createduerroru!could not create storage pool {0}uKstorage pool {0} was not imported, no (valid) layout specified for creationN(RtTrueRRtupdatet	__utils__Rtinserttlogtdebugt__opts__t__salt__tformattwarningR(
tnameRRRtconfigtrettdefault_configRtproperties_currenttproperties_updatetproptrestmod_res((s5/usr/lib/python2.7/site-packages/salt/states/zpool.pytpresent�s�O




		


!






 






cC@sVi|d6id6dd6dd6}tjd||�tjd||�td|�r5i}t|d<td	rt|d<nQ|r�td
|d|�}|d|d<n$td
|d|�}|d|d<|dr|r�dnd|d|<dj||d|�|d<qRd|krR|d|d<qRnt|d<dj|�|d<|S(u�
    ensure storage pool is absent on the system

    name : string
        name of storage pool
    export : boolean
        export instread of destroy the zpool if present
    force : boolean
        force destroy or export

    unameuchangesuresultuucommentu$zpool.absent::%s::config::force = %su%zpool.absent::%s::config::export = %suzpool.existsutestuzpool.exportRuexportedu
zpool.destroyu	destroyedustorage pool {0} was {1}uerrorustorage pool {0} is absentN(RR$R%R'RR&R R((R*texportRR,R2((s5/usr/lib/python2.7/site-packages/salt/states/zpool.pytabsents0





!
(t__doc__t
__future__RRRR	tloggingtsalt.utils.odictRt	getLoggert__name__R$RRRRR3RR5(((s5/usr/lib/python2.7/site-packages/salt/states/zpool.pyt<module>Gs		I�

Zerion Mini Shell 1.0