1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Use aiozipstream for snapshots.

Fix tests.
This commit is contained in:
grossmj 2019-02-28 17:25:05 +07:00
parent 52bfa636c1
commit 8cc8269842
13 changed files with 91 additions and 90 deletions

View File

@ -40,7 +40,6 @@ from ..config import Config
from ..utils.path import check_path_allowed, get_default_project_directory from ..utils.path import check_path_allowed, get_default_project_directory
from ..utils.asyncio.pool import Pool from ..utils.asyncio.pool import Pool
from ..utils.asyncio import locking from ..utils.asyncio import locking
from ..utils.asyncio import wait_run_in_executor
from ..utils.asyncio import aiozipstream from ..utils.asyncio import aiozipstream
from .export_project import export_project from .export_project import export_project
from .import_project import import_project from .import_project import import_project

View File

@ -20,14 +20,20 @@ import os
import uuid import uuid
import shutil import shutil
import tempfile import tempfile
import asyncio import aiofiles
import zipfile
import time
import aiohttp.web import aiohttp.web
from datetime import datetime, timezone from datetime import datetime, timezone
from ..utils.asyncio import wait_run_in_executor from ..utils.asyncio import wait_run_in_executor
from ..utils.asyncio import aiozipstream
from .export_project import export_project from .export_project import export_project
from .import_project import import_project from .import_project import import_project
import logging
log = logging.getLogger(__name__)
# The string use to extract the date from the filename # The string use to extract the date from the filename
FILENAME_TIME_FORMAT = "%d%m%y_%H%M%S" FILENAME_TIME_FORMAT = "%d%m%y_%H%M%S"
@ -73,15 +79,6 @@ class Snapshot:
def created_at(self): def created_at(self):
return int(self._created_at) return int(self._created_at)
def _create_snapshot_file(self, zipstream):
"""
Creates the snapshot file (to be run in its own thread)
"""
with open(self.path, "wb") as f:
for data in zipstream:
f.write(data)
async def create(self): async def create(self):
""" """
Create the snapshot Create the snapshot
@ -97,9 +94,14 @@ class Snapshot:
raise aiohttp.web.HTTPInternalServerError(text="Could not create the snapshot directory '{}': {}".format(snapshot_directory, e)) raise aiohttp.web.HTTPInternalServerError(text="Could not create the snapshot directory '{}': {}".format(snapshot_directory, e))
try: try:
begin = time.time()
with tempfile.TemporaryDirectory() as tmpdir: with tempfile.TemporaryDirectory() as tmpdir:
zipstream = await export_project(self._project, tmpdir, keep_compute_id=True, allow_all_nodes=True) with aiozipstream.ZipFile(compression=zipfile.ZIP_STORED) as zstream:
await wait_run_in_executor(self._create_snapshot_file, zipstream) await export_project(zstream, self._project, tmpdir, keep_compute_id=True, allow_all_nodes=True)
async with aiofiles.open(self.path, 'wb') as f:
async for chunk in zstream:
await f.write(chunk)
log.info("Snapshot '{}' created in {:.4f} seconds".format(self.path, time.time() - begin))
except (ValueError, OSError, RuntimeError) as e: except (ValueError, OSError, RuntimeError) as e:
raise aiohttp.web.HTTPConflict(text="Could not create snapshot file '{}': {}".format(self.path, e)) raise aiohttp.web.HTTPConflict(text="Could not create snapshot file '{}': {}".format(self.path, e))

View File

@ -313,7 +313,7 @@ class ProjectHandler:
# We need to do that now because export could failed and raise an HTTP error # We need to do that now because export could failed and raise an HTTP error
# that why response start need to be the later possible # that why response start need to be the later possible
response.content_type = 'application/octet-stream' response.content_type = 'application/gns3project'
response.headers['CONTENT-DISPOSITION'] = 'attachment; filename="{}.gns3project"'.format(project.name) response.headers['CONTENT-DISPOSITION'] = 'attachment; filename="{}.gns3project"'.format(project.name)
response.enable_chunked_encoding() response.enable_chunked_encoding()
await response.prepare(request) await response.prepare(request)

View File

@ -29,6 +29,7 @@ from tests.utils import AsyncioMagicMock, AsyncioBytesIO
from gns3server.controller.project import Project from gns3server.controller.project import Project
from gns3server.controller.export_project import export_project, _is_exportable from gns3server.controller.export_project import export_project, _is_exportable
from gns3server.utils.asyncio import aiozipstream
@pytest.fixture @pytest.fixture
@ -51,6 +52,13 @@ def node(controller, project, async_run):
return node return node
async def write_file(path, z):
with open(path, 'wb') as f:
async for chunk in z:
f.write(chunk)
def test_exportable_files(): def test_exportable_files():
assert _is_exportable("hello/world") assert _is_exportable("hello/world")
assert not _is_exportable("project-files/tmp") assert not _is_exportable("project-files/tmp")
@ -103,12 +111,10 @@ def test_export(tmpdir, project, async_run):
with open(os.path.join(path, "project-files", "snapshots", "test"), 'w+') as f: with open(os.path.join(path, "project-files", "snapshots", "test"), 'w+') as f:
f.write("WORLD") f.write("WORLD")
with patch("gns3server.compute.Dynamips.get_images_directory", return_value=str(tmpdir / "IOS"),): with aiozipstream.ZipFile() as z:
z = async_run(export_project(project, str(tmpdir), include_images=False)) with patch("gns3server.compute.Dynamips.get_images_directory", return_value=str(tmpdir / "IOS"),):
async_run(export_project(z, project, str(tmpdir), include_images=False))
with open(str(tmpdir / 'zipfile.zip'), 'wb') as f: async_run(write_file(str(tmpdir / 'zipfile.zip'), z))
for data in z:
f.write(data)
with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip: with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip:
with myzip.open("vm-1/dynamips/test") as myfile: with myzip.open("vm-1/dynamips/test") as myfile:
@ -128,7 +134,7 @@ def test_export(tmpdir, project, async_run):
assert topo["computes"] == [] assert topo["computes"] == []
def test_export_vm(tmpdir, project, async_run, controller): def test_export_vm(tmpdir, project, async_run):
""" """
If data is on a remote server export it locally before If data is on a remote server export it locally before
sending it in the archive. sending it in the archive.
@ -154,12 +160,10 @@ def test_export_vm(tmpdir, project, async_run, controller):
with open(os.path.join(path, "test.gns3"), 'w+') as f: with open(os.path.join(path, "test.gns3"), 'w+') as f:
f.write("{}") f.write("{}")
z = async_run(export_project(project, str(tmpdir))) with aiozipstream.ZipFile() as z:
assert compute.list_files.called async_run(export_project(z, project, str(tmpdir)))
assert compute.list_files.called
with open(str(tmpdir / 'zipfile.zip'), 'wb') as f: async_run(write_file(str(tmpdir / 'zipfile.zip'), z))
for data in z:
f.write(data)
with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip: with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip:
with myzip.open("vm-1/dynamips/test") as myfile: with myzip.open("vm-1/dynamips/test") as myfile:
@ -169,7 +173,7 @@ def test_export_vm(tmpdir, project, async_run, controller):
def test_export_disallow_running(tmpdir, project, node, async_run): def test_export_disallow_running(tmpdir, project, node, async_run):
""" """
Dissallow export when a node is running Disallow export when a node is running
""" """
path = project.path path = project.path
@ -189,12 +193,13 @@ def test_export_disallow_running(tmpdir, project, node, async_run):
node._status = "started" node._status = "started"
with pytest.raises(aiohttp.web.HTTPConflict): with pytest.raises(aiohttp.web.HTTPConflict):
async_run(export_project(project, str(tmpdir))) with aiozipstream.ZipFile() as z:
async_run(export_project(z, project, str(tmpdir)))
def test_export_disallow_some_type(tmpdir, project, async_run): def test_export_disallow_some_type(tmpdir, project, async_run):
""" """
Dissalow export for some node type Disallow export for some node type
""" """
path = project.path path = project.path
@ -213,8 +218,10 @@ def test_export_disallow_some_type(tmpdir, project, async_run):
json.dump(topology, f) json.dump(topology, f)
with pytest.raises(aiohttp.web.HTTPConflict): with pytest.raises(aiohttp.web.HTTPConflict):
z = async_run(export_project(project, str(tmpdir))) with aiozipstream.ZipFile() as z:
z = async_run(export_project(project, str(tmpdir), allow_all_nodes=True)) async_run(export_project(z, project, str(tmpdir)))
with aiozipstream.ZipFile() as z:
async_run(export_project(z, project, str(tmpdir), allow_all_nodes=True))
# VirtualBox is always disallowed # VirtualBox is always disallowed
topology = { topology = {
@ -232,7 +239,8 @@ def test_export_disallow_some_type(tmpdir, project, async_run):
with open(os.path.join(path, "test.gns3"), 'w+') as f: with open(os.path.join(path, "test.gns3"), 'w+') as f:
json.dump(topology, f) json.dump(topology, f)
with pytest.raises(aiohttp.web.HTTPConflict): with pytest.raises(aiohttp.web.HTTPConflict):
z = async_run(export_project(project, str(tmpdir), allow_all_nodes=True)) with aiozipstream.ZipFile() as z:
async_run(export_project(z, project, str(tmpdir), allow_all_nodes=True))
def test_export_fix_path(tmpdir, project, async_run): def test_export_fix_path(tmpdir, project, async_run):
@ -264,10 +272,9 @@ def test_export_fix_path(tmpdir, project, async_run):
with open(os.path.join(path, "test.gns3"), 'w+') as f: with open(os.path.join(path, "test.gns3"), 'w+') as f:
json.dump(topology, f) json.dump(topology, f)
z = async_run(export_project(project, str(tmpdir))) with aiozipstream.ZipFile() as z:
with open(str(tmpdir / 'zipfile.zip'), 'wb') as f: async_run(export_project(z, project, str(tmpdir)))
for data in z: async_run(write_file(str(tmpdir / 'zipfile.zip'), z))
f.write(data)
with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip: with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip:
with myzip.open("project.gns3") as myfile: with myzip.open("project.gns3") as myfile:
@ -303,11 +310,10 @@ def test_export_with_images(tmpdir, project, async_run):
with open(os.path.join(path, "test.gns3"), 'w+') as f: with open(os.path.join(path, "test.gns3"), 'w+') as f:
json.dump(topology, f) json.dump(topology, f)
with patch("gns3server.compute.Dynamips.get_images_directory", return_value=str(tmpdir / "IOS"),): with aiozipstream.ZipFile() as z:
z = async_run(export_project(project, str(tmpdir), include_images=True)) with patch("gns3server.compute.Dynamips.get_images_directory", return_value=str(tmpdir / "IOS"),):
with open(str(tmpdir / 'zipfile.zip'), 'wb') as f: async_run(export_project(z, project, str(tmpdir), include_images=True))
for data in z: async_run(write_file(str(tmpdir / 'zipfile.zip'), z))
f.write(data)
with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip: with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip:
myzip.getinfo("images/IOS/test.image") myzip.getinfo("images/IOS/test.image")
@ -341,11 +347,9 @@ def test_export_keep_compute_id(tmpdir, project, async_run):
} }
json.dump(data, f) json.dump(data, f)
z = async_run(export_project(project, str(tmpdir), keep_compute_id=True)) with aiozipstream.ZipFile() as z:
async_run(export_project(z, project, str(tmpdir), keep_compute_id=True))
with open(str(tmpdir / 'zipfile.zip'), 'wb') as f: async_run(write_file(str(tmpdir / 'zipfile.zip'), z))
for data in z:
f.write(data)
with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip: with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip:
with myzip.open("project.gns3") as myfile: with myzip.open("project.gns3") as myfile:
@ -353,7 +357,8 @@ def test_export_keep_compute_id(tmpdir, project, async_run):
assert topo["nodes"][0]["compute_id"] == "6b7149c8-7d6e-4ca0-ab6b-daa8ab567be0" assert topo["nodes"][0]["compute_id"] == "6b7149c8-7d6e-4ca0-ab6b-daa8ab567be0"
assert len(topo["computes"]) == 1 assert len(topo["computes"]) == 1
def test_export_images_from_vm(tmpdir, project, async_run, controller):
def test_export_images_from_vm(tmpdir, project, async_run):
""" """
If data is on a remote server export it locally before If data is on a remote server export it locally before
sending it in the archive. sending it in the archive.
@ -405,12 +410,10 @@ def test_export_images_from_vm(tmpdir, project, async_run, controller):
with open(os.path.join(path, "test.gns3"), 'w+') as f: with open(os.path.join(path, "test.gns3"), 'w+') as f:
f.write(json.dumps(topology)) f.write(json.dumps(topology))
z = async_run(export_project(project, str(tmpdir), include_images=True)) with aiozipstream.ZipFile() as z:
assert compute.list_files.called async_run(export_project(z, project, str(tmpdir), include_images=True))
assert compute.list_files.called
with open(str(tmpdir / 'zipfile.zip'), 'wb') as f: async_run(write_file(str(tmpdir / 'zipfile.zip'), z))
for data in z:
f.write(data)
with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip: with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip:
with myzip.open("vm-1/dynamips/test") as myfile: with myzip.open("vm-1/dynamips/test") as myfile:
@ -450,12 +453,9 @@ def test_export_with_ignoring_snapshots(tmpdir, project, async_run):
os.makedirs(snapshots_dir) os.makedirs(snapshots_dir)
Path(os.path.join(snapshots_dir, 'snap.gns3project')).touch() Path(os.path.join(snapshots_dir, 'snap.gns3project')).touch()
z = async_run(export_project(project, str(tmpdir), keep_compute_id=True)) with aiozipstream.ZipFile() as z:
async_run(export_project(z, project, str(tmpdir), keep_compute_id=True))
with open(str(tmpdir / 'zipfile.zip'), 'wb') as f: async_run(write_file(str(tmpdir / 'zipfile.zip'), z))
for data in z:
f.write(data)
with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip: with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip:
assert not os.path.join('snapshots', 'snap.gns3project') in [f.filename for f in myzip.filelist] assert not os.path.join('snapshots', 'snap.gns3project') in [f.filename for f in myzip.filelist]

View File

@ -64,7 +64,7 @@ def test_cloud_nio_create_udp(http_compute, vm):
"rhost": "127.0.0.1"}, "rhost": "127.0.0.1"},
example=True) example=True)
assert response.status == 201 assert response.status == 201
assert response.route == "/projects/{project_id}/cloud/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/cloud/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -82,7 +82,7 @@ def test_cloud_nio_update_udp(http_compute, vm):
"filters": {}}, "filters": {}},
example=True) example=True)
assert response.status == 201, response.body.decode() assert response.status == 201, response.body.decode()
assert response.route == "/projects/{project_id}/cloud/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/cloud/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -93,7 +93,7 @@ def test_cloud_delete_nio(http_compute, vm):
"rhost": "127.0.0.1"}) "rhost": "127.0.0.1"})
response = http_compute.delete("/projects/{project_id}/cloud/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True) response = http_compute.delete("/projects/{project_id}/cloud/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True)
assert response.status == 204 assert response.status == 204
assert response.route == "/projects/{project_id}/cloud/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/cloud/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
def test_cloud_delete(http_compute, vm): def test_cloud_delete(http_compute, vm):

View File

@ -120,7 +120,7 @@ def test_docker_nio_create_udp(http_compute, vm):
"rhost": "127.0.0.1"}, "rhost": "127.0.0.1"},
example=True) example=True)
assert response.status == 201 assert response.status == 201
assert response.route == "/projects/{project_id}/docker/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/docker/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -141,14 +141,14 @@ def test_docker_update_nio(http_compute, vm):
}, },
example=True) example=True)
assert response.status == 201, response.body.decode() assert response.status == 201, response.body.decode()
assert response.route == "/projects/{project_id}/docker/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/docker/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
def test_docker_delete_nio(http_compute, vm): def test_docker_delete_nio(http_compute, vm):
with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.adapter_remove_nio_binding") as mock: with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.adapter_remove_nio_binding") as mock:
response = http_compute.delete("/projects/{project_id}/docker/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True) response = http_compute.delete("/projects/{project_id}/docker/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True)
assert response.status == 204 assert response.status == 204
assert response.route == "/projects/{project_id}/docker/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/docker/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
def test_docker_update(http_compute, vm, tmpdir, free_console_port): def test_docker_update(http_compute, vm, tmpdir, free_console_port):

View File

@ -201,7 +201,7 @@ def test_iou_nio_create_udp(http_compute, vm):
"rhost": "127.0.0.1"}, "rhost": "127.0.0.1"},
example=True) example=True)
assert response.status == 201 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.route == r"/projects/{project_id}/iou/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -219,7 +219,7 @@ def test_iou_nio_update_udp(http_compute, vm):
"filters": {}}, "filters": {}},
example=True) example=True)
assert response.status == 201, response.body.decode() assert response.status == 201, response.body.decode()
assert response.route == "/projects/{project_id}/iou/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/iou/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -229,7 +229,7 @@ def test_iou_nio_create_ethernet(http_compute, vm, ethernet_device):
}, },
example=True) example=True)
assert response.status == 201 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.route == r"/projects/{project_id}/iou/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_ethernet" assert response.json["type"] == "nio_ethernet"
assert response.json["ethernet_device"] == ethernet_device assert response.json["ethernet_device"] == ethernet_device
@ -240,7 +240,7 @@ def test_iou_nio_create_ethernet_different_port(http_compute, vm, ethernet_devic
}, },
example=False) example=False)
assert response.status == 201 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.route == r"/projects/{project_id}/iou/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_ethernet" assert response.json["type"] == "nio_ethernet"
assert response.json["ethernet_device"] == ethernet_device assert response.json["ethernet_device"] == ethernet_device
@ -250,7 +250,7 @@ def test_iou_nio_create_tap(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_tap", 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_tap",
"tap_device": ethernet_device}) "tap_device": ethernet_device})
assert response.status == 201 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.route == r"/projects/{project_id}/iou/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_tap" assert response.json["type"] == "nio_tap"
@ -261,7 +261,7 @@ def test_iou_delete_nio(http_compute, vm):
"rhost": "127.0.0.1"}) "rhost": "127.0.0.1"})
response = http_compute.delete("/projects/{project_id}/iou/nodes/{node_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True) response = http_compute.delete("/projects/{project_id}/iou/nodes/{node_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True)
assert response.status == 204 assert response.status == 204
assert response.route == "/projects/{project_id}/iou/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/iou/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
def test_iou_start_capture(http_compute, vm, tmpdir, project): def test_iou_start_capture(http_compute, vm, tmpdir, project):

View File

@ -65,7 +65,7 @@ def test_nat_nio_create_udp(http_compute, vm):
"rhost": "127.0.0.1"}, "rhost": "127.0.0.1"},
example=True) example=True)
assert response.status == 201 assert response.status == 201
assert response.route == "/projects/{project_id}/nat/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/nat/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -83,7 +83,7 @@ def test_nat_nio_update_udp(http_compute, vm):
"filters": {}}, "filters": {}},
example=True) example=True)
assert response.status == 201, response.body.decode() assert response.status == 201, response.body.decode()
assert response.route == "/projects/{project_id}/nat/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/nat/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -97,7 +97,7 @@ def test_nat_delete_nio(http_compute, vm):
response = http_compute.delete("/projects/{project_id}/nat/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True) response = http_compute.delete("/projects/{project_id}/nat/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True)
assert mock_remove_nio.called assert mock_remove_nio.called
assert response.status == 204 assert response.status == 204
assert response.route == "/projects/{project_id}/nat/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/nat/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
def test_nat_delete(http_compute, vm): def test_nat_delete(http_compute, vm):

View File

@ -189,7 +189,7 @@ def test_qemu_nio_create_udp(http_compute, vm):
"rhost": "127.0.0.1"}, "rhost": "127.0.0.1"},
example=True) example=True)
assert response.status == 201 assert response.status == 201
assert response.route == "/projects/{project_id}/qemu/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/qemu/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -208,7 +208,7 @@ def test_qemu_nio_update_udp(http_compute, vm):
"filters": {}}, "filters": {}},
example=True) example=True)
assert response.status == 201, response.body.decode() assert response.status == 201, response.body.decode()
assert response.route == "/projects/{project_id}/qemu/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/qemu/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -221,7 +221,7 @@ def test_qemu_delete_nio(http_compute, vm):
"rhost": "127.0.0.1"}) "rhost": "127.0.0.1"})
response = http_compute.delete("/projects/{project_id}/qemu/nodes/{node_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True) response = http_compute.delete("/projects/{project_id}/qemu/nodes/{node_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True)
assert response.status == 204 assert response.status == 204
assert response.route == "/projects/{project_id}/qemu/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/qemu/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
def test_qemu_list_binaries(http_compute, vm): def test_qemu_list_binaries(http_compute, vm):

View File

@ -55,7 +55,7 @@ def test_traceng_nio_create_udp(http_compute, vm):
"rhost": "127.0.0.1"}, "rhost": "127.0.0.1"},
example=True) example=True)
assert response.status == 201 assert response.status == 201
assert response.route == "/projects/{project_id}/traceng/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/traceng/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -76,7 +76,7 @@ def test_traceng_nio_update_udp(http_compute, vm):
"filters": {}}, "filters": {}},
example=True) example=True)
assert response.status == 201, response.body.decode("utf-8") assert response.status == 201, response.body.decode("utf-8")
assert response.route == "/projects/{project_id}/traceng/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/traceng/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -88,7 +88,7 @@ def test_traceng_delete_nio(http_compute, vm):
"rhost": "127.0.0.1"}) "rhost": "127.0.0.1"})
response = http_compute.delete("/projects/{project_id}/traceng/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True) response = http_compute.delete("/projects/{project_id}/traceng/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True)
assert response.status == 204, response.body.decode() assert response.status == 204, response.body.decode()
assert response.route == "/projects/{project_id}/traceng/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/traceng/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
def test_traceng_start(http_compute, vm): def test_traceng_start(http_compute, vm):

View File

@ -108,7 +108,7 @@ def test_vbox_nio_create_udp(http_compute, vm):
assert args[0] == 0 assert args[0] == 0
assert response.status == 201 assert response.status == 201
assert response.route == "/projects/{project_id}/virtualbox/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/virtualbox/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -127,7 +127,7 @@ def test_virtualbox_nio_update_udp(http_compute, vm):
"filters": {}}, "filters": {}},
example=True) example=True)
assert response.status == 201, response.body.decode() assert response.status == 201, response.body.decode()
assert response.route == "/projects/{project_id}/virtualbox/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/virtualbox/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -141,7 +141,7 @@ def test_vbox_delete_nio(http_compute, vm):
assert args[0] == 0 assert args[0] == 0
assert response.status == 204 assert response.status == 204
assert response.route == "/projects/{project_id}/virtualbox/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/virtualbox/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
def test_vbox_update(http_compute, vm, free_console_port): def test_vbox_update(http_compute, vm, free_console_port):

View File

@ -116,7 +116,7 @@ def test_vmware_nio_create_udp(http_compute, vm):
assert args[0] == 0 assert args[0] == 0
assert response.status == 201 assert response.status == 201
assert response.route == "/projects/{project_id}/vmware/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/vmware/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -135,7 +135,7 @@ def test_vmware_nio_update_udp(http_compute, vm):
"filters": {}}, "filters": {}},
example=True) example=True)
assert response.status == 201, response.body.decode() assert response.status == 201, response.body.decode()
assert response.route == "/projects/{project_id}/vmware/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/vmware/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -149,7 +149,7 @@ def test_vmware_delete_nio(http_compute, vm):
assert args[0] == 0 assert args[0] == 0
assert response.status == 204 assert response.status == 204
assert response.route == "/projects/{project_id}/vmware/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/vmware/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
def test_vmware_update(http_compute, vm, free_console_port): def test_vmware_update(http_compute, vm, free_console_port):

View File

@ -70,7 +70,7 @@ def test_vpcs_nio_create_udp(http_compute, vm):
"rhost": "127.0.0.1"}, "rhost": "127.0.0.1"},
example=True) example=True)
assert response.status == 201 assert response.status == 201
assert response.route == "/projects/{project_id}/vpcs/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/vpcs/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -91,7 +91,7 @@ def test_vpcs_nio_update_udp(http_compute, vm):
"filters": {}}, "filters": {}},
example=True) example=True)
assert response.status == 201, response.body.decode("utf-8") assert response.status == 201, response.body.decode("utf-8")
assert response.route == "/projects/{project_id}/vpcs/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/vpcs/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp" assert response.json["type"] == "nio_udp"
@ -103,7 +103,7 @@ def test_vpcs_delete_nio(http_compute, vm):
"rhost": "127.0.0.1"}) "rhost": "127.0.0.1"})
response = http_compute.delete("/projects/{project_id}/vpcs/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True) response = http_compute.delete("/projects/{project_id}/vpcs/nodes/{node_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], node_id=vm["node_id"]), example=True)
assert response.status == 204, response.body.decode() assert response.status == 204, response.body.decode()
assert response.route == "/projects/{project_id}/vpcs/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio" assert response.route == r"/projects/{project_id}/vpcs/nodes/{node_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
def test_vpcs_start(http_compute, vm): def test_vpcs_start(http_compute, vm):