From 69b3061a90d3198ff41834d7db923aae5081c3c5 Mon Sep 17 00:00:00 2001 From: Vladimir Domnich Date: Fri, 15 Jul 2022 09:35:57 +0400 Subject: [PATCH] Fix call to storage node control endpoint with overriding storage wallet path. --- Makefile | 4 ++++ robot/resources/lib/python_keywords/node_management.py | 9 ++++++++- robot/variables/common.py | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c64e577e..d89bd0a2 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,8 @@ setup-for-remote-devenv: # env: files inside storage node to make calls via SSH on that node echo STORAGE_NODE_BIN_PATH="$(DEV_ENV_DEPLOY_DIR)/vendor" >> .env echo STORAGE_NODE_CONFIG_PATH="$(DEV_ENV_DEPLOY_DIR)/services/storage/cli-cfg.yml" >> .env + echo STORAGE_NODE_WALLET_PATH="$(DEV_ENV_DEPLOY_DIR)/services/storage/wallet01.json" >> .env + echo STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT="s01.neofs.devenv:8081" >> .env # env: s3 gateway public key ssh root@$(DEV_ENV_HOST_NAME) 'cd $(DEV_ENV_DEPLOY_DIR) && make env | grep NEOFS_IR_CONTRACTS_NEOFS' >> .env @@ -115,6 +117,8 @@ setup-for-sbercloud: # env: files inside storage node to make calls via SSH on that node echo STORAGE_NODE_BIN_PATH="/usr/local/bin/" >> .env echo STORAGE_NODE_CONFIG_PATH="/tmp/conf.yaml" >> .env + echo STORAGE_NODE_WALLET_PATH="/etc/neofs/storage/wallet.json" >> .env + echo STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT="localhost:8091" >> .env # env: s3 gateway public key echo S3_GATE_PUB_KEY=$(shell $(NEO_BIN_DIR)/neo-go wallet dump-keys -w $(CONFIG_DIR)/wallets/node1-s3.json | head -2 | tail -1) >> .env diff --git a/robot/resources/lib/python_keywords/node_management.py b/robot/resources/lib/python_keywords/node_management.py index d8ad59d0..a832c693 100644 --- a/robot/resources/lib/python_keywords/node_management.py +++ b/robot/resources/lib/python_keywords/node_management.py @@ -14,7 +14,8 @@ from typing import List import docker from common import (NEOFS_NETMAP_DICT, STORAGE_NODE_BIN_PATH, STORAGE_NODE_CONFIG_PATH, STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT, STORAGE_NODE_SSH_PASSWORD, - STORAGE_NODE_SSH_PRIVATE_KEY_PATH, STORAGE_NODE_SSH_USER) + STORAGE_NODE_SSH_PRIVATE_KEY_PATH, STORAGE_NODE_SSH_USER, + STORAGE_NODE_WALLET_PATH) from robot.api import logger from robot.api.deco import keyword from ssh_helper import HostClient, HostIsNotAvailable @@ -172,6 +173,7 @@ def node_healthcheck(node_name: str) -> HealthStatus: with create_ssh_client(node_name) as ssh_client: cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control healthcheck ' \ f'--endpoint {STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT} ' \ + f'{"-w " + STORAGE_NODE_WALLET_PATH if STORAGE_NODE_WALLET_PATH else ""} ' \ f'--config {STORAGE_NODE_CONFIG_PATH}' output = ssh_client.exec_with_confirmation(cmd, ['']) return HealthStatus.from_stdout(output.stdout) @@ -190,6 +192,7 @@ def node_set_status(node_name: str, status: str): with create_ssh_client(node_name) as ssh_client: cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control set-status ' \ f'--endpoint {STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT} ' \ + f'{"-w " + STORAGE_NODE_WALLET_PATH if STORAGE_NODE_WALLET_PATH else ""} ' \ f'--config {STORAGE_NODE_CONFIG_PATH} --status {status}' ssh_client.exec_with_confirmation(cmd, ['']) @@ -208,6 +211,7 @@ def get_netmap_snapshot(node_name: str = None) -> str: with create_ssh_client(node_name) as ssh_client: cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control netmap-snapshot ' \ f'--endpoint {STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT} ' \ + f'{"-w " + STORAGE_NODE_WALLET_PATH if STORAGE_NODE_WALLET_PATH else ""} ' \ f'--config {STORAGE_NODE_CONFIG_PATH}' output = ssh_client.exec_with_confirmation(cmd, ['']) return output.stdout @@ -225,6 +229,7 @@ def node_shard_list(node_name: str) -> List[str]: with create_ssh_client(node_name) as ssh_client: cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control shards list ' \ f'--endpoint {STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT} ' \ + f'{"-w " + STORAGE_NODE_WALLET_PATH if STORAGE_NODE_WALLET_PATH else ""} ' \ f'--config {STORAGE_NODE_CONFIG_PATH}' output = ssh_client.exec_with_confirmation(cmd, ['']) return re.findall(r'Shard (.*):', output.stdout) @@ -242,6 +247,7 @@ def node_shard_set_mode(node_name: str, shard: str, mode: str) -> str: with create_ssh_client(node_name) as ssh_client: cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control shards set-mode ' \ f'--endpoint {STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT} ' \ + f'{"-w " + STORAGE_NODE_WALLET_PATH if STORAGE_NODE_WALLET_PATH else ""} ' \ f'--config {STORAGE_NODE_CONFIG_PATH} --id {shard} --mode {mode}' output = ssh_client.exec_with_confirmation(cmd, ['']) return output.stdout @@ -259,6 +265,7 @@ def drop_object(node_name: str, cid: str, oid: str) -> str: with create_ssh_client(node_name) as ssh_client: cmd = f'{STORAGE_NODE_BIN_PATH}/neofs-cli control drop-objects ' \ f'--endpoint {STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT} ' \ + f'{"-w " + STORAGE_NODE_WALLET_PATH if STORAGE_NODE_WALLET_PATH else ""} ' \ f'--config {STORAGE_NODE_CONFIG_PATH} -o {cid}/{oid}' output = ssh_client.exec_with_confirmation(cmd, ['']) return output.stdout diff --git a/robot/variables/common.py b/robot/variables/common.py index f5161333..60b7d592 100644 --- a/robot/variables/common.py +++ b/robot/variables/common.py @@ -92,12 +92,18 @@ IR_WALLET_PATH = os.getenv("IR_WALLET_PATH", f"{DEVENV_PATH}/services/ir/wallet0 IR_WALLET_CONFIG = os.getenv("IR_WALLET_CONFIG", f"{os.getcwd()}/neofs_cli_configs/one_wallet_password.yml") IR_WALLET_PASS = os.getenv("IR_WALLET_PASS", "one") +# Parameters that control SSH connection to storage node STORAGE_NODE_SSH_USER = os.getenv("STORAGE_NODE_SSH_USER", "root") STORAGE_NODE_SSH_PASSWORD = os.getenv("STORAGE_NODE_SSH_PASSWORD") STORAGE_NODE_SSH_PRIVATE_KEY_PATH = os.getenv("STORAGE_NODE_SSH_PRIVATE_KEY_PATH") + +# Parameters that control resources located on the storage node: +# STORAGE_NODE_BIN_PATH - path to directory that contains CLI tools +# STORAGE_NODE_CONFIG_PATH - configuration file for neofs-cli on the storage node STORAGE_NODE_BIN_PATH = os.getenv("STORAGE_NODE_BIN_PATH", f"{DEVENV_PATH}/vendor") STORAGE_NODE_CONFIG_PATH = os.getenv("STORAGE_NODE_CONFIG_PATH", f"{DEVENV_PATH}/services/storage/cli-cfg.yml") -STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT = os.getenv("STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT", "localhost:8091") +STORAGE_NODE_WALLET_PATH = os.getenv("STORAGE_NODE_WALLET_PATH") # allows to override path to wallet that was given in STORAGE_NODE_CONFIG_PATH, this is temp parameter, should be fixed in environment setup +STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT = os.getenv("STORAGE_NODE_PRIVATE_CONTROL_ENDPOINT") # Path and config for neofs-adm utility. Optional if tests are running against devenv NEOFS_ADM_EXEC = os.getenv("NEOFS_ADM_EXEC")