2022-12-05 20:14:17 +00:00
|
|
|
from typing import Optional
|
|
|
|
|
2023-01-10 13:02:24 +00:00
|
|
|
from frostfs_testlib.cli.cli_command import CliCommand
|
|
|
|
from frostfs_testlib.shell import CommandResult
|
2022-12-05 20:14:17 +00:00
|
|
|
|
|
|
|
|
2023-01-10 13:02:24 +00:00
|
|
|
class FrostfsCliShards(CliCommand):
|
2022-12-05 20:14:17 +00:00
|
|
|
def flush_cache(
|
|
|
|
self,
|
|
|
|
endpoint: str,
|
|
|
|
wallet: str,
|
|
|
|
wallet_password: str,
|
|
|
|
id: Optional[list[str]],
|
|
|
|
address: Optional[str] = None,
|
|
|
|
all: bool = False,
|
2023-03-09 11:25:39 +00:00
|
|
|
timeout: Optional[str] = None,
|
2022-12-05 20:14:17 +00:00
|
|
|
) -> CommandResult:
|
|
|
|
"""
|
|
|
|
Flush objects from the write-cache to the main storage.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
address: Address of wallet account.
|
|
|
|
id: List of shard IDs in base58 encoding.
|
|
|
|
all: Process all shards.
|
|
|
|
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
|
|
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
|
|
|
wallet_password: Wallet password.
|
2023-03-09 11:25:39 +00:00
|
|
|
timeout: Timeout for an operation (default 15s).
|
2022-12-05 20:14:17 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
Command's result.
|
|
|
|
"""
|
|
|
|
return self._execute_with_password(
|
|
|
|
f"control shards flush-cache",
|
|
|
|
wallet_password,
|
|
|
|
**{param: value for param, value in locals().items() if param not in ["self"]},
|
|
|
|
)
|
|
|
|
|
|
|
|
def set_mode(
|
|
|
|
self,
|
|
|
|
endpoint: str,
|
|
|
|
mode: str,
|
|
|
|
id: Optional[list[str]],
|
2024-02-19 10:01:29 +00:00
|
|
|
wallet: Optional[str] = None,
|
|
|
|
wallet_password: Optional[str] = None,
|
2022-12-05 20:14:17 +00:00
|
|
|
address: Optional[str] = None,
|
|
|
|
all: bool = False,
|
|
|
|
clear_errors: bool = False,
|
2023-03-09 11:25:39 +00:00
|
|
|
timeout: Optional[str] = None,
|
2022-12-05 20:14:17 +00:00
|
|
|
) -> CommandResult:
|
|
|
|
"""
|
|
|
|
Set work mode of the shard.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
address: Address of wallet account.
|
|
|
|
id: List of shard IDs in base58 encoding.
|
|
|
|
mode: New shard mode ('degraded-read-only', 'read-only', 'read-write').
|
|
|
|
all: Process all shards.
|
|
|
|
clear_errors: Set shard error count to 0.
|
|
|
|
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
|
|
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
|
|
|
wallet_password: Wallet password.
|
2023-03-09 11:25:39 +00:00
|
|
|
timeout: Timeout for an operation (default 15s).
|
2022-12-05 20:14:17 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
Command's result.
|
|
|
|
"""
|
2024-02-19 10:01:29 +00:00
|
|
|
if not wallet_password:
|
|
|
|
return self._execute(
|
|
|
|
"control shards set-mode",
|
|
|
|
**{param: value for param, value in locals().items() if param not in ["self"]},
|
|
|
|
)
|
2022-12-05 20:14:17 +00:00
|
|
|
return self._execute_with_password(
|
2023-03-09 11:25:39 +00:00
|
|
|
"control shards set-mode",
|
2022-12-05 20:14:17 +00:00
|
|
|
wallet_password,
|
2024-01-11 11:51:07 +00:00
|
|
|
**{param: value for param, value in locals().items() if param not in ["self", "wallet_password"]},
|
2022-12-05 20:14:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def dump(
|
|
|
|
self,
|
|
|
|
endpoint: str,
|
|
|
|
wallet: str,
|
|
|
|
wallet_password: str,
|
|
|
|
id: str,
|
|
|
|
path: str,
|
|
|
|
address: Optional[str] = None,
|
|
|
|
no_errors: bool = False,
|
2023-03-09 11:25:39 +00:00
|
|
|
timeout: Optional[str] = None,
|
2022-12-05 20:14:17 +00:00
|
|
|
) -> CommandResult:
|
|
|
|
"""
|
|
|
|
Dump objects from shard to a file.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
address: Address of wallet account.
|
|
|
|
no_errors: Skip invalid/unreadable objects.
|
|
|
|
id: Shard ID in base58 encoding.
|
|
|
|
path: File to write objects to.
|
|
|
|
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
|
|
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
|
|
|
wallet_password: Wallet password.
|
2023-03-09 11:25:39 +00:00
|
|
|
timeout: Timeout for an operation (default 15s).
|
2022-12-05 20:14:17 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
Command's result.
|
|
|
|
"""
|
|
|
|
return self._execute_with_password(
|
2023-03-09 11:25:39 +00:00
|
|
|
"control shards dump",
|
2022-12-05 20:14:17 +00:00
|
|
|
wallet_password,
|
2024-01-11 11:51:07 +00:00
|
|
|
**{param: value for param, value in locals().items() if param not in ["self", "wallet_password"]},
|
2022-12-05 20:14:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def list(
|
|
|
|
self,
|
|
|
|
endpoint: str,
|
2024-01-11 11:51:07 +00:00
|
|
|
wallet: Optional[str] = None,
|
|
|
|
wallet_password: Optional[str] = None,
|
2022-12-05 20:14:17 +00:00
|
|
|
address: Optional[str] = None,
|
2023-06-02 10:03:28 +00:00
|
|
|
json_mode: bool = False,
|
2023-03-09 11:25:39 +00:00
|
|
|
timeout: Optional[str] = None,
|
2022-12-05 20:14:17 +00:00
|
|
|
) -> CommandResult:
|
|
|
|
"""
|
|
|
|
List shards of the storage node.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
address: Address of wallet account.
|
2023-06-02 10:03:28 +00:00
|
|
|
json_mode: Print shard info as a JSON array.
|
2022-12-05 20:14:17 +00:00
|
|
|
endpoint: Remote node address (as 'multiaddr' or '<host>:<port>').
|
|
|
|
wallet: WIF (NEP-2) string or path to the wallet or binary key.
|
|
|
|
wallet_password: Wallet password.
|
2023-03-09 11:25:39 +00:00
|
|
|
timeout: Timeout for an operation (default 15s).
|
2022-12-05 20:14:17 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
Command's result.
|
|
|
|
"""
|
2024-01-11 11:51:07 +00:00
|
|
|
if not wallet_password:
|
|
|
|
return self._execute(
|
|
|
|
"control shards list",
|
|
|
|
**{param: value for param, value in locals().items() if param not in ["self"]},
|
|
|
|
)
|
2022-12-05 20:14:17 +00:00
|
|
|
return self._execute_with_password(
|
2023-03-09 11:25:39 +00:00
|
|
|
"control shards list",
|
2022-12-05 20:14:17 +00:00
|
|
|
wallet_password,
|
2024-01-11 11:51:07 +00:00
|
|
|
**{param: value for param, value in locals().items() if param not in ["self", "wallet_password"]},
|
2022-12-05 20:14:17 +00:00
|
|
|
)
|
2024-02-19 10:01:29 +00:00
|
|
|
|