ZTS: Fix summary page creation
[zfs.git] / contrib / pyzfs / libzfs_core / _constants.py
blob9c40ece1a7df32fadb9da09569c77030477b7d1a
2 # Copyright 2015 ClusterHQ
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 """
18 Important `libzfs_core` constants.
19 """
21 from __future__ import absolute_import, division, print_function
22 import errno
23 import sys
26 # Compat for platform-specific errnos
27 if sys.platform.startswith('freebsd'):
28 ECHRNG = errno.ENXIO
29 ECKSUM = 97 # EINTEGRITY
30 ETIME = errno.ETIMEDOUT
31 else:
32 ECHRNG = errno.ECHRNG
33 ECKSUM = errno.EBADE
34 ETIME = errno.ETIME
37 # https://stackoverflow.com/a/1695250
38 def enum_with_offset(offset, sequential, named):
39 enums = dict(((b, a + offset) for a, b in enumerate(sequential)), **named)
40 return type('Enum', (), enums)
43 def enum(*sequential, **named):
44 return enum_with_offset(0, sequential, named)
47 #: Maximum length of any ZFS name.
48 MAXNAMELEN = 255
49 #: Default channel program limits
50 ZCP_DEFAULT_INSTRLIMIT = 10 * 1000 * 1000
51 ZCP_DEFAULT_MEMLIMIT = 10 * 1024 * 1024
52 #: Encryption wrapping key length
53 WRAPPING_KEY_LEN = 32
54 #: Encryption key location enum
55 zfs_key_location = enum(
56 'ZFS_KEYLOCATION_NONE',
57 'ZFS_KEYLOCATION_PROMPT',
58 'ZFS_KEYLOCATION_URI'
60 #: Encryption key format enum
61 zfs_keyformat = enum(
62 'ZFS_KEYFORMAT_NONE',
63 'ZFS_KEYFORMAT_RAW',
64 'ZFS_KEYFORMAT_HEX',
65 'ZFS_KEYFORMAT_PASSPHRASE'
67 # Encryption algorithms enum
68 zio_encrypt = enum(
69 'ZIO_CRYPT_INHERIT',
70 'ZIO_CRYPT_ON',
71 'ZIO_CRYPT_OFF',
72 'ZIO_CRYPT_AES_128_CCM',
73 'ZIO_CRYPT_AES_192_CCM',
74 'ZIO_CRYPT_AES_256_CCM',
75 'ZIO_CRYPT_AES_128_GCM',
76 'ZIO_CRYPT_AES_192_GCM',
77 'ZIO_CRYPT_AES_256_GCM'
79 # ZFS-specific error codes
80 zfs_errno = enum_with_offset(1024, [
81 'ZFS_ERR_CHECKPOINT_EXISTS',
82 'ZFS_ERR_DISCARDING_CHECKPOINT',
83 'ZFS_ERR_NO_CHECKPOINT',
84 'ZFS_ERR_DEVRM_IN_PROGRESS',
85 'ZFS_ERR_VDEV_TOO_BIG',
86 'ZFS_ERR_IOC_CMD_UNAVAIL',
87 'ZFS_ERR_IOC_ARG_UNAVAIL',
88 'ZFS_ERR_IOC_ARG_REQUIRED',
89 'ZFS_ERR_IOC_ARG_BADTYPE',
90 'ZFS_ERR_WRONG_PARENT',
91 'ZFS_ERR_FROM_IVSET_GUID_MISSING',
92 'ZFS_ERR_FROM_IVSET_GUID_MISMATCH',
93 'ZFS_ERR_SPILL_BLOCK_FLAG_MISSING',
94 'ZFS_ERR_UNKNOWN_SEND_STREAM_FEATURE',
95 'ZFS_ERR_EXPORT_IN_PROGRESS',
96 'ZFS_ERR_BOOKMARK_SOURCE_NOT_ANCESTOR',
97 'ZFS_ERR_STREAM_TRUNCATED',
98 'ZFS_ERR_STREAM_LARGE_BLOCK_MISMATCH',
99 'ZFS_ERR_RESILVER_IN_PROGRESS',
100 'ZFS_ERR_REBUILD_IN_PROGRESS',
101 'ZFS_ERR_BADPROP',
102 'ZFS_ERR_VDEV_NOTSUP',
103 'ZFS_ERR_NOT_USER_NAMESPACE',
104 'ZFS_ERR_RESUME_EXISTS',
105 'ZFS_ERR_CRYPTO_NOTSUP',
106 'ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS',
110 # compat before we used the enum helper for these values
111 ZFS_ERR_CHECKPOINT_EXISTS = zfs_errno.ZFS_ERR_CHECKPOINT_EXISTS
112 assert (ZFS_ERR_CHECKPOINT_EXISTS == 1024)
113 ZFS_ERR_DISCARDING_CHECKPOINT = zfs_errno.ZFS_ERR_DISCARDING_CHECKPOINT
114 ZFS_ERR_NO_CHECKPOINT = zfs_errno.ZFS_ERR_NO_CHECKPOINT
115 ZFS_ERR_DEVRM_IN_PROGRESS = zfs_errno.ZFS_ERR_DEVRM_IN_PROGRESS
116 ZFS_ERR_VDEV_TOO_BIG = zfs_errno.ZFS_ERR_VDEV_TOO_BIG
117 ZFS_ERR_WRONG_PARENT = zfs_errno.ZFS_ERR_WRONG_PARENT
118 ZFS_ERR_VDEV_NOTSUP = zfs_errno.ZFS_ERR_VDEV_NOTSUP
119 ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS = zfs_errno.ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS
121 # vim: softtabstop=4 tabstop=4 expandtab shiftwidth=4