Add total RAM, CPUs and disk size to servers summary as well as disk usage in percent. Fixes https://github.com/GNS3/gns3-server/issues/1532

This commit is contained in:
grossmj committed 2020-07-19 14:16:07 +09:30
1 parent 00a6765405
commit 3dc4ea46d6
11 files changed
+69 -9

No files matched your search

+4
View File
@@ -292,10 +292,14 @@ async def test_json(compute):
"user": "test",
"cpu_usage_percent": None,
"memory_usage_percent": None,
"disk_usage_percent": None,
"connected": True,
"last_error": None,
"capabilities": {
"version": None,
"cpus": None,
"memory": None,
"disk_size": None,
"node_types": []
}
}
@@ -18,8 +18,10 @@
import sys
import pytest
import psutil
from gns3server.version import __version__
from gns3server.utils.path import get_default_project_directory
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
@@ -27,7 +29,13 @@ async def test_get(compute_api, windows_platform):
response = await compute_api.get('/capabilities')
assert response.status == 200
assert response.json == {'node_types': ['cloud', 'ethernet_hub', 'ethernet_switch', 'nat', 'vpcs', 'virtualbox', 'dynamips', 'frame_relay_switch', 'atm_switch', 'qemu', 'vmware', 'traceng', 'docker', 'iou'], 'version': __version__, 'platform': sys.platform}
assert response.json == {'node_types': ['cloud', 'ethernet_hub', 'ethernet_switch', 'nat', 'vpcs', 'virtualbox', 'dynamips', 'frame_relay_switch', 'atm_switch', 'qemu', 'vmware', 'traceng', 'docker', 'iou'],
'version': __version__,
'platform': sys.platform,
'cpus': psutil.cpu_count(logical=True),
'memory': psutil.virtual_memory().total,
'disk_size': psutil.disk_usage(get_default_project_directory()).total,
}
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
@@ -35,4 +43,10 @@ async def test_get_on_gns3vm(compute_api, on_gns3vm):
response = await compute_api.get('/capabilities')
assert response.status == 200
assert response.json == {'node_types': ['cloud', 'ethernet_hub', 'ethernet_switch', 'nat', 'vpcs', 'virtualbox', 'dynamips', 'frame_relay_switch', 'atm_switch', 'qemu', 'vmware', 'traceng', 'docker', 'iou'], 'version': __version__, 'platform': sys.platform}
assert response.json == {'node_types': ['cloud', 'ethernet_hub', 'ethernet_switch', 'nat', 'vpcs', 'virtualbox', 'dynamips', 'frame_relay_switch', 'atm_switch', 'qemu', 'vmware', 'traceng', 'docker', 'iou'],
'version': __version__,
'platform': sys.platform,
'cpus': psutil.cpu_count(logical=True),
'memory': psutil.virtual_memory().total,
'disk_size': psutil.disk_usage(get_default_project_directory()).total,
}
@@ -133,9 +133,13 @@ async def test_compute_list(controller_api):
'name': 'My super server',
'cpu_usage_percent': None,
'memory_usage_percent': None,
'disk_usage_percent': None,
'last_error': None,
'capabilities': {
'version': None,
'cpus': None,
'memory': None,
'disk_size': None,
'node_types': []
}
}
+4 -4
View File
@@ -53,7 +53,7 @@ def write_config(tmpdir, settings):
return path
def test_get_section_config(tmpdir):
def test_get_section_config(loop, tmpdir):
config = load_config(tmpdir, {
"Server": {
@@ -63,7 +63,7 @@ def test_get_section_config(tmpdir):
assert dict(config.get_section_config("Server")) == {"host": "127.0.0.1"}
def test_set_section_config(tmpdir):
def test_set_section_config(loop, tmpdir):
config = load_config(tmpdir, {
"Server": {
@@ -77,7 +77,7 @@ def test_set_section_config(tmpdir):
assert dict(config.get_section_config("Server")) == {"host": "192.168.1.1", "local": "true"}
def test_set(tmpdir):
def test_set(loop, tmpdir):
config = load_config(tmpdir, {
"Server": {
@@ -90,7 +90,7 @@ def test_set(tmpdir):
assert dict(config.get_section_config("Server")) == {"host": "192.168.1.1"}
def test_reload(tmpdir):
def test_reload(loop, tmpdir):
config = load_config(tmpdir, {
"Server": {