forked from TrueCloudLab/frostfs-testlib
[#353] Added Netmap command for CliWrapper
Signed-off-by: Dmitriy Zayakin <d.zayakin@yadro.com>
This commit is contained in:
parent
ace9564243
commit
b44705eb2f
14 changed files with 770 additions and 441 deletions
|
@ -12,6 +12,7 @@ class FrostfsCliNetmap(CliCommand):
|
|||
address: Optional[str] = None,
|
||||
generate_key: bool = False,
|
||||
ttl: Optional[int] = None,
|
||||
trace: Optional[bool] = False,
|
||||
xhdr: Optional[dict] = None,
|
||||
timeout: Optional[str] = None,
|
||||
) -> CommandResult:
|
||||
|
@ -42,6 +43,7 @@ class FrostfsCliNetmap(CliCommand):
|
|||
address: Optional[str] = None,
|
||||
generate_key: bool = False,
|
||||
ttl: Optional[int] = None,
|
||||
trace: Optional[bool] = False,
|
||||
xhdr: Optional[dict] = None,
|
||||
timeout: Optional[str] = None,
|
||||
) -> CommandResult:
|
||||
|
@ -73,6 +75,7 @@ class FrostfsCliNetmap(CliCommand):
|
|||
generate_key: bool = False,
|
||||
json: bool = False,
|
||||
ttl: Optional[int] = None,
|
||||
trace: Optional[bool] = False,
|
||||
xhdr: Optional[dict] = None,
|
||||
timeout: Optional[str] = None,
|
||||
) -> CommandResult:
|
||||
|
@ -104,6 +107,7 @@ class FrostfsCliNetmap(CliCommand):
|
|||
address: Optional[str] = None,
|
||||
generate_key: bool = False,
|
||||
ttl: Optional[int] = None,
|
||||
trace: Optional[bool] = False,
|
||||
xhdr: Optional[dict] = None,
|
||||
timeout: Optional[str] = None,
|
||||
) -> CommandResult:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import re
|
||||
|
||||
from frostfs_testlib.storage.cluster import ClusterNode
|
||||
from frostfs_testlib.storage.dataclasses.storage_object_info import Interfaces, NodeNetInfo, NodeNetmapInfo, NodeStatus
|
||||
from frostfs_testlib.storage.dataclasses.storage_object_info import Interfaces, NodeInfo, NodeNetInfo, NodeNetmapInfo, NodeStatus
|
||||
|
||||
|
||||
class NetmapParser:
|
||||
|
@ -20,8 +20,6 @@ class NetmapParser:
|
|||
"withdrawal_fee": r"Withdrawal fee: (?P<withdrawal_fee>\d+)",
|
||||
"homomorphic_hashing_disabled": r"Homomorphic hashing disabled: (?P<homomorphic_hashing_disabled>true|false)",
|
||||
"maintenance_mode_allowed": r"Maintenance mode allowed: (?P<maintenance_mode_allowed>true|false)",
|
||||
"eigen_trust_alpha": r"EigenTrustAlpha: (?P<eigen_trust_alpha>\d+\w+$)",
|
||||
"eigen_trust_iterations": r"EigenTrustIterations: (?P<eigen_trust_iterations>\d+)",
|
||||
}
|
||||
parse_result = {}
|
||||
|
||||
|
@ -64,7 +62,7 @@ class NetmapParser:
|
|||
for node in netmap_nodes:
|
||||
for key, regex in regexes.items():
|
||||
search_result = re.search(regex, node, flags=re.MULTILINE)
|
||||
if search_result == None:
|
||||
if search_result is None:
|
||||
result_netmap[key] = None
|
||||
continue
|
||||
if key == "node_data_ips":
|
||||
|
@ -83,9 +81,22 @@ class NetmapParser:
|
|||
return dataclasses_netmap
|
||||
|
||||
@staticmethod
|
||||
def snapshot_one_node(output: str, cluster_node: ClusterNode) -> NodeNetmapInfo | None:
|
||||
def snapshot_one_node(output: str, rpc_endpoint: str) -> NodeNetmapInfo | None:
|
||||
snapshot_nodes = NetmapParser.snapshot_all_nodes(output=output)
|
||||
snapshot_node = [node for node in snapshot_nodes if node.node == cluster_node.get_interface(Interfaces.MGMT)]
|
||||
if not snapshot_node:
|
||||
return None
|
||||
return snapshot_node[0]
|
||||
for snapshot in snapshot_nodes:
|
||||
for endpoint in snapshot.external_address:
|
||||
if rpc_endpoint.split(":")[0] in endpoint:
|
||||
return snapshot
|
||||
|
||||
@staticmethod
|
||||
def node_info(output: dict) -> NodeNetmapInfo:
|
||||
data_dict = {"attributes": {}}
|
||||
|
||||
for key, value in output.items():
|
||||
if key != "attributes":
|
||||
data_dict[key] = value
|
||||
|
||||
for attribute in output["attributes"]:
|
||||
data_dict["attributes"][attribute["key"]] = attribute["value"]
|
||||
|
||||
return NodeInfo(**data_dict)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue