Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion node_cli/cli/mirage_boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def init_boot(env_file):
@click.option('--domain', '-d', prompt='Enter node domain name', type=str, help='Node domain name')
@streamed_cmd
def register_boot(name, ip, port, domain):
register(name=name, p2p_ip=ip, public_ip=ip, port=port, domain_name=domain)
register(name=name, p2p_ip=ip, public_ip=ip, port=port, domain_name=domain, is_mirage_boot=True)


@boot.command('signature', help='Get mirage node signature for a validator ID (during Boot Phase).')
Expand Down
12 changes: 10 additions & 2 deletions node_cli/cli/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from node_cli.utils.texts import safe_load_texts
from node_cli.configs.ssl import DEFAULT_SSL_CHECK_PORT, SSL_CERT_FILEPATH, SSL_KEY_FILEPATH
from node_cli.core.ssl import check_cert, upload_cert, cert_status
from node_cli.cli.info import TYPE
from node_cli.utils.node_type import NodeType


TEXTS = safe_load_texts()
Expand All @@ -46,7 +48,10 @@ def status():
status, payload = cert_status()
if status == 'ok':
if payload.get('is_empty'):
print(TEXTS['ssl']['no_cert'])
if TYPE == NodeType.MIRAGE:
print(TEXTS['ssl']['no_cert_mirage'])
else:
print(TEXTS['ssl']['no_cert'])
else:
table_data = [
['Issued to', payload['issued_to']],
Expand All @@ -71,7 +76,10 @@ def status():
def upload(key_path, cert_path, force):
status, payload = upload_cert(cert_path, key_path, force)
if status == 'ok':
print(TEXTS['ssl']['uploaded'])
if TYPE == NodeType.MIRAGE:
print(TEXTS['ssl']['uploaded_mirage'])
else:
print(TEXTS['ssl']['uploaded'])
else:
error_exit(payload)

Expand Down
4 changes: 2 additions & 2 deletions node_cli/cli/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ def wallet():
pass


@wallet.command('info', help='Get info about SKALE node wallet')
@wallet.command('info', help='Get info about node wallet')
@click.option('--format', '-f', type=click.Choice(['json', 'text']))
def wallet_info(format):
get_wallet_info(format)


@wallet.command('send', help='Send ETH from SKALE node wallet to address')
@wallet.command('send', help='Send ETH from node wallet to address')
@click.argument('address')
@click.argument('amount', type=float)
@click.option(
Expand Down
24 changes: 20 additions & 4 deletions node_cli/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
TM_INIT_TIMEOUT,
)
from node_cli.cli import __version__
from node_cli.cli.info import TYPE
from node_cli.configs.env import get_validated_env_config, SKALE_DIR_ENV_FILEPATH
from node_cli.configs.cli_logger import LOG_DATA_PATH as CLI_LOG_DATA_PATH

Expand Down Expand Up @@ -120,9 +121,15 @@ def is_update_safe(node_type: NodeType) -> bool:

@check_inited
@check_user
def register_node(name, p2p_ip, public_ip, port, domain_name):
def register_node(name, p2p_ip, public_ip, port, domain_name, is_mirage_boot: bool = False) -> None:
if not is_node_inited():
print(TEXTS['node']['not_inited'])
if TYPE == NodeType.MIRAGE:
if is_mirage_boot:
print(TEXTS['node']['not_inited_mirage_boot'])
else:
print(TEXTS['node']['not_inited_mirage'])
else:
print(TEXTS['node']['not_inited'])
return

# todo: add name, ips and port checks
Expand All @@ -135,7 +142,13 @@ def register_node(name, p2p_ip, public_ip, port, domain_name):
}
status, payload = post_request(blueprint=BLUEPRINT_NAME, method='register', json=json_data)
if status == 'ok':
msg = TEXTS['node']['registered']
if TYPE == NodeType.MIRAGE:
if is_mirage_boot:
msg = TEXTS['node']['registered_mirage_boot']
else:
msg = TEXTS['node']['registered_mirage']
else:
msg = TEXTS['node']['registered']
logger.info(msg)
print(msg)
else:
Expand Down Expand Up @@ -498,7 +511,10 @@ def run_checks(
disk: Optional[str] = None,
) -> None:
if not is_node_inited():
print(TEXTS['node']['not_inited'])
if TYPE == NodeType.MIRAGE:
print(TEXTS['node']['not_inited_mirage'])
else:
print(TEXTS['node']['not_inited'])
return

if disk is None:
Expand Down
9 changes: 8 additions & 1 deletion node_cli/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from node_cli.utils.helper import error_exit, is_user_valid, get_g_conf_user
from node_cli.utils.texts import safe_load_texts
from node_cli.utils.exit_codes import CLIExitCodes
from node_cli.cli.info import TYPE
from node_cli.utils.node_type import NodeType


TEXTS = safe_load_texts()
Expand All @@ -45,7 +47,12 @@ def check_inited(f):
@wraps(f)
def inner(*args, **kwargs):
if not is_node_inited():
error_exit(TEXTS['node']['not_inited'], exit_code=CLIExitCodes.NODE_STATE_ERROR)
if TYPE == NodeType.MIRAGE:
error_exit(
TEXTS['node']['not_inited_mirage'], exit_code=CLIExitCodes.NODE_STATE_ERROR
)
else:
error_exit(TEXTS['node']['not_inited'], exit_code=CLIExitCodes.NODE_STATE_ERROR)
return f(*args, **kwargs)

return inner
Expand Down
7 changes: 6 additions & 1 deletion node_cli/utils/print_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@

import inspect

from node_cli.cli.info import TYPE
from node_cli.configs import LONG_LINE
from node_cli.configs.cli_logger import DEBUG_LOG_FILEPATH
from node_cli.utils.meta import CliMeta
from node_cli.utils.texts import safe_load_texts
from node_cli.utils.node_type import NodeType

TEXTS = safe_load_texts()

Expand Down Expand Up @@ -226,7 +228,10 @@ def print_schain_info(info: dict, raw: bool = False) -> None:


def print_node_cmd_error():
print(TEXTS['node']['cmd_failed'].format(DEBUG_LOG_FILEPATH))
if TYPE == NodeType.MIRAGE:
print(TEXTS['node']['cmd_failed_mirage'].format(DEBUG_LOG_FILEPATH))
else:
print(TEXTS['node']['cmd_failed'].format(DEBUG_LOG_FILEPATH))


def print_node_info(node, node_status):
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/mirage_cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_mirage_boot_register(mock_register_core):

assert result.exit_code == 0, f'Output: {result.output}\nException: {result.exception}'
mock_register_core.assert_called_once_with(
name=name, p2p_ip=ip, public_ip=ip, port=port, domain_name=domain
name=name, p2p_ip=ip, public_ip=ip, port=port, domain_name=domain, is_mirage_boot=True
)


Expand Down
2 changes: 1 addition & 1 deletion tests/cli/node_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_node_info_node_info_not_created():
resp_mock = response_mock(requests.codes.ok, json_data={'payload': payload, 'status': 'ok'})
result = run_command_mock('node_cli.utils.helper.requests.get', resp_mock, node_info)
assert result.exit_code == 0
assert result.output == 'This SKALE node is not registered on SKALE Manager yet\n'
assert result.output == 'This node is not registered on SKALE Manager yet\n'


def test_node_info_node_info_frozen():
Expand Down
20 changes: 19 additions & 1 deletion text.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ node:
registered: |-
Node registered in SKALE manager.
For more info run < skale node info >
registered_mirage: |-
Node registered in SKALE manager.
For more info run < mirage node info >
registered_mirage_boot: |-
Node registered in SKALE manager.
For more info run < mirage boot info >
status:
ACTIVE: Active
LEAVING: Leaving
Expand All @@ -27,24 +33,36 @@ node:
not_inited: |-
Node hasn't been inited before.
You should run < skale node init >
not_inited_mirage: |-
Node hasn't been inited before.
You should run < mirage node init >
already_inited: Node was already inited before.
cmd_failed: |-
Command failed. Please, check out < skale logs cli >
and logs from docker containers for more information
cmd_failed_mirage: |-
Command failed. Please, check out < mirage logs cli >
and logs from docker containers for more information
domain_name_changed: Domain name successfully changed
wallet:
successful_transfer: "Funds were successfully transferred"

service:
node_not_registered: This SKALE node is not registered on SKALE Manager yet
node_not_registered: This node is not registered on SKALE Manager yet

ssl:
no_cert: |-
No SSL certificates on the node.
Run < skale ssl upload > to add new certificates.
no_cert_mirage: |-
No SSL certificates on the node.
Run < mirage ssl upload > to add new certificates.
uploaded: |-
Certificates are successfully uploaded.
You can check status by running < skale ssl status >
uploaded_mirage: |-
Certificates are successfully uploaded.
You can check status by running < mirage ssl status >
check_passed: |-
Check passed

Expand Down