Signed-off-by: anastasia prasolova <anastasia@nspcc.ru>
This commit is contained in:
anastasia prasolova 2022-06-13 23:33:09 +03:00 committed by Anastasia Prasolova
parent 0e27ea02c1
commit a56734ed93
30 changed files with 468 additions and 412 deletions

View file

@ -9,7 +9,7 @@ from enum import Enum, auto
import base58
from cli_helpers import _cmd_run
from common import ASSETS_DIR, NEOFS_ENDPOINT, WALLET_PASS
from common import ASSETS_DIR, NEOFS_ENDPOINT, WALLET_CONFIG
from robot.api import logger
from robot.api.deco import keyword
@ -39,7 +39,7 @@ class Role(AutoName):
def get_eacl(wallet: str, cid: str):
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'container get-eacl --cid {cid} --config {WALLET_PASS}'
f'container get-eacl --cid {cid} --config {WALLET_CONFIG}'
)
try:
output = _cmd_run(cmd)
@ -56,7 +56,7 @@ def get_eacl(wallet: str, cid: str):
def set_eacl(wallet: str, cid: str, eacl_table_path: str):
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'container set-eacl --cid {cid} --table {eacl_table_path} --config {WALLET_PASS} --await'
f'container set-eacl --cid {cid} --table {eacl_table_path} --config {WALLET_CONFIG} --await'
)
_cmd_run(cmd)
@ -163,6 +163,6 @@ def form_bearertoken_file(wif: str, cid: str, eacl_records: list) -> str:
def sign_bearer_token(wallet: str, eacl_rules_file: str):
cmd = (
f'{NEOFS_CLI_EXEC} util sign bearer-token --from {eacl_rules_file} '
f'--to {eacl_rules_file} --wallet {wallet} --config {WALLET_PASS} --json'
f'--to {eacl_rules_file} --wallet {wallet} --config {WALLET_CONFIG} --json'
)
_cmd_run(cmd)

View file

@ -1,24 +0,0 @@
#!/usr/bin/python3.8
import pexpect
from robot.api.deco import keyword
ROBOT_AUTO_KEYWORDS = False
@keyword('Run Process And Enter Empty Password')
def run_proccess_and_interact(cmd: str) -> str:
p = pexpect.spawn(cmd)
p.expect("[pP]assword")
# enter empty password
p.sendline('\r')
p.wait()
# throw a string with password prompt
first = p.readline()
# take all output
child_output = p.readline()
p.close()
if p.exitstatus != 0:
raise Exception(f"{first}\n{child_output}")
return child_output

View file

@ -10,6 +10,9 @@
first non-null response.
"""
from common import NEOFS_NETMAP, WALLET_CONFIG
import neofs_verbs
from robot.api import logger
from robot.api.deco import keyword
from robot.libraries.BuiltIn import BuiltIn
@ -21,7 +24,9 @@ ROBOT_AUTO_KEYWORDS = False
@keyword('Get Link Object')
def get_link_object(wallet: str, cid: str, oid: str, bearer_token: str = ""):
<<<<<<< HEAD
def get_link_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
wallet_config: str = WALLET_CONFIG):
"""
Args:
wallet (str): path to the wallet on whose behalf the Storage Nodes
@ -29,6 +34,7 @@ def get_link_object(wallet: str, cid: str, oid: str, bearer_token: str = ""):
cid (str): Container ID which stores the Large Object
oid (str): Large Object ID
bearer_token (optional, str): path to Bearer token file
wallet_config (optional, str): path to the neofs-cli config file
Returns:
(str): Link Object ID
When no Link Object ID is found after all Storage Nodes polling,
@ -40,7 +46,8 @@ def get_link_object(wallet: str, cid: str, oid: str, bearer_token: str = ""):
endpoint=node,
is_raw=True,
is_direct=True,
bearer_token=bearer_token)
bearer_token=bearer_token,
wallet_config=wallet_config)
if resp['link']:
return resp['link']
except Exception:

View file

@ -8,13 +8,14 @@
import json
import time
from common import NEOFS_ENDPOINT, COMMON_PLACEMENT_RULE, NEOFS_CLI_EXEC, WALLET_CONFIG
from cli_helpers import _cmd_run
from data_formatters import dict_to_attrs
import json_transformers
from robot.api import logger
from robot.api.deco import keyword
import json_transformers
from cli_helpers import _cmd_run
from common import NEOFS_ENDPOINT, COMMON_PLACEMENT_RULE, NEOFS_CLI_EXEC, WALLET_PASS
from data_formatters import dict_to_attrs
ROBOT_AUTO_KEYWORDS = False
@ -46,7 +47,7 @@ def create_container(wallet: str, rule: str = COMMON_PLACEMENT_RULE, basic_acl:
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} container create '
f'--wallet {session_wallet if session_wallet else wallet} '
f'--config {WALLET_PASS} --policy "{rule}" '
f'--config {WALLET_CONFIG} --policy "{rule}" '
f'{"--basic-acl " + basic_acl if basic_acl else ""} '
f'{"--attributes " + dict_to_attrs(attributes) if attributes else ""} '
f'{"--session " + session_token if session_token else ""} '
@ -84,7 +85,7 @@ def list_containers(wallet: str):
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'--config {WALLET_PASS} container list'
f'--config {WALLET_CONFIG} container list'
)
output = _cmd_run(cmd)
return output.split()
@ -103,7 +104,7 @@ def get_container(wallet: str, cid: str):
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'--config {WALLET_PASS} --cid {cid} container get --json'
f'--config {WALLET_CONFIG} --cid {cid} container get --json'
)
output = _cmd_run(cmd)
container_info = json.loads(output)
@ -130,7 +131,7 @@ def delete_container(wallet: str, cid: str):
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'--config {WALLET_PASS} container delete --cid {cid}'
f'--config {WALLET_CONFIG} container delete --cid {cid}'
)
_cmd_run(cmd)

View file

@ -13,9 +13,9 @@ import uuid
from robot.api import logger
from robot.api.deco import keyword
from common import NEOFS_ENDPOINT, ASSETS_DIR, NEOFS_NETMAP, WALLET_CONFIG
import json_transformers
from cli_helpers import _cmd_run
from common import NEOFS_ENDPOINT, ASSETS_DIR, NEOFS_NETMAP, WALLET_PASS
from data_formatters import dict_to_attrs
ROBOT_AUTO_KEYWORDS = False
@ -26,7 +26,8 @@ NEOFS_CLI_EXEC = os.getenv('NEOFS_CLI_EXEC', 'neofs-cli')
@keyword('Get object')
def get_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
write_object: str = "", endpoint: str = "", options: str = ""):
write_object: str = "", endpoint: str = "", options: str = "",
wallet_config: str = WALLET_CONFIG):
"""
GET from NeoFS.
@ -37,6 +38,7 @@ def get_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
bearer_token (optional, str): path to Bearer Token file, appends to `--bearer` key
write_object (optional, str): path to downloaded file, appends to `--file` key
endpoint (optional, str): NeoFS endpoint to send request to, appends to `--rpc-endpoint` key
wallet_config(optional, str): path to the wallet config
options (optional, str): any options which `neofs-cli object get` accepts
Returns:
(str): path to downloaded file
@ -51,7 +53,7 @@ def get_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint} --wallet {wallet} '
f'object get --cid {cid} --oid {oid} --file {file_path} --config {WALLET_PASS} '
f'object get --cid {cid} --oid {oid} --file {file_path} --config {wallet_config} '
f'{"--bearer " + bearer_token if bearer_token else ""} '
f'{options}'
)
@ -62,7 +64,7 @@ def get_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
# TODO: make `bearer_token` optional
@keyword('Get Range Hash')
def get_range_hash(wallet: str, cid: str, oid: str, bearer_token: str, range_cut: str,
options: str = ""):
wallet_config: str = WALLET_CONFIG, options: str = ""):
"""
GETRANGEHASH of given Object.
@ -73,13 +75,14 @@ def get_range_hash(wallet: str, cid: str, oid: str, bearer_token: str, range_cut
range_cut (str): Range to take hash from in the form offset1:length1,...,
value to pass to the `--range` parameter
bearer_token (optional, str): path to Bearer Token file, appends to `--bearer` key
wallet_config(optional, str): path to the wallet config
options (optional, str): any options which `neofs-cli object hash` accepts
Returns:
None
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'object hash --cid {cid} --oid {oid} --range {range_cut} --config {WALLET_PASS} '
f'object hash --cid {cid} --oid {oid} --range {range_cut} --config {wallet_config} '
f'{"--bearer " + bearer_token if bearer_token else ""} '
f'{options}'
)
@ -90,7 +93,7 @@ def get_range_hash(wallet: str, cid: str, oid: str, bearer_token: str, range_cut
@keyword('Put object')
def put_object(wallet: str, path: str, cid: str, bearer: str = "", user_headers: dict = {},
endpoint: str = "", options: str = ""):
endpoint: str = "", wallet_config: str = WALLET_CONFIG, options: str = ""):
"""
PUT of given file.
@ -101,6 +104,7 @@ def put_object(wallet: str, path: str, cid: str, bearer: str = "", user_headers:
bearer (optional, str): path to Bearer Token file, appends to `--bearer` key
user_headers (optional, dict): Object attributes, append to `--attributes` key
endpoint(optional, str): NeoFS endpoint to send request to
wallet_config(optional, str): path to the wallet config
options (optional, str): any options which `neofs-cli object put` accepts
Returns:
(str): ID of uploaded Object
@ -109,7 +113,7 @@ def put_object(wallet: str, path: str, cid: str, bearer: str = "", user_headers:
endpoint = random.sample(NEOFS_NETMAP, 1)[0]
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint} --wallet {wallet} '
f'object put --file {path} --cid {cid} {options} --config {WALLET_PASS} '
f'object put --file {path} --cid {cid} {options} --config {wallet_config} '
f'{"--bearer " + bearer if bearer else ""} '
f'{"--attributes " + dict_to_attrs(user_headers) if user_headers else ""}'
)
@ -121,7 +125,8 @@ def put_object(wallet: str, path: str, cid: str, bearer: str = "", user_headers:
@keyword('Delete object')
def delete_object(wallet: str, cid: str, oid: str, bearer: str = "", options: str = ""):
def delete_object(wallet: str, cid: str, oid: str, bearer: str = "", wallet_config: str = WALLET_CONFIG,
options: str = ""):
"""
DELETE an Object.
@ -130,13 +135,14 @@ def delete_object(wallet: str, cid: str, oid: str, bearer: str = "", options: st
cid (str): ID of Container where we get the Object from
oid (str): ID of Object we are going to delete
bearer (optional, str): path to Bearer Token file, appends to `--bearer` key
wallet_config(optional, str): path to the wallet config
options (optional, str): any options which `neofs-cli object delete` accepts
Returns:
(str): Tombstone ID
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'object delete --cid {cid} --oid {oid} {options} --config {WALLET_PASS} '
f'object delete --cid {cid} --oid {oid} {options} --config {wallet_config} '
f'{"--bearer " + bearer if bearer else ""}'
)
output = _cmd_run(cmd)
@ -149,7 +155,7 @@ def delete_object(wallet: str, cid: str, oid: str, bearer: str = "", options: st
# TODO: make `bearer` an optional parameter
@keyword('Get Range')
def get_range(wallet: str, cid: str, oid: str, file_path: str, bearer: str, range_cut: str,
options: str = ""):
wallet_config: str = WALLET_CONFIG, options: str = ""):
"""
GETRANGE an Object.
@ -160,6 +166,7 @@ def get_range(wallet: str, cid: str, oid: str, file_path: str, bearer: str, rang
file_path (str): file path
range_cut (str): range to take data from in the form offset:length
bearer (optional, str): path to Bearer Token file, appends to `--bearer` key
wallet_config(optional, str): path to the wallet config
options (optional, str): any options which `neofs-cli object range` accepts
Returns:
(void)
@ -167,7 +174,7 @@ def get_range(wallet: str, cid: str, oid: str, file_path: str, bearer: str, rang
range_file = f"{ASSETS_DIR}/{uuid.uuid4()}"
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'object range --cid {cid} --oid {oid} --range {range_cut} --config {WALLET_PASS} '
f'object range --cid {cid} --oid {oid} --range {range_cut} --config {wallet_config} '
f'{options} --file {range_file} '
f'{"--bearer " + bearer if bearer else ""} '
)
@ -180,7 +187,7 @@ def get_range(wallet: str, cid: str, oid: str, file_path: str, bearer: str, rang
@keyword('Search object')
def search_object(wallet: str, cid: str, keys: str = "", bearer: str = "", filters: dict = {},
expected_objects_list=[]):
expected_objects_list=[], wallet_config: str = WALLET_CONFIG):
"""
SEARCH an Object.
@ -192,6 +199,7 @@ def search_object(wallet: str, cid: str, keys: str = "", bearer: str = "", filte
bearer (optional, str): path to Bearer Token file, appends to `--bearer` key
filters (optional, dict): key=value pairs to filter Objects
expected_objects_list (optional, list): a list of ObjectIDs to compare found Objects with
wallet_config(optional, str): path to the wallet config
Returns:
(list): list of found ObjectIDs
"""
@ -203,7 +211,7 @@ def search_object(wallet: str, cid: str, keys: str = "", bearer: str = "", filte
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} --wallet {wallet} '
f'object search {keys} --cid {cid} {filters_result} --config {WALLET_PASS} '
f'object search {keys} --cid {cid} {filters_result} --config {wallet_config} '
f'{"--bearer " + bearer if bearer else ""}'
)
output = _cmd_run(cmd)
@ -224,7 +232,7 @@ def search_object(wallet: str, cid: str, keys: str = "", bearer: str = "", filte
@keyword('Head object')
def head_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
options: str = "", endpoint: str = "", json_output: bool = True,
is_raw: bool = False, is_direct: bool = False):
is_raw: bool = False, is_direct: bool = False, wallet_config: str = WALLET_CONFIG):
"""
HEAD an Object.
@ -241,6 +249,7 @@ def head_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
turns into `--raw` key
is_direct(optional, bool): send request directly to the node or not; this flag
turns into `--ttl 1` key
wallet_config(optional, str): path to the wallet config
Returns:
depending on the `json_output` parameter value, the function returns
(dict): HEAD response in JSON format
@ -249,7 +258,7 @@ def head_object(wallet: str, cid: str, oid: str, bearer_token: str = "",
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {endpoint if endpoint else NEOFS_ENDPOINT} '
f'--wallet {wallet} --config {WALLET_PASS} '
f'--wallet {wallet} --config {wallet_config} '
f'object head --cid {cid} --oid {oid} {options} '
f'{"--bearer " + bearer_token if bearer_token else ""} '
f'{"--json" if json_output else ""} '

View file

@ -1,29 +1,39 @@
#!/usr/bin/python3
import re
import time
import pexpect
from neo3 import wallet
from robot.api import logger
from robot.api.deco import keyword
import contract
from common import (MAINNET_WALLET_PATH, MORPH_ENDPOINT,
NEO_MAINNET_ENDPOINT, NEOFS_CONTRACT, MAINNET_SINGLE_ADDR)
import rpc_client
from common import *
import contract
import converters
import wallet
from wrappers import run_sh_with_passwd_contract
from converters import load_wallet
from robot.api.deco import keyword
from robot.api import logger
from robot.libraries.BuiltIn import BuiltIn
ROBOT_AUTO_KEYWORDS = False
MORPH_TOKEN_POWER = 12
EMPTY_PASSWORD = ''
MAINNET_WALLET_PASS = 'one'
TX_PERSIST_TIMEOUT = 15 #seconds
morph_rpc_cli = rpc_client.RPCClient(NEOFS_NEO_API_ENDPOINT)
NEOGO_CLI_EXEC = BuiltIn().get_variable_value("${NEOGO_CLI_EXEC}")
morph_rpc_cli = rpc_client.RPCClient(MORPH_ENDPOINT)
mainnet_rpc_cli = rpc_client.RPCClient(NEO_MAINNET_ENDPOINT)
@keyword('Withdraw Mainnet Gas')
def withdraw_mainnet_gas(wallet: str, address: str, scripthash: str, amount: int):
def withdraw_mainnet_gas(wlt: str, address: str, scripthash: str, amount: int):
cmd = (
f"{NEOGO_CLI_EXEC} contract invokefunction -w {wallet} -a {address} "
f"{NEOGO_CLI_EXEC} contract invokefunction -w {wlt} -a {address} "
f"-r {NEO_MAINNET_ENDPOINT} {NEOFS_CONTRACT} withdraw {scripthash} "
f"int:{amount} -- {scripthash}:Global"
)
@ -35,34 +45,39 @@ def withdraw_mainnet_gas(wallet: str, address: str, scripthash: str, amount: int
if m is None:
raise Exception("Can not get Tx.")
tx = m.group(1)
return tx
if not transaction_accepted(tx):
raise RuntimeError(f"TX {tx} hasn't been processed")
@keyword('Transaction accepted in block')
def transaction_accepted_in_block(tx_id: str):
def transaction_accepted(tx_id: str):
"""
This function return True in case of accepted TX.
Parameters:
:param tx_id: transaction ID
This function returns True in case of accepted TX.
Args:
tx_id(str): transaction ID
Returns:
(bool)
"""
try:
resp = mainnet_rpc_cli.get_transaction_height(tx_id)
if resp is not None:
logger.info(f"got block height: {resp}")
return True
for _ in range(0, TX_PERSIST_TIMEOUT):
time.sleep(1)
resp = mainnet_rpc_cli.get_transaction_height(tx_id)
if resp is not None:
logger.info(f"TX is accepted in block: {resp}")
return True
except Exception as e:
logger.info(f"request failed with error: {e}")
raise e
return False
@keyword('Get NeoFS Balance')
def get_balance(wif: str):
def get_balance(wallet_path: str):
"""
This function returns NeoFS balance for given WIF.
This function returns NeoFS balance for given wallet.
"""
acc = wallet.Account.from_wif(wif, '')
wlt = load_wallet(wallet_path)
acc = wlt.accounts[-1]
payload = [
{
'type': 'Hash160',
@ -71,24 +86,56 @@ def get_balance(wif: str):
]
try:
resp = morph_rpc_cli.invoke_function(
contract.get_balance_contract_hash(NEOFS_NEO_API_ENDPOINT),
'balanceOf',
payload
)
logger.info(resp)
contract.get_balance_contract_hash(MORPH_ENDPOINT),
'balanceOf',
payload
)
logger.info(f"Got response \n{resp}")
value = int(resp['stack'][0]['value'])
return value / (10 ** MORPH_TOKEN_POWER)
except Exception as e:
logger.error(f"failed to get {wif} balance: {e}")
logger.error(f"failed to get wallet balance: {e}")
raise e
def _run_sh_with_passwd(passwd, cmd):
p = pexpect.spawn(cmd)
p.expect(".*")
p.sendline(passwd + '\r')
p.wait()
# throw a string with password prompt
# take a string with tx hash
tx_hash = p.read().splitlines()[-1]
return tx_hash.decode()
@keyword('Transfer Mainnet Gas')
def transfer_mainnet_gas(wallet_to: str, amount: int, wallet_password: str = EMPTY_PASSWORD):
'''
This function transfer GAS in main chain from mainnet wallet to
the provided wallet. If the wallet contains more than one address,
the assets will be transferred to the last one.
Args:
wallet_to (str): the path to the wallet to transfer assets to
amount (int): amount of gas to transfer
wallet_password (optional, str): password of the wallet; it is
required to decode the wallet and extract its addresses
Returns:
(void)
'''
wlt = load_wallet(wallet_to, wallet_password)
address_to = wlt.accounts[-1].address
logger.info(f"got address to: {address_to}")
txid = wallet.nep17_transfer(MAINNET_WALLET_PATH, address_to, amount, NEO_MAINNET_ENDPOINT,
wallet_pass=MAINNET_WALLET_PASS, addr_from=MAINNET_SINGLE_ADDR)
if not transaction_accepted(txid):
raise RuntimeError(f"TX {txid} hasn't been processed")
@keyword('NeoFS Deposit')
def neofs_deposit(wallet_to: str, amount: int, wallet_password: str = EMPTY_PASSWORD):
"""
Transferring GAS from given wallet to NeoFS contract address.
"""
# get NeoFS contract address
deposit_addr = converters.contract_hash_to_address(NEOFS_CONTRACT)
logger.info(f"NeoFS contract address: {deposit_addr}")
wlt = load_wallet(wallet_to, wallet_password)
address_to = wlt.accounts[-1].address
logger.info(f"got address to: {address_to}")
txid = wallet.nep17_transfer(wallet_to, deposit_addr, amount, NEO_MAINNET_ENDPOINT,
wallet_pass=wallet_password, addr_from=address_to)
if not transaction_accepted(txid):
raise RuntimeError(f"TX {txid} hasn't been processed")

View file

@ -10,13 +10,14 @@ import os
import uuid
from neo3 import wallet
from common import WALLET_CONFIG, ASSETS_DIR
from cli_helpers import _cmd_run
import json_transformers
from robot.api.deco import keyword
from robot.api import logger
from robot.api.deco import keyword
import json_transformers
from cli_helpers import _cmd_run
from common import WALLET_PASS, ASSETS_DIR
ROBOT_AUTO_KEYWORDS = False
# path to neofs-cli executable
@ -95,7 +96,7 @@ def sign_session_token(session_token: str, wlt: str):
signed_token = f"{os.getcwd()}/{ASSETS_DIR}/{uuid.uuid4()}"
cmd = (
f'{NEOFS_CLI_EXEC} util sign session-token --from {session_token} '
f'-w {wlt} --to {signed_token} --config {WALLET_PASS}'
f'-w {wlt} --to {signed_token} --config {WALLET_CONFIG}'
)
_cmd_run(cmd)
return signed_token

View file

@ -5,16 +5,17 @@
It contains wrappers for `neofs-cli storagegroup` verbs.
"""
from robot.api.deco import keyword
from cli_helpers import _cmd_run
from common import NEOFS_CLI_EXEC, NEOFS_ENDPOINT, WALLET_PASS
from common import NEOFS_CLI_EXEC, NEOFS_ENDPOINT, WALLET_CONFIG
from robot.api.deco import keyword
ROBOT_AUTO_KEYWORDS = False
@keyword('Put Storagegroup')
def put_storagegroup(wallet: str, cid: str, objects: list, bearer_token: str = ""):
def put_storagegroup(wallet: str, cid: str, objects: list, bearer_token: str = "",
wallet_config: str = WALLET_CONFIG):
"""
Wrapper for `neofs-cli storagegroup put`. Before the SG is created,
neofs-cli performs HEAD on `objects`, so this verb must be allowed
@ -24,12 +25,13 @@ def put_storagegroup(wallet: str, cid: str, objects: list, bearer_token: str = "
cid (str): ID of Container to put SG to
objects (list): list of Object IDs to include into the SG
bearer_token (optional, str): path to Bearer token file
wallet_config (optional, str): path to neofs-cli config file
Returns:
(str): Object ID of created Storage Group
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} '
f'--wallet {wallet} --config {WALLET_PASS} '
f'--wallet {wallet} --config {wallet_config} '
f'storagegroup put --cid {cid} '
f'--members {",".join(objects)} '
f'{"--bearer " + bearer_token if bearer_token else ""}'
@ -40,7 +42,8 @@ def put_storagegroup(wallet: str, cid: str, objects: list, bearer_token: str = "
@keyword('List Storagegroup')
def list_storagegroup(wallet: str, cid: str, bearer_token: str = ""):
def list_storagegroup(wallet: str, cid: str, bearer_token: str = "",
wallet_config: str = WALLET_CONFIG):
"""
Wrapper for `neofs-cli storagegroup list`. This operation
requires SEARCH allowed for `wallet` in `cid`.
@ -49,12 +52,13 @@ def list_storagegroup(wallet: str, cid: str, bearer_token: str = ""):
listed in the container
cid (str): ID of Container to list
bearer_token (optional, str): path to Bearer token file
wallet_config (optional, str): path to neofs-cli config file
Returns:
(list): Object IDs of found Storage Groups
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} '
f'--wallet {wallet} --config {WALLET_PASS} storagegroup list '
f'--wallet {wallet} --config {wallet_config} storagegroup list '
f'--cid {cid} {"--bearer " + bearer_token if bearer_token else ""}'
)
output = _cmd_run(cmd)
@ -64,7 +68,8 @@ def list_storagegroup(wallet: str, cid: str, bearer_token: str = ""):
@keyword('Get Storagegroup')
def get_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str = ''):
def get_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str = '',
wallet_config: str = WALLET_CONFIG):
"""
Wrapper for `neofs-cli storagegroup get`.
Args:
@ -72,13 +77,14 @@ def get_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str = ''):
cid (str): ID of Container where SG is stored
oid (str): ID of the Storage Group
bearer_token (optional, str): path to Bearer token file
wallet_config (optional, str): path to neofs-cli config file
Returns:
(dict): detailed information on the Storage Group
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} '
f'--wallet {wallet} --config {WALLET_PASS} '
f'--wallet {wallet} --config {wallet_config} '
f'storagegroup get --cid {cid} --id {oid} '
f'{"--bearer " + bearer_token if bearer_token else ""}'
)
@ -103,7 +109,8 @@ def get_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str = ''):
@keyword('Delete Storagegroup')
def delete_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str = ""):
def delete_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str = "",
wallet_config: str = WALLET_CONFIG):
"""
Wrapper for `neofs-cli storagegroup delete`.
Args:
@ -111,13 +118,14 @@ def delete_storagegroup(wallet: str, cid: str, oid: str, bearer_token: str = "")
cid (str): ID of Container where SG is stored
oid (str): ID of the Storage Group
bearer_token (optional, str): path to Bearer token file
wallet_config (optional, str): path to neofs-cli config file
Returns:
(str): Tombstone ID of the deleted Storage Group
"""
cmd = (
f'{NEOFS_CLI_EXEC} --rpc-endpoint {NEOFS_ENDPOINT} '
f'--wallet {wallet} --config {WALLET_PASS} '
f'--wallet {wallet} --config {wallet_config} '
f'storagegroup delete --cid {cid} --id {oid} '
f'{"--bearer " + bearer_token if bearer_token else ""}'
)