mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
Revert move "/version" endpoint to "/server/version".
Move "/server/shutdown" endpoint to "/shutdown".
This commit is contained in:
parent
cd07a99118
commit
f47eb326c7
@ -228,7 +228,7 @@ class Compute:
|
||||
Check if remote server is accessible
|
||||
"""
|
||||
if not self._connected:
|
||||
response = yield from self._run_http_query("GET", "/server/version")
|
||||
response = yield from self._run_http_query("GET", "/version")
|
||||
|
||||
if "version" not in response.json:
|
||||
raise aiohttp.web.HTTPConflict(text="The server {} is not a GNS3 server".format(self._id))
|
||||
|
@ -25,7 +25,7 @@ from aiohttp.web import HTTPConflict
|
||||
class VersionHandler:
|
||||
|
||||
@Route.get(
|
||||
r"/server/version",
|
||||
r"/version",
|
||||
description="Retrieve the server version number",
|
||||
output=VERSION_SCHEMA)
|
||||
def version(request, response):
|
||||
@ -35,7 +35,7 @@ class VersionHandler:
|
||||
response.json({"version": __version__, "local": local_server})
|
||||
|
||||
@Route.post(
|
||||
r"/server/version",
|
||||
r"/version",
|
||||
description="Check if version is the same as the server",
|
||||
output=VERSION_SCHEMA,
|
||||
input=VERSION_SCHEMA,
|
||||
|
@ -33,7 +33,7 @@ class ServerHandler:
|
||||
|
||||
@classmethod
|
||||
@Route.post(
|
||||
r"/server/shutdown",
|
||||
r"/shutdown",
|
||||
description="Shutdown the local server",
|
||||
status_codes={
|
||||
201: "Server is shutting down",
|
||||
@ -71,7 +71,7 @@ class ServerHandler:
|
||||
response.set_status(201)
|
||||
|
||||
@Route.get(
|
||||
r"/server/version",
|
||||
r"/version",
|
||||
description="Retrieve the server version number",
|
||||
output=VERSION_SCHEMA)
|
||||
def version(request, response):
|
||||
@ -81,7 +81,7 @@ class ServerHandler:
|
||||
response.json({"version": __version__, "local": local_server})
|
||||
|
||||
@Route.post(
|
||||
r"/server/version",
|
||||
r"/version",
|
||||
description="Check if version is the same as the server",
|
||||
output=VERSION_SCHEMA,
|
||||
input=VERSION_SCHEMA,
|
||||
|
@ -200,7 +200,7 @@ def test_add_nio_binding_udp(vm, loop):
|
||||
@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.compute.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})
|
||||
nio = Qemu.instance().create_nio(vm.qemu_path, {"type": "nio_ethernet", "ethernet_device": ethernet_device})
|
||||
loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio)))
|
||||
assert nio.ethernet_device == ethernet_device
|
||||
|
||||
|
@ -220,24 +220,24 @@ def test_iou_nio_create_udp(http_compute, vm):
|
||||
|
||||
|
||||
def test_iou_nio_create_ethernet(http_compute, vm, ethernet_device):
|
||||
response = http_compute.post("/projects/{project_id}/iou/nodes/{node_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), {"type": "nio_generic_ethernet",
|
||||
response = http_compute.post("/projects/{project_id}/iou/nodes/{node_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), {"type": "nio_ethernet",
|
||||
"ethernet_device": ethernet_device,
|
||||
},
|
||||
example=True)
|
||||
assert response.status == 201
|
||||
assert response.route == "/projects/{project_id}/iou/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
|
||||
assert response.json["type"] == "nio_generic_ethernet"
|
||||
assert response.json["type"] == "nio_ethernet"
|
||||
assert response.json["ethernet_device"] == ethernet_device
|
||||
|
||||
|
||||
def test_iou_nio_create_ethernet_different_port(http_compute, vm, ethernet_device):
|
||||
response = http_compute.post("/projects/{project_id}/iou/nodes/{node_id}/adapters/0/ports/3/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), {"type": "nio_generic_ethernet",
|
||||
response = http_compute.post("/projects/{project_id}/iou/nodes/{node_id}/adapters/0/ports/3/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), {"type": "nio_ethernet",
|
||||
"ethernet_device": ethernet_device,
|
||||
},
|
||||
example=False)
|
||||
assert response.status == 201
|
||||
assert response.route == "/projects/{project_id}/iou/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
|
||||
assert response.json["type"] == "nio_generic_ethernet"
|
||||
assert response.json["type"] == "nio_ethernet"
|
||||
assert response.json["ethernet_device"] == ethernet_device
|
||||
|
||||
|
||||
|
@ -183,7 +183,7 @@ def test_qemu_nio_create_udp(http_compute, vm):
|
||||
|
||||
def test_qemu_nio_create_ethernet(http_compute, vm):
|
||||
http_compute.put("/projects/{project_id}/qemu/nodes/{node_id}".format(project_id=vm["project_id"], node_id=vm["node_id"]), {"adapters": 2})
|
||||
response = http_compute.post("/projects/{project_id}/qemu/nodes/{node_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), {"type": "nio_generic_ethernet",
|
||||
response = http_compute.post("/projects/{project_id}/qemu/nodes/{node_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), {"type": "nio_ethernet",
|
||||
"ethernet_device": "eth0",
|
||||
},
|
||||
example=True)
|
||||
|
@ -36,17 +36,17 @@ def test_shutdown_local(http_controller, web_server, config):
|
||||
|
||||
web_server.shutdown_server.return_value = hello()
|
||||
config.set("Server", "local", True)
|
||||
response = http_controller.post('/server/shutdown', example=True)
|
||||
response = http_controller.post('/shutdown', example=True)
|
||||
assert response.status == 201
|
||||
assert web_server.shutdown_server.called
|
||||
|
||||
|
||||
def test_shutdown_non_local(http_controller, web_server, config):
|
||||
"""
|
||||
Dissalow shutdown of a non local GNS3 server
|
||||
Disallow shutdown of a non local GNS3 server
|
||||
"""
|
||||
WebServer._instance = MagicMock()
|
||||
config.set("Server", "local", False)
|
||||
response = http_controller.post('/server/shutdown')
|
||||
response = http_controller.post('/shutdown')
|
||||
assert response.status == 403
|
||||
assert not web_server.shutdown_server.called
|
||||
|
Loading…
Reference in New Issue
Block a user