Skip to content

Commit

Permalink
Add ability to start pools
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Apr 28, 2022
1 parent 95e50c1 commit 384a195
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/stratis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ pool create [--key-desc <key_desc>] [--clevis <(nbde|tang|tpm2)> [--tang-url <ta
Create a pool from one or more block devices, with the given pool name.
pool stop <pool_name>::
Stop a pool. Tear down the storage stack but leave all metadata intact.
pool start <pool_uuid> --unlock-method <(keyring | clevis)>::
Start a pool. Use --unlock-method option to specify method of unlocking
the pool if it is encrypted.
pool list::
List all pools on the system.
pool list-stopped --uuid <uuid>::
Expand Down
29 changes: 29 additions & 0 deletions src/stratis_cli/_actions/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,35 @@ def stop_pool(namespace):
% pool_name
)

@staticmethod
def start_pool(namespace):
"""
Start a pool.
:raises StratisCliIncoherenceError:
:raises StratisCliEngineError:
"""
# pylint: disable=import-outside-toplevel
from ._data import Manager

proxy = get_object(TOP_OBJECT)

((started, _), return_code, message) = Manager.Methods.StartPool(
proxy,
{
"pool_uuid": str(namespace.pool_uuid),
"unlock_method": (False, "")
if namespace.unlock_method is None
else (True, namespace.unlock_method),
},
)

if return_code != StratisdErrors.OK:
raise StratisCliEngineError(return_code, message)

if not started:
raise StratisCliNoChangeError("start", namespace.pool_uuid)

@staticmethod
def init_cache(namespace): # pylint: disable=too-many-locals
"""
Expand Down
27 changes: 27 additions & 0 deletions src/stratis_cli/_parser/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,33 @@ def _ensure_nat(arg):
func=PoolActions.stop_pool,
),
),
(
"start",
dict(
help="Start a pool.",
args=[
(
"pool_uuid",
dict(
action="store",
type=UUID,
help="UUID of the pool to start",
),
),
(
"--unlock-method",
dict(
default=None,
dest="unlock_method",
action="store",
choices=[str(x) for x in list(EncryptionMethod)],
help="Method to use to unlock the pool if encrypted.",
),
),
],
func=PoolActions.start_pool,
),
),
(
"init-cache",
dict(
Expand Down

0 comments on commit 384a195

Please sign in to comment.