Skip to content

Commit

Permalink
Use integrity tag spec not size
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Dec 17, 2024
1 parent 5ede34b commit 1f395ae
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/stratis_cli/_actions/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ def create_pool(namespace): # pylint: disable=too-many-locals
if namespace.journal_size is None
else (True, namespace.journal_size.magnitude.numerator)
),
"tag_size": (
"tag_spec": (
(False, 0)
if namespace.tag_size is None
else (True, namespace.tag_size.magnitude.numerator)
if namespace.tag_spec is None
else (True, namespace.tag_spec)
),
},
)
Expand Down
13 changes: 13 additions & 0 deletions src/stratis_cli/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,16 @@ class Clevis(Enum):

def __str__(self):
return self.value


class IntegrityTagSpec(Enum):
"""
Options for specifying integrity tag size.
"""

B0 = "0b"
B32 = "32b"
B512 = "512b"

def __str__(self):
return self.value
25 changes: 17 additions & 8 deletions src/stratis_cli/_parser/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@
from uuid import UUID

from .._actions import BindActions, PoolActions
from .._constants import Clevis, EncryptionMethod, UnlockMethod, YesOrNo
from .._constants import (
Clevis,
EncryptionMethod,
IntegrityTagSpec,
UnlockMethod,
YesOrNo,
)
from .._error_codes import PoolErrorCode
from ._bind import BIND_SUBCMDS, REBIND_SUBCMDS
from ._debug import POOL_DEBUG_SUBCMDS
from ._range import RejectAction, parse_bytes_range, parse_range
from ._range import RejectAction, parse_range


class ClevisEncryptionOptions: # pylint: disable=too-few-public-methods
Expand Down Expand Up @@ -186,15 +192,18 @@ def _ensure_nat(arg):
},
),
(
"--tag-size",
"--tag-spec",
{
"help": (
"Size of tag to use to verify "
"correctness of 4KiB block, e.g, 64B. "
"Must be a power of 2 and less than "
"128B."
"Integrity tag specification defining "
"the size of the tag used to store a "
"checksum or other value for each "
"block on a device. stratisd chooses "
"a default specification if none is "
"given."
),
"type": parse_bytes_range,
"choices": list(IntegrityTagSpec),
"type": IntegrityTagSpec,
},
),
],
Expand Down
7 changes: 0 additions & 7 deletions src/stratis_cli/_parser/_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ def parse_range(values, *, bound=None):
return result


def parse_bytes_range(values):
"""
Parse a range that must be less than 256B.
"""
return parse_range(values, bound=Range(256))


class RejectAction(argparse.Action):
"""
Just reject any use of the option.
Expand Down

0 comments on commit 1f395ae

Please sign in to comment.