[#330] Switch to new command netmap snapshot

1. Add netmap command to NeofsCli wrapper.
2. Update node_management steps to use netmap.snapshot method instead of
   deprecated "neofs-cli control netmap-snapshot" command.
3. Switch node's public key in netmap from base58-encoding to hex-encoding.

Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
Vladimir Domnich 2022-09-28 13:53:08 +04:00 committed by Vladimir
parent 2a175b5824
commit 26032a67ec
4 changed files with 181 additions and 97 deletions

View file

@ -1,5 +1,6 @@
from typing import Optional
from cli_utils.cli.netmap import NeofsCliNetmap
from common import NEOFS_CLI_EXEC
from .accounting import NeofsCliAccounting
@ -10,19 +11,23 @@ from .version import NeofsCliVersion
class NeofsCli:
neofs_cli_exec_path: Optional[str] = None
config: Optional[str] = None
accounting: Optional[NeofsCliAccounting] = None
acl: Optional[NeofsCliACL] = None
container: Optional[NeofsCliContainer] = None
object: Optional[NeofsCliObject] = None
version: Optional[NeofsCliVersion] = None
accounting: NeofsCliAccounting
acl: NeofsCliACL
container: NeofsCliContainer
netmap: NeofsCliNetmap
object: NeofsCliObject
version: NeofsCliVersion
def __init__(self, neofs_cli_exec_path: Optional[str] = None, config: Optional[str] = None, timeout: int = 30):
self.config = config # config(str): config file (default is $HOME/.config/neofs-cli/config.yaml)
self.neofs_cli_exec_path = neofs_cli_exec_path or NEOFS_CLI_EXEC
self.accounting = NeofsCliAccounting(self.neofs_cli_exec_path, timeout=timeout, config=config)
self.acl = NeofsCliACL(self.neofs_cli_exec_path, timeout=timeout, config=config)
self.container = NeofsCliContainer(self.neofs_cli_exec_path, timeout=timeout, config=config)
self.object = NeofsCliObject(self.neofs_cli_exec_path, timeout=timeout, config=config)
self.version = NeofsCliVersion(self.neofs_cli_exec_path, timeout=timeout, config=config)
def __init__(
self,
neofs_cli_exec_path: Optional[str] = None,
config: Optional[str] = None,
timeout: int = 30,
):
neofs_cli_exec_path = neofs_cli_exec_path or NEOFS_CLI_EXEC
self.accounting = NeofsCliAccounting(neofs_cli_exec_path, timeout=timeout, config=config)
self.acl = NeofsCliACL(neofs_cli_exec_path, timeout=timeout, config=config)
self.container = NeofsCliContainer(neofs_cli_exec_path, timeout=timeout, config=config)
self.netmap = NeofsCliNetmap(neofs_cli_exec_path, timeout=timeout, config=config)
self.object = NeofsCliObject(neofs_cli_exec_path, timeout=timeout, config=config)
self.version = NeofsCliVersion(neofs_cli_exec_path, timeout=timeout, config=config)

View file

@ -0,0 +1,119 @@
from typing import Optional
from cli_utils.cli_command import NeofsCliCommand
class NeofsCliNetmap(NeofsCliCommand):
def epoch(
self,
rpc_endpoint: str,
wallet: str,
address: Optional[str] = None,
generate_key: bool = False,
ttl: Optional[int] = None,
xhdr: Optional[dict] = None,
) -> str:
"""
Get current epoch number.
Args:
address: address of wallet account
generate_key: generate new private key
rpc_endpoint: remote node address (as 'multiaddr' or '<host>:<port>')
ttl: TTL value in request meta header (default 2)
wallet: path to the wallet or binary key
xhdr: request X-Headers in form of Key=Value
Returns:
str: Raw command output
"""
return self._execute(
"netmap epoch",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def netinfo(
self,
rpc_endpoint: str,
wallet: str,
address: Optional[str] = None,
generate_key: bool = False,
ttl: Optional[int] = None,
xhdr: Optional[dict] = None,
) -> str:
"""
Get information about NeoFS network.
Args:
address: address of wallet account
generate_key: generate new private key
rpc_endpoint: remote node address (as 'multiaddr' or '<host>:<port>')
ttl: TTL value in request meta header (default 2)
wallet: path to the wallet or binary key
xhdr: request X-Headers in form of Key=Value
Returns:
str: Raw command output
"""
return self._execute(
"netmap netinfo",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def nodeinfo(
self,
rpc_endpoint: str,
wallet: str,
address: Optional[str] = None,
generate_key: bool = False,
json: bool = False,
ttl: Optional[int] = None,
xhdr: Optional[dict] = None,
) -> str:
"""
Get target node info.
Args:
address: address of wallet account
generate_key: generate new private key
json: print node info in JSON format
rpc_endpoint: remote node address (as 'multiaddr' or '<host>:<port>')
ttl: TTL value in request meta header (default 2)
wallet: path to the wallet or binary key
xhdr: request X-Headers in form of Key=Value
Returns:
str: Raw command output
"""
return self._execute(
"netmap nodeinfo",
**{param: value for param, value in locals().items() if param not in ["self"]},
)
def snapshot(
self,
rpc_endpoint: str,
wallet: str,
address: Optional[str] = None,
generate_key: bool = False,
ttl: Optional[int] = None,
xhdr: Optional[dict] = None,
) -> str:
"""
Request current local snapshot of the network map.
Args:
address: address of wallet account
generate_key: generate new private key
rpc_endpoint: remote node address (as 'multiaddr' or '<host>:<port>')
ttl: TTL value in request meta header (default 2)
wallet: path to the wallet or binary key
xhdr: request X-Headers in form of Key=Value
Returns:
str: Raw command output
"""
return self._execute(
"netmap snapshot",
**{param: value for param, value in locals().items() if param not in ["self"]},
)