Skip to content

Commit 7f22fa4

Browse files
committed
SKALE-1410 Add SGX status cmd
1 parent 4277cbd commit 7f22fa4

File tree

5 files changed

+83
-5
lines changed

5 files changed

+83
-5
lines changed

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ SKALE Node CLI, part of the SKALE suite of validator tools, is the command line
1515
2.4 [Wallet](#wallet-commands)
1616
2.5 [sChains](#schain-commands)
1717
2.6 [Containers](#containers-commands)
18-
2.6 [SSL](#ssl-commands)
19-
2.7 [Logs](#logs-commands)
18+
2.7 [SGX](#sgx-commands)
19+
2.8 [SSL](#ssl-commands)
20+
2.9 [Logs](#logs-commands)
21+
2022
3. [Development](#development)
2123

2224
## Installation
@@ -344,6 +346,27 @@ Options:
344346

345347
- `-a/--all` - list all sChain containers (by default - only running)
346348

349+
### SGX commands
350+
351+
> Prefix: `skale sgx`
352+
353+
#### Status
354+
355+
Status of the SGX server. Returns SGX server URL and connection status.
356+
357+
```bash
358+
$ skale sgx status
359+
360+
SGX server status:
361+
┌────────────────┬────────────────────────────┐
362+
│ SGX server URL │ https://0.0.0.0:1026/ │
363+
├────────────────┼────────────────────────────┤
364+
│ Status │ CONNECTED │
365+
└────────────────┴────────────────────────────┘
366+
```
367+
368+
Admin API URL: [GET] `/api/ssl/sgx`
369+
347370
### SSL commands
348371

349372
> Prefix: `skale ssl`

cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.7.0'
1+
__version__ = '0.8.0'
22

33
if __name__ == "__main__":
44
print(__version__)

cli/sgx.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of skale-node-cli
4+
#
5+
# Copyright (C) 2019 SKALE Labs
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Affero General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Affero General Public License
18+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
20+
import click
21+
from terminaltables import SingleTable
22+
23+
from core.helper import login_required, get, safe_load_texts
24+
25+
26+
TEXTS = safe_load_texts()
27+
28+
29+
@click.group()
30+
def sgx_cli():
31+
pass
32+
33+
34+
@sgx_cli.group('sgx', help="SGX commands")
35+
def sgx():
36+
pass
37+
38+
39+
@sgx.command(help="Status of the SGX server")
40+
@login_required
41+
def status():
42+
result = get('sgx_status')
43+
if not result:
44+
return
45+
else:
46+
table_data = [
47+
['SGX server URL', result['sgx_server_url']],
48+
['Status', result['status_name']]
49+
]
50+
table = SingleTable(table_data)
51+
print('SGX server status:')
52+
print(table.table)

configs/routes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@
2323
'ssl_status': '/api/ssl/status',
2424
'ssl_upload': '/api/ssl/upload',
2525

26-
'dkg_statuses': '/api/dkg/statuses'
26+
'dkg_statuses': '/api/dkg/statuses',
27+
28+
'sgx_status': '/api/sgx/status'
2729
}

main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from cli.user import user_cli
3434
from cli.wallet import wallet_cli
3535
from cli.ssl import ssl_cli
36+
from cli.sgx import sgx_cli
3637

3738
from core.helper import (safe_load_texts, init_default_logger)
3839
from configs import LONG_LINE
@@ -119,7 +120,7 @@ def handle_exception(exc_type, exc_value, exc_traceback):
119120

120121
cmd_collection = click.CommandCollection(
121122
sources=[cli, schains_cli, containers_cli, logs_cli,
122-
node_cli, metrics_cli, user_cli, wallet_cli, ssl_cli])
123+
node_cli, metrics_cli, user_cli, wallet_cli, ssl_cli, sgx_cli])
123124
try:
124125
cmd_collection()
125126
except Exception as err:

0 commit comments

Comments
 (0)