From 8312a5461540eaedca3b18a5dc7b4d0e50751270 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 21 Dec 2015 10:17:22 +0100 Subject: [PATCH 1/6] Fix missing boot priority order --- gns3server/schemas/qemu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gns3server/schemas/qemu.py b/gns3server/schemas/qemu.py index 03dc8cd86..43af3409f 100644 --- a/gns3server/schemas/qemu.py +++ b/gns3server/schemas/qemu.py @@ -123,7 +123,7 @@ QEMU_CREATE_SCHEMA = { }, "boot_priority": { "description": "QEMU boot priority", - "enum": ["c", "d"] + "enum": ["c", "d", "n", "cn", "cd"] }, "ram": { "description": "amount of RAM in MB", From 095ef7994adf8840d2f2eb9d3e30cc5edfc49640 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 21 Dec 2015 11:35:29 +0100 Subject: [PATCH 2/6] Support building any branch --- README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index e1ab30af4..f97251ada 100644 --- a/README.rst +++ b/README.rst @@ -22,8 +22,10 @@ master master is the next stable release, you can test it in your day to day activities. Bug fixes or small improvements pull requests go here. -unstable +1.x (1.4 for example) ******** +Next major release + *Never* use this branch for production. Pull requests for major new features go here. Linux From 28533cfdac616f846479c005550a0a10cb54437d Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 22 Dec 2015 12:51:43 +0100 Subject: [PATCH 3/6] Cleanup --- .coverage.atlantis.6236.785802 | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .coverage.atlantis.6236.785802 diff --git a/.coverage.atlantis.6236.785802 b/.coverage.atlantis.6236.785802 deleted file mode 100644 index 52f67bcee..000000000 --- a/.coverage.atlantis.6236.785802 +++ /dev/null @@ -1 +0,0 @@ -!coverage.py: This is a private format, don't read it directly!{"lines": {"/Users/noplay/code/gns3/gns3-server/gns3server/modules/docker/docker_vm.py": [20, 22, 23, 24, 25, 27, 28, 29, 30, 31, 32, 34, 35, 38, 46, 48, 49, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 77, 82, 89, 91, 92, 93, 94, 95, 97, 101, 102, 103, 104, 105, 106, 109, 112, 113, 114, 115, 116, 118, 122, 123, 124, 126, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 142, 143, 144, 145, 146, 147, 148, 149, 155, 156, 157, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 197, 198, 199, 215, 216, 217, 273, 274, 275, 285, 286, 287, 291, 292, 298, 299, 300, 301, 302, 303, 304, 306, 307, 308, 332, 333, 334, 339, 340, 341, 342, 343, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360], "/Users/noplay/code/gns3/gns3-server/gns3server/modules/docker/__init__.py": [20, 22, 23, 24, 25, 26, 27, 29, 31, 32, 33, 34, 37, 39, 41, 42, 44, 45, 47, 48, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 72, 79, 80, 81, 82, 83], "/Users/noplay/code/gns3/gns3-server/gns3server/modules/docker/docker_error.py": [20, 22, 25, 26]}} \ No newline at end of file From 61cf91d83ce3e2b77ca06008953471db8187cbf4 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 22 Dec 2015 13:15:28 +0100 Subject: [PATCH 4/6] Fix tests on Windows Fix #377 --- gns3server/modules/qemu/qemu_vm.py | 5 ++++- tests/handlers/api/test_vpcs.py | 2 ++ tests/modules/qemu/test_qemu_vm.py | 36 +++++++++++++++++++++--------- tests/modules/vpcs/test_vpcs_vm.py | 1 + 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py index 4e79a2f45..e0355ded8 100644 --- a/gns3server/modules/qemu/qemu_vm.py +++ b/gns3server/modules/qemu/qemu_vm.py @@ -748,6 +748,9 @@ class QemuVM(BaseVM): Changes the process priority """ + if self._process_priority == "normal": + return + if sys.platform.startswith("win"): try: import win32api @@ -756,7 +759,7 @@ class QemuVM(BaseVM): except ImportError: log.error("pywin32 must be installed to change the priority class for QEMU VM {}".format(self._name)) else: - log.info("setting QEMU VM {} priority class to BELOW_NORMAL".format(self._name)) + log.info("Setting QEMU VM {} priority class to {}".format(self._name, self._process_priority)) handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, 0, self._process.pid) if self._process_priority == "realtime": priority = win32process.REALTIME_PRIORITY_CLASS diff --git a/tests/handlers/api/test_vpcs.py b/tests/handlers/api/test_vpcs.py index 3f96794d8..22117d615 100644 --- a/tests/handlers/api/test_vpcs.py +++ b/tests/handlers/api/test_vpcs.py @@ -16,6 +16,7 @@ # along with this program. If not, see . import pytest +import sys import os from tests.utils import asyncio_patch from unittest.mock import patch @@ -76,6 +77,7 @@ def test_vpcs_nio_create_udp(server, vm): assert response.json["type"] == "nio_udp" +@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") def test_vpcs_nio_create_tap(server, vm, ethernet_device): with patch("gns3server.modules.base_manager.BaseManager.has_privileged_access", return_value=True): response = server.post("/projects/{project_id}/vpcs/vms/{vm_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_tap", diff --git a/tests/modules/qemu/test_qemu_vm.py b/tests/modules/qemu/test_qemu_vm.py index e0187cce7..ca1b3b2bb 100644 --- a/tests/modules/qemu/test_qemu_vm.py +++ b/tests/modules/qemu/test_qemu_vm.py @@ -31,6 +31,7 @@ from unittest.mock import patch, MagicMock from gns3server.modules.qemu.qemu_vm import QemuVM from gns3server.modules.qemu.qemu_error import QemuError from gns3server.modules.qemu import Qemu +from gns3server.utils import force_unix_path @pytest.fixture(scope="module") @@ -66,7 +67,9 @@ def fake_qemu_binary(): @pytest.fixture(scope="function") def vm(project, manager, fake_qemu_binary, fake_qemu_img_binary): manager.port_manager.console_host = "127.0.0.1" - return QemuVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, qemu_path=fake_qemu_binary) + vm = QemuVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, qemu_path=fake_qemu_binary) + vm._process_priority = "normal" # Avoid complexity for Windows tests + return vm @pytest.fixture(scope="function") @@ -175,6 +178,7 @@ def test_add_nio_binding_udp(vm, loop): assert nio.lport == 4242 +@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") def test_add_nio_binding_ethernet(vm, loop, ethernet_device): with patch("gns3server.modules.base_manager.BaseManager.has_privileged_access", return_value=True): nio = Qemu.instance().create_nio(vm.qemu_path, {"type": "nio_generic_ethernet", "ethernet_device": ethernet_device}) @@ -254,6 +258,7 @@ def test_set_qemu_path_windows(vm, tmpdir): assert vm.platform == "x86_64" +@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") def test_set_qemu_path_kvm_binary(vm, tmpdir, fake_qemu_binary): bin_path = os.path.join(os.environ["PATH"], "qemu-kvm") @@ -299,12 +304,23 @@ def test_set_process_priority(vm, loop, fake_qemu_img_binary): with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process: vm._process = MagicMock() vm._process.pid = 42 + vm._process_priority = "low" loop.run_until_complete(asyncio.async(vm._set_process_priority())) assert process.called args, kwargs = process.call_args assert args == ("renice", "-n", "5", "-p", "42") +@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") +def test_set_process_priority_normal(vm, loop, fake_qemu_img_binary): + + with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process: + vm._process = MagicMock() + vm._process.pid = 42 + loop.run_until_complete(asyncio.async(vm._set_process_priority())) + assert not process.called + + def test_json(vm, project): json = vm.__json__() @@ -388,9 +404,9 @@ def test_hda_disk_image(vm, tmpdir): vm.manager.config.set("Server", "images_path", str(tmpdir)) vm.hda_disk_image = str(tmpdir / "test") - assert vm.hda_disk_image == str(tmpdir / "test") + assert vm.hda_disk_image == force_unix_path(str(tmpdir / "test")) vm.hda_disk_image = "test" - assert vm.hda_disk_image == str(tmpdir / "QEMU" / "test") + assert vm.hda_disk_image == force_unix_path(str(tmpdir / "QEMU" / "test")) def test_hda_disk_image_ova(vm, tmpdir): @@ -398,7 +414,7 @@ def test_hda_disk_image_ova(vm, tmpdir): vm.manager.config.set("Server", "images_path", str(tmpdir)) vm.hda_disk_image = "test.ovf/test.vmdk" - assert vm.hda_disk_image == str(tmpdir / "QEMU" / "test.ovf" / "test.vmdk") + assert vm.hda_disk_image == force_unix_path(str(tmpdir / "QEMU" / "test.ovf" / "test.vmdk")) def test_hdb_disk_image(vm, tmpdir): @@ -406,9 +422,9 @@ def test_hdb_disk_image(vm, tmpdir): vm.manager.config.set("Server", "images_path", str(tmpdir)) vm.hdb_disk_image = str(tmpdir / "test") - assert vm.hdb_disk_image == str(tmpdir / "test") + assert vm.hdb_disk_image == force_unix_path(str(tmpdir / "test")) vm.hdb_disk_image = "test" - assert vm.hdb_disk_image == str(tmpdir / "QEMU" / "test") + assert vm.hdb_disk_image == force_unix_path(str(tmpdir / "QEMU" / "test")) def test_hdc_disk_image(vm, tmpdir): @@ -416,9 +432,9 @@ def test_hdc_disk_image(vm, tmpdir): vm.manager.config.set("Server", "images_path", str(tmpdir)) vm.hdc_disk_image = str(tmpdir / "test") - assert vm.hdc_disk_image == str(tmpdir / "test") + assert vm.hdc_disk_image == force_unix_path(str(tmpdir / "test")) vm.hdc_disk_image = "test" - assert vm.hdc_disk_image == str(tmpdir / "QEMU" / "test") + assert vm.hdc_disk_image == force_unix_path(str(tmpdir / "QEMU" / "test")) def test_hdd_disk_image(vm, tmpdir): @@ -426,9 +442,9 @@ def test_hdd_disk_image(vm, tmpdir): vm.manager.config.set("Server", "images_path", str(tmpdir)) vm.hdd_disk_image = str(tmpdir / "test") - assert vm.hdd_disk_image == str(tmpdir / "test") + assert vm.hdd_disk_image == force_unix_path(str(tmpdir / "test")) vm.hdd_disk_image = "test" - assert vm.hdd_disk_image == str(tmpdir / "QEMU" / "test") + assert vm.hdd_disk_image == force_unix_path(str(tmpdir / "QEMU" / "test")) def test_options(linux_platform, vm): diff --git a/tests/modules/vpcs/test_vpcs_vm.py b/tests/modules/vpcs/test_vpcs_vm.py index f133a525b..3d7d729c0 100644 --- a/tests/modules/vpcs/test_vpcs_vm.py +++ b/tests/modules/vpcs/test_vpcs_vm.py @@ -211,6 +211,7 @@ def test_add_nio_binding_udp(vm): assert nio.lport == 4242 +@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") def test_add_nio_binding_tap(vm, ethernet_device): with patch("gns3server.modules.base_manager.BaseManager.has_privileged_access", return_value=True): nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_tap", "tap_device": ethernet_device}) From a0987bbc921dfbcb437762e389dd25950603c5ab Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 22 Dec 2015 14:58:51 +0100 Subject: [PATCH 5/6] Fix status link in GNS3 homepage --- gns3server/templates/layout.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gns3server/templates/layout.html b/gns3server/templates/layout.html index 87eed6f35..54caef090 100644 --- a/gns3server/templates/layout.html +++ b/gns3server/templates/layout.html @@ -16,7 +16,7 @@ | Backup projects | - Status + Status {% block body %}{% endblock %} From 31046358ccce618fa0cc1443dbbdd58eb76adf22 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 22 Dec 2015 15:19:38 +0100 Subject: [PATCH 6/6] Add more informations in the debug status page * Number of VM in a project * Number of client connected --- gns3server/modules/project.py | 7 +++++++ gns3server/templates/status.html | 18 +++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gns3server/modules/project.py b/gns3server/modules/project.py index 4e758406d..26604066f 100644 --- a/gns3server/modules/project.py +++ b/gns3server/modules/project.py @@ -459,6 +459,13 @@ class Project: self._listeners.remove(queue) + @property + def listeners(self): + """ + List of current clients listening for event in this projects + """ + return self._listeners + @asyncio.coroutine def list_files(self): """ diff --git a/gns3server/templates/status.html b/gns3server/templates/status.html index 409536373..bed8c7973 100644 --- a/gns3server/templates/status.html +++ b/gns3server/templates/status.html @@ -6,11 +6,23 @@ The purpose of this page is to help for GNS3 debug.

Opened projects

-
    + + + + + + {% for project in project_manager.projects %} -
  • {{project.name}} ({{project.id}})
  • + + + + + + {% endfor %} - +
    NameID + VMsClients connected
    {{project.name}}{{project.id}}{{project.vms|length}}{{project.listeners|length}}
    +

    Ports reserved by GNS3

    TCP