salt.modules.zpool

Module for running ZFS zpool command

codeauthor:Nitin Madhok <nmadhok@clemson.edu>
salt.modules.zpool.add(zpool, *vdevs, **kwargs)

在 2016.3.0 版更改.

Add the specified vdev's to the given storage pool

zpool : string
name of storage pool
*vdevs : string
one or more devices
force : boolean
forces use of device

CLI 范例:

salt '*' zpool.add myzpool /path/to/vdev1 /path/to/vdev2 [...]
salt.modules.zpool.attach(zpool, device, new_device, force=False)

在 2016.3.0 版更改.

Attach specified device to zpool

zpool : string
name of storage pool
device : string
device to attach too
new_device : string
device to attach
force : boolean
forces use of device

CLI 范例:

salt '*' zpool.attach myzpool /path/to/vdev1 /path/to/vdev2 [...]
salt.modules.zpool.create(zpool, *vdevs, **kwargs)

2015.5.0 新版功能.

在 2016.3.0 版更改.

Create a simple zpool, a mirrored zpool, a zpool having nested VDEVs, a hybrid zpool with cache, spare and log drives or a zpool with RAIDZ-1, RAIDZ-2 or RAIDZ-3

zpool : string
name of storage pool
*vdevs : string
one or move devices
force : boolean
forces use of vdevs, even if they appear in use or specify a conflicting replication level.
mountpoint : string
sets the mount point for the root dataset
altroot : string
equivalent to "-o cachefile=none,altroot=root"
properties : dict
additional pool properties
filesystem_properties : dict
additional filesystem properties

CLI 范例:

salt '*' zpool.create myzpool /path/to/vdev1 [...] [force=True|False]
salt '*' zpool.create myzpool mirror /path/to/vdev1 /path/to/vdev2 [...] [force=True|False]
salt '*' zpool.create myzpool raidz1 /path/to/vdev1 /path/to/vdev2 raidz2 /path/to/vdev3 /path/to/vdev4 /path/to/vdev5 [...] [force=True|False]
salt '*' zpool.create myzpool mirror /path/to/vdev1 [...] mirror /path/to/vdev2 /path/to/vdev3 [...] [force=True|False]
salt '*' zpool.create myhybridzpool mirror /tmp/file1 [...] log mirror /path/to/vdev1 [...] cache /path/to/vdev2 [...] spare /path/to/vdev3 [...] [force=True|False]

注解

Zpool properties can be specified at the time of creation of the pool by passing an additional argument called "properties" and specifying the properties with their respective values in the form of a python dictionary:

properties="{'property1': 'value1', 'property2': 'value2'}"

Filesystem properties can be specified at the time of creation of the pool by passing an additional argument called "filesystem_properties" and specifying the properties with their respective values in the form of a python dictionary:

filesystem_properties="{'property1': 'value1', 'property2': 'value2'}"

Example:

salt '*' zpool.create myzpool /path/to/vdev1 [...] properties="{'property1': 'value1', 'property2': 'value2'}"
salt.modules.zpool.create_file_vdev(size, *vdevs)

在 2016.3.0 版更改.

Creates file based virtual devices for a zpool

*vdevs is a list of full paths for mkfile to create

CLI 范例:

salt '*' zpool.create_file_vdev 7g /path/to/vdev1 [/path/to/vdev2] [...]

注解

Depending on file size, the above command may take a while to return.

salt.modules.zpool.destroy(zpool, force=False)

在 2016.3.0 版更改.

Destroys a storage pool

zpool : string
name of storage pool
force : boolean
force destroy of pool

CLI 范例:

salt '*' zpool.destroy myzpool
salt.modules.zpool.detach(zpool, device)

在 2016.3.0 版更改.

Detach specified device to zpool

zpool : string
name of storage pool
device : string
device to detach

CLI 范例:

salt '*' zpool.detach myzpool /path/to/vdev1
salt.modules.zpool.exists(zpool)

Check if a ZFS storage pool is active

zpool : string
name of storage pool

CLI 范例:

salt '*' zpool.exists myzpool
salt.modules.zpool.export(*pools, **kwargs)

2015.5.0 新版功能.

在 2016.3.0 版更改.

Export storage pools

*pools : string
one or more storage pools to export
force : boolean
force export of storage pools

CLI 范例:

salt '*' zpool.export myzpool ... [force=True|False]
salt '*' zpool.export myzpool2 myzpool2 ... [force=True|False]
salt.modules.zpool.get(zpool, prop=None, show_source=False)

2016.3.0 新版功能.

Retrieves the given list of properties

zpool : string
name of storage pool
prop : string
optional name of property to retrieve
show_source : boolean
show source of property

CLI 范例:

salt '*' zpool.get myzpool
salt.modules.zpool.healthy()

2016.3.0 新版功能.

Check if all zpools are healthy

CLI 范例:

salt '*' zpool.healthy
salt.modules.zpool.history(zpool=None, internal=False, verbose=False)

2016.3.0 新版功能.

Displays the command history of the specified pools or all pools if no pool is specified

zpool : string
optional storage pool
internal : boolean
toggle display of internally logged ZFS events
verbose : boolean
toggle display of the user name, the hostname, and the zone in which the operation was performed

CLI 范例:

salt '*' zpool.upgrade myzpool
salt.modules.zpool.import(zpool=None, new_name=None, **kwargs)

2015.5.0 新版功能.

在 2016.3.0 版更改.

Import storage pools or list pools available for import

zpool : string
optional name of storage pool
new_name : string
optional new name for the storage pool
mntopts : string
comma-separated list of mount options to use when mounting datasets within the pool.
force : boolean
forces import, even if the pool appears to be potentially active.
altroot : string
equivalent to "-o cachefile=none,altroot=root"
dir : string
searches for devices or files in dir, mutiple dirs can be specified as follows:: dir="dir1,dir2"
no_mount : boolean
import the pool without mounting any file systems.
only_destroyed : boolean
imports destroyed pools only. this also sets force=True.
properties : dict
additional pool properties

注解

Zpool properties can be specified at the time of creation of the pool by passing an additional argument called "properties" and specifying the properties with their respective values in the form of a python dictionary:

properties="{'property1': 'value1', 'property2': 'value2'}"

CLI 范例:

salt '*' zpool.import [force=True|False]
salt '*' zpool.import myzpool [mynewzpool] [force=True|False]
salt '*' zpool.import myzpool dir='/tmp'
salt.modules.zpool.iostat(zpool=None, sample_time=0)

在 2016.3.0 版更改.

Display I/O statistics for the given pools

zpool : string
optional name of storage pool
sample_time : int
seconds to capture data before output

CLI 范例:

salt '*' zpool.iostat myzpool
salt.modules.zpool.list(properties='size, alloc, free, cap, frag, health', zpool=None)

2015.5.0 新版功能.

在 2016.3.0 版更改.

Return information about (all) storage pools

zpool : string
optional name of storage pool
properties : string
comma-separated list of properties to list

注解

the 'name' property will always be included, the 'frag' property will get removed if not available

zpool : string
optional zpool

注解

multiple storage pool can be provded as a space seperated list

CLI 范例:

salt '*' zpool.list
salt.modules.zpool.offline(zpool, *vdevs, **kwargs)

2015.5.0 新版功能.

在 2016.3.0 版更改.

Ensure that the specified devices are offline

警告

By default, the OFFLINE state is persistent. The device remains offline when the system is rebooted. To temporarily take a device offline, use temporary=True.

zpool : string
name of storage pool
*vdevs : string
one or more devices
temporary : boolean
enable temporarily offline

CLI 范例:

salt '*' zpool.offline myzpool /path/to/vdev1 [...] [temporary=True|False]
salt.modules.zpool.online(zpool, *vdevs, **kwargs)

2015.5.0 新版功能.

在 2016.3.0 版更改.

Ensure that the specified devices are online

zpool : string
name of storage pool
*vdevs : string
one or more devices
expand : boolean

Expand the device to use all available space.

注解

If the device is part of a mirror or raidz then all devices must be expanded before the new space will become available to the pool.

CLI 范例:

salt '*' zpool.online myzpool /path/to/vdev1 [...]
salt.modules.zpool.reguid(zpool)

2016.3.0 新版功能.

Generates a new unique identifier for the pool

警告

You must ensure that all devices in this pool are online and healthy before performing this action.

zpool : string
name of storage pool

CLI 范例:

salt '*' zpool.reguid myzpool
salt.modules.zpool.reopen(zpool)

2016.3.0 新版功能.

Reopen all the vdevs associated with the pool

zpool : string
name of storage pool

CLI 范例:

salt '*' zpool.reopen myzpool
salt.modules.zpool.replace(zpool, old_device, new_device=None, force=False)

在 2016.3.0 版更改.

Replaces old_device with new_device.

注解

This is equivalent to attaching new_device, waiting for it to resilver, and then detaching old_device.

The size of new_device must be greater than or equal to the minimum size of all the devices in a mirror or raidz configuration.

zpool : string
name of storage pool
old_device : string
old device to replace
new_device : string
optional new device
force : boolean
Forces use of new_device, even if its appears to be in use.

CLI 范例:

salt '*' zpool.replace myzpool /path/to/vdev1 /path/to/vdev2
salt.modules.zpool.scrub(zpool, stop=False)

在 2016.3.0 版更改.

Scrub a storage pool

zpool : string
name of storage pool
stop : boolean
if true, cancel ongoing scrub

CLI 范例:

salt '*' zpool.scrub myzpool
salt.modules.zpool.set(zpool, prop, value)

2016.3.0 新版功能.

Sets the given property on the specified pool

zpool : string
name of storage pool
prop : string
name of property
value : string
value to set property to

CLI 范例:

salt '*' zpool.set myzpool readonly yes
salt.modules.zpool.status(zpool=None)

在 2016.3.0 版更改.

Return the status of the named zpool

zpool : string
optional name of storage pool

CLI 范例:

salt '*' zpool.status myzpool
salt.modules.zpool.upgrade(zpool=None, version=None)

2016.3.0 新版功能.

Enables all supported features on the given pool

警告

Once this is done, the pool will no longer be accessible on systems that do not support feature flags. See zpool-features(5) for details on compatibility with systems that support feature flags, but do not support all features enabled on the pool.

zpool : string
optional storage pool, applies to all otherwize
version : int
version to upgrade to, if unspecified upgrade to the highest possible

CLI 范例:

salt '*' zpool.upgrade myzpool
salt.modules.zpool.zpool_list()

2014.7.0 版后已移除: Use list() instead.

Return a list of all pools in the system with health status and space usage

CLI 范例:

salt '*' zpool.zpool_list