Skip to content

Commit 90c0772

Browse files
committed
Reapply "Reapply "Remove "pool encryption" subcommand""
This reverts commit 31cd3a7.
1 parent 975431c commit 90c0772

6 files changed

Lines changed: 14 additions & 728 deletions

File tree

src/stratis_cli/_actions/_bind.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,9 @@
2828

2929
def _get_pool_id(namespace: Namespace) -> PoolId:
3030
"""
31-
Get id for pool, regardless of whether parser uses mandatory pool_name
32-
argument or --name/--uuid alternative.
33-
3431
:return: Id representing how to lookup the pool
3532
"""
36-
name = getattr(namespace, "pool_name", None)
37-
if name is None:
38-
result = PoolId.from_parser_namespace(namespace)
39-
assert result is not None
40-
return result
41-
42-
return PoolId(IdType.NAME, name)
33+
return PoolId(IdType.NAME, namespace.pool_name)
4334

4435

4536
class BindActions:

src/stratis_cli/_parser/_encryption.py

Lines changed: 1 addition & 238 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
from argparse import SUPPRESS, Namespace
2121

2222
from .._actions import BindActions, RebindActions
23-
from .._constants import Clevis, EncryptionMethod
23+
from .._constants import Clevis
2424
from ._shared import (
2525
TRUST_URL_OR_THUMBPRINT,
26-
UUID_OR_NAME,
2726
ClevisEncryptionOptions,
28-
MoveNotice,
2927
RejectAction,
3028
ensure_nat,
3129
)
@@ -88,9 +86,6 @@ def __init__(self, namespace: Namespace):
8886
)
8987
],
9088
"aliases": [str(Clevis.TANG)],
91-
"epilog": str(
92-
MoveNotice("nbde", "pool bind", "pool encryption bind", "3.10.0")
93-
),
9489
"func": BindActions.bind_clevis,
9590
},
9691
),
@@ -110,9 +105,6 @@ def __init__(self, namespace: Namespace):
110105
),
111106
("pool_name", {"help": "Pool name"}),
112107
],
113-
"epilog": str(
114-
MoveNotice("tpm2", "pool bind", "pool encryption bind", "3.10.0")
115-
),
116108
"func": BindActions.bind_clevis,
117109
},
118110
),
@@ -124,9 +116,6 @@ def __init__(self, namespace: Namespace):
124116
("pool_name", {"help": "Pool name"}),
125117
("keydesc", {"help": "key description"}),
126118
],
127-
"epilog": str(
128-
MoveNotice("keyring", "pool bind", "pool encryption bind", "3.10.0")
129-
),
130119
"func": BindActions.bind_keyring,
131120
},
132121
),
@@ -153,9 +142,6 @@ def __init__(self, namespace: Namespace):
153142
},
154143
),
155144
],
156-
"epilog": str(
157-
MoveNotice("clevis", "pool rebind", "pool encryption rebind", "3.10.0")
158-
),
159145
"func": RebindActions.rebind_clevis,
160146
},
161147
),
@@ -181,230 +167,7 @@ def __init__(self, namespace: Namespace):
181167
},
182168
),
183169
],
184-
"epilog": str(
185-
MoveNotice("keyring", "pool rebind", "pool encryption rebind", "3.10.0")
186-
),
187-
"func": RebindActions.rebind_keyring,
188-
},
189-
),
190-
]
191-
192-
BIND_SUBCMDS_ENCRYPTION = [
193-
(
194-
str(Clevis.NBDE),
195-
{
196-
"help": "Bind using NBDE via a tang server",
197-
"args": [
198-
(
199-
"--post-parser",
200-
{
201-
"action": RejectAction,
202-
"default": ClevisEncryptionOptionsForTang,
203-
"help": SUPPRESS,
204-
"nargs": "?",
205-
},
206-
),
207-
("url", {"help": "URL of tang server"}),
208-
],
209-
"groups": [
210-
(
211-
"Pool Identifier",
212-
{
213-
"description": "Choose one option to specify the pool to bind",
214-
"mut_ex_args": [
215-
(True, UUID_OR_NAME),
216-
],
217-
},
218-
),
219-
(
220-
"Tang Server Verification",
221-
{
222-
"description": "Choose one option",
223-
"mut_ex_args": [(True, TRUST_URL_OR_THUMBPRINT)],
224-
},
225-
),
226-
],
227-
"aliases": [str(Clevis.TANG)],
228-
"func": BindActions.bind_clevis,
229-
},
230-
),
231-
(
232-
str(Clevis.TPM2),
233-
{
234-
"help": "Bind using TPM2",
235-
"args": [
236-
(
237-
"--post-parser",
238-
{
239-
"action": RejectAction,
240-
"default": ClevisEncryptionOptionsForTpm2,
241-
"help": SUPPRESS,
242-
"nargs": "?",
243-
},
244-
),
245-
],
246-
"groups": [
247-
(
248-
"Pool Identifier",
249-
{
250-
"description": "Choose one option to specify the pool to bind",
251-
"mut_ex_args": [
252-
(True, UUID_OR_NAME),
253-
],
254-
},
255-
)
256-
],
257-
"func": BindActions.bind_clevis,
258-
},
259-
),
260-
(
261-
"keyring",
262-
{
263-
"help": "Bind using the kernel keyring",
264-
"groups": [
265-
(
266-
"Pool Identifier",
267-
{
268-
"description": "Choose one option to specify the pool to bind",
269-
"mut_ex_args": [
270-
(True, UUID_OR_NAME),
271-
],
272-
},
273-
)
274-
],
275-
"args": [
276-
("keydesc", {"help": "key description"}),
277-
],
278-
"func": BindActions.bind_keyring,
279-
},
280-
),
281-
]
282-
283-
REBIND_SUBCMDS_ENCRYPTION = [
284-
(
285-
"clevis",
286-
{
287-
"help": (
288-
"Rebind the specified pool using the current Clevis configuration"
289-
),
290-
"groups": [
291-
(
292-
"Pool Identifier",
293-
{
294-
"description": "Choose one option to specify the pool to rebind",
295-
"mut_ex_args": [
296-
(True, UUID_OR_NAME),
297-
],
298-
},
299-
)
300-
],
301-
"args": [
302-
(
303-
"--token-slot",
304-
{
305-
"help": (
306-
"token slot; may be specified if there is more "
307-
"than one binding with the specified method; for "
308-
"V2 pools only"
309-
),
310-
"type": ensure_nat,
311-
},
312-
),
313-
],
314-
"func": RebindActions.rebind_clevis,
315-
},
316-
),
317-
(
318-
"keyring",
319-
{
320-
"help": (
321-
"Rebind the specified pool using the specified key in the "
322-
"kernel keyring"
323-
),
324-
"groups": [
325-
(
326-
"Pool Identifier",
327-
{
328-
"description": "Choose one option to specify the pool to rebind",
329-
"mut_ex_args": [
330-
(True, UUID_OR_NAME),
331-
],
332-
},
333-
)
334-
],
335-
"args": [
336-
("keydesc", {"help": "key description"}),
337-
(
338-
"--token-slot",
339-
{
340-
"help": (
341-
"token slot; may be specified if there is more "
342-
"than one binding with the specified method; for "
343-
"V2 pools only"
344-
),
345-
"type": ensure_nat,
346-
},
347-
),
348-
],
349170
"func": RebindActions.rebind_keyring,
350171
},
351172
),
352173
]
353-
354-
ENCRYPTION_SUBCMDS = [
355-
(
356-
"bind",
357-
{
358-
"help": "Bind the given pool with an additional encryption facility",
359-
"subcmds": BIND_SUBCMDS_ENCRYPTION,
360-
},
361-
),
362-
(
363-
"rebind",
364-
{
365-
"help": (
366-
"Rebind the given pool with a currently in use encryption "
367-
"facility but new credentials"
368-
),
369-
"subcmds": REBIND_SUBCMDS_ENCRYPTION,
370-
},
371-
),
372-
(
373-
"unbind",
374-
{
375-
"help": "Unbind the given pool, removing use of the specified encryption method",
376-
"groups": [
377-
(
378-
"Pool Identifier",
379-
{
380-
"description": "Choose one option to specify the pool to unbind",
381-
"mut_ex_args": [
382-
(True, UUID_OR_NAME),
383-
],
384-
},
385-
)
386-
],
387-
"args": [
388-
(
389-
"method",
390-
{
391-
"choices": list(EncryptionMethod),
392-
"help": "Encryption method to unbind",
393-
"type": EncryptionMethod,
394-
},
395-
),
396-
(
397-
"--token-slot",
398-
{
399-
"help": (
400-
"token slot; must be specified if there is more "
401-
"than one binding with the specified method"
402-
),
403-
"type": ensure_nat,
404-
},
405-
),
406-
],
407-
"func": BindActions.unbind,
408-
},
409-
),
410-
]

src/stratis_cli/_parser/_parser.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,12 @@ def add_subcommand(subparser, cmd):
118118
Add subcommand to a parser based on a subcommand dict.
119119
"""
120120
name, info = cmd
121-
help_text = info.get("help")
122121

123-
if help_text is None:
124-
parser = subparser.add_parser(
125-
name, aliases=info.get("aliases", []), epilog=info.get("epilog")
126-
)
127-
else:
128-
parser = subparser.add_parser(
129-
name,
130-
help=help_text,
131-
aliases=info.get("aliases", []),
132-
epilog=info.get("epilog"),
133-
)
122+
parser = subparser.add_parser(
123+
name,
124+
help=info["help"],
125+
aliases=info.get("aliases", []),
126+
)
134127

135128
subcmds = info.get("subcmds")
136129
if subcmds is not None:

src/stratis_cli/_parser/_pool.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@
3434
YesOrNo,
3535
)
3636
from ._debug import POOL_DEBUG_SUBCMDS
37-
from ._encryption import BIND_SUBCMDS, ENCRYPTION_SUBCMDS, REBIND_SUBCMDS
37+
from ._encryption import BIND_SUBCMDS, REBIND_SUBCMDS
3838
from ._shared import (
3939
KEYFILE_PATH_OR_STDIN,
4040
TRUST_URL_OR_THUMBPRINT,
4141
UUID_OR_NAME,
4242
ClevisEncryptionOptions,
4343
DefaultAction,
44-
MoveNotice,
4544
RejectAction,
4645
ensure_nat,
4746
parse_range,
@@ -390,14 +389,6 @@ def verify(self, namespace: Namespace, parser: ArgumentParser):
390389
"func": PoolActions.rename_pool,
391390
},
392391
),
393-
(
394-
"encryption",
395-
{
396-
"help": "Manage pool encryption operations",
397-
"aliases": ["crypt"],
398-
"subcmds": ENCRYPTION_SUBCMDS,
399-
},
400-
),
401392
(
402393
"init-cache",
403394
{
@@ -488,20 +479,24 @@ def verify(self, namespace: Namespace, parser: ArgumentParser):
488479
(
489480
"bind",
490481
{
491-
"epilog": str(MoveNotice("bind", "pool", "pool encryption", "3.10.0")),
482+
"help": "Bind the given pool with an additional encryption facility",
492483
"subcmds": BIND_SUBCMDS,
493484
},
494485
),
495486
(
496487
"rebind",
497488
{
498-
"epilog": str(MoveNotice("rebind", "pool", "pool encryption", "3.10.0")),
489+
"help": (
490+
"Rebind the given pool with a currently in use encryption "
491+
"facility but new credentials"
492+
),
499493
"subcmds": REBIND_SUBCMDS,
500494
},
501495
),
502496
(
503497
"unbind",
504498
{
499+
"help": "Unbind the given pool, removing use of the specified encryption method",
505500
"args": [
506501
(
507502
"method",
@@ -523,7 +518,6 @@ def verify(self, namespace: Namespace, parser: ArgumentParser):
523518
},
524519
),
525520
],
526-
"epilog": str(MoveNotice("unbind", "pool", "pool encryption", "3.10.0")),
527521
"func": BindActions.unbind,
528522
},
529523
),

0 commit comments

Comments
 (0)