Skip to content

Commit

Permalink
Add support for starting and stopping pools
Browse files Browse the repository at this point in the history
Remove global unlock command and StratisCliAggregateError.

Add a start and stop command on pools.

Add a new global debug subcommand for refresh.

Add additional options to the pool list command for showing stopped
pools and detailed views on individual pools.

Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Jun 23, 2022
1 parent 126e0ea commit 29e4ae5
Show file tree
Hide file tree
Showing 19 changed files with 741 additions and 183 deletions.
22 changes: 15 additions & 7 deletions docs/stratis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ COMMANDS
--------
pool create [--key-desc <key_desc>] [--clevis <(nbde|tang|tpm2)> [--tang-url <tang_url>] [<(--thumbprint <thp> | --trust-url)>] [--no-overprovision] <pool_name> <blockdev> [<blockdev>..]::
Create a pool from one or more block devices, with the given pool name.
pool list::
List all pools on the system.
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 [--stopped] [--uuid <uuid>]::
List pools. If the --stopped option is used, list only stopped pools.
Otherwise, list only started pools. If a UUID is specified, print
more detailed information about the pool corresponding to that UUID.
pool rename <old_pool_name> <new_pool_name>::
Rename a pool.
pool destroy <pool_name>::
Expand All @@ -54,10 +61,6 @@ pool init-cache <pool_name> <blockdev> [<blockdev>..]::
drives, such as SSDs, are used for this purpose.
pool add-cache <pool_name> <blockdev> [<blockdev>..]::
Add one or more blockdevs to an existing pool with an initialized cache.
pool unlock <(keyring | clevis)>::
Unlock all devices that are part of an encrypted pool registered with stratisd
but that have not yet been opened. The available unlock methods are
*keyring* or *clevis*.
pool bind <(nbde|tang)> <pool name> <url> <(--thumbprint <thp> | --trust-url)>::
Bind the devices in the specified pool to a supplementary encryption
mechanism that uses NBDE (Network-Bound Disc Encryption). *tang* is
Expand Down Expand Up @@ -129,7 +132,12 @@ report <report_name>::
Any other report name should be considered unstable and may be removed
in a future release. The JSON schema of any report must always be considered unstable.
daemon version::
Show the Stratis service's version.
Show the Stratis service's version.
debug refresh::
For all pools that are not stopped, rebuild their storage stacks from
the pool-level metadata stored on each pool's devices. This is not a
standard administrative command; it is intended for trouble-shooting
and repair only.

OPTIONS
-------
Expand Down
11 changes: 3 additions & 8 deletions shell-completion/bash/stratis
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ _stratis() {
opts="-h --help"
global_opts="--version --propagate ${opts} --unhyphenated-uuids"
root_subcommands="daemon pool blockdev filesystem key report"
pool_subcommands="add-cache add-data bind create destroy init-cache list rename unbind unlock"
pool_subcommands="add-cache add-data bind create destroy init-cache list rename unbind"
pool_create_opts="--key-desc"
pool_bind_opts="--thumbprint --trust-url"
pool_bind_subcommands="nbde tang tpm2"
pool_unlock_subcommands="clevis keyring"
fs_subcommands="create snapshot list rename destroy"
fs_create_opts="--size"
blockdev_subcommands="list"
Expand Down Expand Up @@ -154,10 +153,6 @@ _stratis() {
;;
pool)
case ${subcommand} in
unlock)
COMPREPLY=($(compgen -W "${pool_unlock_subcommands}" -- ${cur}))
return 0
;;
bind)
COMPREPLY=($(compgen -W "${pool_bind_subcommands}" -- ${cur}))
return 0
Expand Down Expand Up @@ -201,7 +196,7 @@ _stratis() {
;;
pool)
case ${subcommand} in
list | rename | destroy | unbind | unlock)
list | rename | destroy | unbind)
return 0
;;
create | add-data | add-cache | init-cache)
Expand Down Expand Up @@ -252,7 +247,7 @@ _stratis() {
;;
pool)
case ${subcommand} in
list | rename | destroy | bind | unbind | unlock)
list | rename | destroy | bind | unbind)
return 0
;;
create | add-cache | add-data | init-cache)
Expand Down
7 changes: 6 additions & 1 deletion src/stratis_cli/_actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@

from ._bind import BindActions, RebindActions
from ._constants import BLOCKDEV_INTERFACE, FILESYSTEM_INTERFACE, POOL_INTERFACE
from ._debug import BlockdevDebugActions, FilesystemDebugActions, PoolDebugActions
from ._debug import (
BlockdevDebugActions,
FilesystemDebugActions,
PoolDebugActions,
TopDebugActions,
)
from ._logical import LogicalActions
from ._physical import PhysicalActions
from ._pool import PoolActions
Expand Down
21 changes: 21 additions & 0 deletions src/stratis_cli/_actions/_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,31 @@
"""


from .._errors import StratisCliEngineError
from .._stratisd_constants import StratisdErrors
from ._connection import get_object
from ._constants import TOP_OBJECT


class TopDebugActions: # pylint: disable=too-few-public-methods
"""
Top level object debug actions.
"""

@staticmethod
def refresh_state(_namespace):
"""
Refresh pools from their metadata up.
"""
from ._data import Manager # pylint: disable=import-outside-toplevel

(return_code, message) = Manager.Methods.RefreshState(
get_object(TOP_OBJECT), {}
)
if return_code != StratisdErrors.OK: # pragma: no cover
raise StratisCliEngineError(return_code, message)


class PoolDebugActions: # pylint: disable=too-few-public-methods
"""
Pool debug actions.
Expand Down
18 changes: 14 additions & 4 deletions src/stratis_cli/_actions/_introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,27 @@
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="RefreshState">
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="SetKey">
<arg name="key_desc" type="s" direction="in" />
<arg name="key_fd" type="h" direction="in" />
<arg name="result" type="(bb)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="UnlockPool">
<method name="StartPool">
<arg name="pool_uuid" type="s" direction="in" />
<arg name="unlock_method" type="s" direction="in" />
<arg name="result" type="(bas)" direction="out" />
<arg name="unlock_method" type="(bs)" direction="in" />
<arg name="result" type="(b(oaoao))" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="StopPool">
<arg name="pool" type="o" direction="in" />
<arg name="result" type="(bs)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
Expand All @@ -54,7 +64,7 @@
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<property name="LockedPools" type="a{sa{sv}}" access="read" />
<property name="StoppedPools" type="a{sa{sv}}" access="read" />
<property name="Version" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
Expand Down
Loading

0 comments on commit 29e4ae5

Please sign in to comment.