saltext.zfs.utils.zfs

Utility functions for ZFS

These functions are for dealing with type conversion and basic execution

saltext.zfs.utils.zfs.is_supported()[source]

Check the system for ZFS support

saltext.zfs.utils.zfs.has_feature_flags()

Check if zpool-features is available

saltext.zfs.utils.zfs.property_data_zpool()

Return a dict of zpool properties

Note

Each property will have an entry with the following info:
  • edit : boolean - is this property editable after pool creation

  • type : str - either bool, bool_alt, size, numeric, or string

  • values : str - list of possible values

Warning

This data is probed from the output of ‘zpool get’ with some supplemental data that is hardcoded. There is no better way to get this information aside from reading the code.

saltext.zfs.utils.zfs.property_data_zfs()

Return a dict of zfs properties

Note

Each property will have an entry with the following info:
  • edit : boolean - is this property editable after pool creation

  • inherit : boolean - is this property inheritable

  • type : str - either bool, bool_alt, size, numeric, or string

  • values : str - list of possible values

Warning

This data is probed from the output of ‘zfs get’ with some supplemental data that is hardcoded. There is no better way to get this information aside from reading the code.

saltext.zfs.utils.zfs.from_numeric(value)[source]

Convert zfs numeric to python int

saltext.zfs.utils.zfs.to_numeric(value)[source]

Convert python int to zfs numeric

saltext.zfs.utils.zfs.from_bool(value)[source]

Convert zfs bool to python bool

saltext.zfs.utils.zfs.from_bool_alt(value)[source]

Convert zfs bool_alt to python bool

saltext.zfs.utils.zfs.to_bool(value)[source]

Convert python bool to zfs on/off bool

saltext.zfs.utils.zfs.to_bool_alt(value)[source]

Convert python to zfs yes/no value

saltext.zfs.utils.zfs.from_size(value)[source]

Convert zfs size (human readable) to python int (bytes)

saltext.zfs.utils.zfs.to_size(value, convert_to_human=True)[source]

Convert python int (bytes) to zfs size

NOTE: https://src.illumos.org/source/xref/illumos-gate/usr/src/lib/pyzfs/common/util.py?#114

saltext.zfs.utils.zfs.from_str(value)[source]

Decode zfs safe string (used for name, path, …)

saltext.zfs.utils.zfs.to_str(value)[source]

Encode zfs safe string (used for name, path, …)

saltext.zfs.utils.zfs.from_auto(name, value, source='auto')[source]

Convert zfs value to python value

saltext.zfs.utils.zfs.to_auto(name, value, source='auto', convert_to_human=True)[source]

Convert python value to zfs value

saltext.zfs.utils.zfs.from_auto_dict(values, source='auto')[source]

Pass an entire dictionary to from_auto

Note

The key will be passed as the name

saltext.zfs.utils.zfs.to_auto_dict(values, source='auto', convert_to_human=True)[source]

Pass an entire dictionary to to_auto

Note

The key will be passed as the name

saltext.zfs.utils.zfs.is_snapshot(name)[source]

Check if name is a valid snapshot name

saltext.zfs.utils.zfs.is_bookmark(name)[source]

Check if name is a valid bookmark name

saltext.zfs.utils.zfs.is_dataset(name)[source]

Check if name is a valid filesystem or volume name

saltext.zfs.utils.zfs.zfs_command(command, flags=None, opts=None, property_name=None, property_value=None, filesystem_properties=None, target=None)[source]

Build and properly escape a zfs command

Note

Input is not considered safe and will be passed through to_auto(from_auto(‘input_here’)), you do not need to do so your self first.

saltext.zfs.utils.zfs.zpool_command(command, flags=None, opts=None, property_name=None, property_value=None, filesystem_properties=None, pool_properties=None, target=None)[source]

Build and properly escape a zpool command

Note

Input is not considered safe and will be passed through to_auto(from_auto(‘input_here’)), you do not need to do so your self first.

saltext.zfs.utils.zfs.parse_command_result(res, label=None)[source]

Parse the result of a zpool/zfs command

Note

Output on failure is rather predictable. - retcode > 0 - each ‘error’ is a line on stderr - optional ‘Usage:’ block under those with hits

We simple check those and return a OrderedDict were we set label = True|False and error = error_messages