From 476a3c42b6a279fd342379acb482cdfa876370cf Mon Sep 17 00:00:00 2001 From: Joe Bowen Date: Tue, 6 May 2014 10:42:38 -0600 Subject: [PATCH] Added NIO TAP support --- gns3server/modules/vpcs/__init__.py | 7 ------ gns3server/modules/vpcs/vpcs_device.py | 6 ++++- tests/vpcs/test_vpcs_device.py | 32 +++++++++++++------------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/gns3server/modules/vpcs/__init__.py b/gns3server/modules/vpcs/__init__.py index 251cb280..81209123 100644 --- a/gns3server/modules/vpcs/__init__.py +++ b/gns3server/modules/vpcs/__init__.py @@ -182,13 +182,6 @@ class VPCS(IModule): self._current_console_port = self._console_start_port_range self._current_udp_port = self._udp_start_port_range - if self._VPCSrc and os.path.isfile(self._VPCSrc): - try: - log.info("deleting VPCSrc file {}".format(self._VPCSrc)) - os.remove(self._VPCSrc) - except OSError as e: - log.warn("could not delete VPCSrc file {}: {}".format(self._VPCSrc, e)) - log.info("VPCS module has been reset") @IModule.route("VPCS.settings") diff --git a/gns3server/modules/vpcs/vpcs_device.py b/gns3server/modules/vpcs/vpcs_device.py index 88f07f85..bec99df4 100644 --- a/gns3server/modules/vpcs/vpcs_device.py +++ b/gns3server/modules/vpcs/vpcs_device.py @@ -450,7 +450,11 @@ class VPCSDevice(object): command.extend(["-s", str(nio.lport)]) command.extend(["-c", str(nio.rport)]) command.extend(["-t", str(nio.rhost)]) - + + elif isinstance(nio, NIO_TAP): + # TAP interface + command.extend(["-e"]) #, str(nio.tap_device)]) #TODO: Fix, currently vpcs doesn't allow specific tap_device + command.extend(["-m", str(self._id)]) #The unique ID is used to set the mac address offset if self._script_file: command.extend([self._script_file]) diff --git a/tests/vpcs/test_vpcs_device.py b/tests/vpcs/test_vpcs_device.py index 0749c97f..13609506 100644 --- a/tests/vpcs/test_vpcs_device.py +++ b/tests/vpcs/test_vpcs_device.py @@ -1,29 +1,29 @@ -from gns3server.modules.iou import IOUDevice +from gns3server.modules.vpcs import VPCSDevice import os import pytest @pytest.fixture(scope="session") -def iou(request): +def vpcs(request): cwd = os.path.dirname(os.path.abspath(__file__)) - iou_path = os.path.join(cwd, "i86bi_linux-ipbase-ms-12.4.bin") - iou_device = IOUDevice(iou_path, "/tmp") - iou_device.start() - request.addfinalizer(iou_device.delete) - return iou_device + vpcs_path = os.path.join(cwd, "vpcs") + vpcs_device = VPCSDevice(vpcs_path, "/tmp") + vpcs_device.start() + request.addfinalizer(vpcs_device.delete) + return vpcs_device -def test_iou_is_started(iou): +def test_vpcs_is_started(vpcs): - print(iou.command()) - assert iou.id == 1 # we should have only one IOU running! - assert iou.is_running() + print(vpcs.command()) + assert vpcs.id == 1 # we should have only one VPCS running! + assert vpcs.is_running() -def test_iou_restart(iou): +def test_vpcs_restart(vpcs): - iou.stop() - assert not iou.is_running() - iou.start() - assert iou.is_running() + vpcs.stop() + assert not vpcs.is_running() + vpcs.start() + assert vpcs.is_running()