Remove redundant variables

Small refactoring that includes:
 - Removed variables that are not used any more.
 - Cleanup in helper functions' names.

Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
Vladimir Domnich 2022-08-01 13:15:02 +03:00
parent 642af0a888
commit 47c55f0060
7 changed files with 77 additions and 66 deletions

View file

@ -6,16 +6,17 @@ import re
import uuid
from enum import Enum
from time import sleep
from typing import Optional
import boto3
from data_formatters import pub_key_hex
from botocore.exceptions import ClientError
import urllib3
from botocore.exceptions import ClientError
from robot.api import logger
from robot.api.deco import keyword
from cli_helpers import _run_with_passwd, log_command_execution
from common import NEOFS_ENDPOINT, S3_GATE, S3_GATE_WALLET_PATH, S3_GATE_WALLET_PASS
from data_formatters import get_wallet_public_key
##########################################################
# Disabling warnings on self-signed certificate which the
@ -39,13 +40,13 @@ class VersioningStatus(Enum):
@keyword('Init S3 Credentials')
def init_s3_credentials(wallet_path, s3_bearer_rules_file: str = None):
def init_s3_credentials(wallet_path, s3_bearer_rules_file: Optional[str] = None):
bucket = str(uuid.uuid4())
s3_bearer_rules = s3_bearer_rules_file or 'robot/resources/files/s3_bearer_rules.json'
gate_pub_key = pub_key_hex(S3_GATE_WALLET_PATH, S3_GATE_WALLET_PASS)
gate_public_key = get_wallet_public_key(S3_GATE_WALLET_PATH, S3_GATE_WALLET_PASS)
cmd = (
f'{NEOFS_EXEC} --debug --with-log --timeout {CREDENTIALS_CREATE_TIMEOUT} '
f'issue-secret --wallet {wallet_path} --gate-public-key={gate_pub_key} '
f'issue-secret --wallet {wallet_path} --gate-public-key={gate_public_key} '
f'--peer {NEOFS_ENDPOINT} --container-friendly-name {bucket} '
f'--bearer-rules {s3_bearer_rules}'
)
@ -158,7 +159,7 @@ def head_bucket(s3_client, bucket: str):
@keyword('Set bucket versioning status')
def set_bucket_versioning(s3_client, bucket_name: str, status: VersioningStatus):
def set_bucket_versioning(s3_client, bucket_name: str, status: VersioningStatus) -> None:
try:
response = s3_client.put_bucket_versioning(Bucket=bucket_name, VersioningConfiguration={'Status': status.value})
log_command_execution('S3 Set bucket versioning to', response)
@ -202,7 +203,7 @@ def get_bucket_tagging(s3_client, bucket_name: str) -> list:
@keyword('Delete bucket tagging')
def delete_bucket_tagging(s3_client, bucket_name: str):
def delete_bucket_tagging(s3_client, bucket_name: str) -> None:
try:
response = s3_client.delete_bucket_tagging(Bucket=bucket_name)
log_command_execution('S3 Delete bucket tagging', response)