Salt interface to ZFS commands
codeauthor: | Nitin Madhok <nmadhok@clemson.edu> |
---|
salt.modules.zfs.
bookmark
(snapshot, bookmark)¶2016.3.0 新版功能.
Creates a bookmark of the given snapshot
注解
Bookmarks mark the point in time when the snapshot was created, and can be used as the incremental source for a zfs send command.
This feature must be enabled to be used. See zpool-features(5) for details on ZFS feature flags and the bookmarks feature.
CLI Example:
salt '*' zfs.bookmark myzpool/mydataset@yesterday myzpool/mydataset#complete
salt.modules.zfs.
clone
(name_a, name_b, **kwargs)¶2016.3.0 新版功能.
Creates a clone of the given snapshot.
注解
ZFS properties can be specified at the time of creation of the filesystem 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 Example:
salt '*' zfs.clone myzpool/mydataset@yesterday myzpool/mydataset_yesterday
salt.modules.zfs.
create
(name, **kwargs)¶2015.5.0 新版功能.
在 2016.3.0 版更改.
Create a ZFS File System.
注解
ZFS properties can be specified at the time of creation of the filesystem 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 Example:
salt '*' zfs.create myzpool/mydataset [create_parent=True|False]
salt '*' zfs.create myzpool/mydataset properties="{'mountpoint': '/export/zfs', 'sharenfs': 'on'}"
salt '*' zfs.create myzpool/volume volume_size=1G [sparse=True|False]`
salt '*' zfs.create myzpool/volume volume_size=1G properties="{'volblocksize': '512'}" [sparse=True|False]
salt.modules.zfs.
destroy
(name, **kwargs)¶2015.5.0 新版功能.
Destroy a ZFS File System.
警告
watch out when using recursive and recursive_all
CLI Example:
salt '*' zfs.destroy myzpool/mydataset [force=True|False]
salt.modules.zfs.
diff
(name_a, name_b, **kwargs)¶2016.3.0 新版功能.
Display the difference between a snapshot of a given filesystem and another snapshot of that filesystem from a later time or the current contents of the filesystem.
CLI Example:
salt '*' zfs.diff myzpool/mydataset@yesterday myzpool/mydataset
salt.modules.zfs.
exists
(name, **kwargs)¶2015.5.0 新版功能.
Check if a ZFS filesystem or volume or snapshot exists.
CLI Example:
salt '*' zfs.exists myzpool/mydataset
salt '*' zfs.exists myzpool/myvolume type=volume
salt.modules.zfs.
get
(*dataset, **kwargs)¶2016.3.0 新版功能.
Displays properties for the given datasets.
注解
If no datasets are specified, then the command displays properties for all datasets on the system.
CLI Example:
salt '*' zfs.get
salt '*' zfs.get myzpool/mydataset [recursive=True|False]
salt '*' zfs.get myzpool/mydataset properties="sharenfs,mountpoint" [recursive=True|False]
salt '*' zfs.get myzpool/mydataset myzpool/myotherdataset properties=available fields=value depth=1
salt.modules.zfs.
hold
(tag, *snapshot, **kwargs)¶2016.3.0 新版功能.
Adds a single reference, named with the tag argument, to the specified snapshot or snapshots.
注解
Each snapshot has its own tag namespace, and tags must be unique within that space.
If a hold exists on a snapshot, attempts to destroy that snapshot by using the zfs destroy command return EBUSY.
注解
A comma-seperated list can be provided for the tag parameter to hold multiple tags.
CLI Example:
salt '*' zfs.hold mytag myzpool/mydataset@mysnapshot [recursive=True]
salt '*' zfs.hold mytag,myothertag myzpool/mydataset@mysnapshot
salt '*' zfs.hold mytag myzpool/mydataset@mysnapshot myzpool/mydataset@myothersnapshot
salt.modules.zfs.
holds
(snapshot, **kwargs)¶2016.3.0 新版功能.
Lists all existing user references for the given snapshot or snapshots.
CLI Example:
salt '*' zfs.holds myzpool/mydataset@baseline
salt.modules.zfs.
inherit
(prop, name, **kwargs)¶2016.3.0 新版功能.
Clears the specified property
CLI Example:
salt '*' zfs.inherit canmount myzpool/mydataset [recursive=True|False]
salt.modules.zfs.
list
(name=None, **kwargs)¶2015.5.0 新版功能.
在 2016.3.0 版更改.
Return a list of all datasets or a specified dataset on the system and the values of their used, available, referenced, and mountpoint properties.
CLI Example:
salt '*' zfs.list
salt '*' zfs.list myzpool/mydataset [recursive=True|False]
salt '*' zfs.list myzpool/mydataset properties="sharenfs,mountpoint"
salt.modules.zfs.
mount
(name='-a', **kwargs)¶2016.3.0 新版功能.
Mounts ZFS file systems
CLI Example:
salt '*' zfs.mount
salt '*' zfs.mount myzpool/mydataset
salt '*' zfs.mount myzpool/mydataset options=ro
salt.modules.zfs.
promote
(name)¶2016.3.0 新版功能.
Promotes a clone file system to no longer be dependent on its "origin" snapshot.
注解
This makes it possible to destroy the file system that the clone was created from. The clone parent-child dependency relationship is reversed, so that the origin file system becomes a clone of the specified file system.
The snapshot that was cloned, and any snapshots previous to this snapshot, are now owned by the promoted clone. The space they use moves from the origin file system to the promoted clone, so enough space must be available to accommodate these snapshots. No new space is consumed by this operation, but the space accounting is adjusted. The promoted clone must not have any conflicting snapshot names of its own. The rename subcommand can be used to rename any conflicting snapshots.
CLI Example:
salt '*' zfs.promote myzpool/myclone
salt.modules.zfs.
release
(tag, *snapshot, **kwargs)¶2016.3.0 新版功能.
Removes a single reference, named with the tag argument, from the specified snapshot or snapshots.
注解
The tag must already exist for each snapshot. If a hold exists on a snapshot, attempts to destroy that snapshot by using the zfs destroy command return EBUSY.
注解
A comma-seperated list can be provided for the tag parameter to release multiple tags.
CLI Example:
salt '*' zfs.release mytag myzpool/mydataset@mysnapshot [recursive=True]
salt '*' zfs.release mytag myzpool/mydataset@mysnapshot myzpool/mydataset@myothersnapshot
salt.modules.zfs.
rename
(name, new_name, **kwargs)¶2015.5.0 新版功能.
在 2016.3.0 版更改.
Rename or Relocate a ZFS File System.
CLI Example:
salt '*' zfs.rename myzpool/mydataset myzpool/renameddataset
salt.modules.zfs.
rollback
(name, **kwargs)¶2016.3.0 新版功能.
Roll back the given dataset to a previous snapshot.
警告
When a dataset is rolled back, all data that has changed since the snapshot is discarded, and the dataset reverts to the state at the time of the snapshot. By default, the command refuses to roll back to a snapshot other than the most recent one.
In order to do so, all intermediate snapshots and bookmarks must be destroyed by specifying the -r option.
CLI Example:
salt '*' zfs.rollback myzpool/mydataset@yesterday
salt.modules.zfs.
set
(*dataset, **kwargs)¶2016.3.0 新版功能.
Sets the property or list of properties to the given value(s) for each dataset.
注解
properties are passed as key-value pairs. e.g.
compression=off
注解
Only some properties can be edited.
See the Properties section for more information on what properties can be set and acceptable values.
Numeric values can be specified as exact values, or in a human-readable form with a suffix of B, K, M, G, T, P, E, Z (for bytes, kilobytes, megabytes, gigabytes, terabytes, petabytes, exabytes, or zettabytes, respectively).
CLI Example:
salt '*' zfs.set myzpool/mydataset compression=off
salt '*' zfs.set myzpool/mydataset myzpool/myotherdataset compression=off
salt '*' zfs.set myzpool/mydataset myzpool/myotherdataset compression=lz4 canmount=off
salt.modules.zfs.
snapshot
(*snapshot, **kwargs)¶2016.3.0 新版功能.
Creates snapshots with the given names.
注解
ZFS properties can be specified at the time of creation of the filesystem 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 Example:
salt '*' zfs.snapshot myzpool/mydataset@yesterday [recursive=True]
salt '*' zfs.snapshot myzpool/mydataset@yesterday myzpool/myotherdataset@yesterday [recursive=True]
salt.modules.zfs.
unmount
(name, **kwargs)¶2016.3.0 新版功能.
Unmounts ZFS file systems
警告
Using -a
for the name parameter will probably break your system, unless your rootfs is not on zfs.
CLI Example:
salt '*' zfs.unmount myzpool/mydataset [force=True|False]