Skip to content

Commit

Permalink
Merge pull request #97 from skalenetwork/feature/SKALE-1410-sgx-statu…
Browse files Browse the repository at this point in the history
…s-cmd

SKALE-1410 Add SGX status cmd
  • Loading branch information
badrogger authored Jan 13, 2020
2 parents 4277cbd + 7f22fa4 commit 1866b87
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 5 deletions.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ SKALE Node CLI, part of the SKALE suite of validator tools, is the command line
2.4 [Wallet](#wallet-commands)
2.5 [sChains](#schain-commands)
2.6 [Containers](#containers-commands)
2.6 [SSL](#ssl-commands)
2.7 [Logs](#logs-commands)
2.7 [SGX](#sgx-commands)
2.8 [SSL](#ssl-commands)
2.9 [Logs](#logs-commands)

3. [Development](#development)

## Installation
Expand Down Expand Up @@ -344,6 +346,27 @@ Options:

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

### SGX commands

> Prefix: `skale sgx`
#### Status

Status of the SGX server. Returns SGX server URL and connection status.

```bash
$ skale sgx status

SGX server status:
┌────────────────┬────────────────────────────┐
│ SGX server URL │ https://0.0.0.0:1026/ │
├────────────────┼────────────────────────────┤
│ Status │ CONNECTED │
└────────────────┴────────────────────────────┘
```

Admin API URL: [GET] `/api/ssl/sgx`

### SSL commands

> Prefix: `skale ssl`
Expand Down
2 changes: 1 addition & 1 deletion cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.7.0'
__version__ = '0.8.0'

if __name__ == "__main__":
print(__version__)
52 changes: 52 additions & 0 deletions cli/sgx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
#
# This file is part of skale-node-cli
#
# Copyright (C) 2019 SKALE Labs
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import click
from terminaltables import SingleTable

from core.helper import login_required, get, safe_load_texts


TEXTS = safe_load_texts()


@click.group()
def sgx_cli():
pass


@sgx_cli.group('sgx', help="SGX commands")
def sgx():
pass


@sgx.command(help="Status of the SGX server")
@login_required
def status():
result = get('sgx_status')
if not result:
return
else:
table_data = [
['SGX server URL', result['sgx_server_url']],
['Status', result['status_name']]
]
table = SingleTable(table_data)
print('SGX server status:')
print(table.table)
4 changes: 3 additions & 1 deletion configs/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
'ssl_status': '/api/ssl/status',
'ssl_upload': '/api/ssl/upload',

'dkg_statuses': '/api/dkg/statuses'
'dkg_statuses': '/api/dkg/statuses',

'sgx_status': '/api/sgx/status'
}
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from cli.user import user_cli
from cli.wallet import wallet_cli
from cli.ssl import ssl_cli
from cli.sgx import sgx_cli

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

cmd_collection = click.CommandCollection(
sources=[cli, schains_cli, containers_cli, logs_cli,
node_cli, metrics_cli, user_cli, wallet_cli, ssl_cli])
node_cli, metrics_cli, user_cli, wallet_cli, ssl_cli, sgx_cli])
try:
cmd_collection()
except Exception as err:
Expand Down

0 comments on commit 1866b87

Please sign in to comment.