def iou_device(local_server, project): from gns3.modules.iou.iou_device import IOUDevice from gns3.modules.iou import IOU device = IOUDevice(IOU(), local_server, project) device._iou_device_id = str(uuid.uuid4()) settings = device._settings settings["name"] = "IOU 1" device._settings = settings device.setInitialized(True) return device
def test_load(local_server, project, fake_bin): uuid = uuid4() iou_device = IOUDevice(IOU(), local_server, project) nio_node = { "description": "IOU device", "id": 1, "ports": [ { "adapter_number": 0, "id": 1, "name": "Hyper Ethernet0/0", "port_number": 0 }, ], "properties": { "name": "IOU 1", "path": fake_bin, "startup_config": "/tmp", "ethernet_adapters": 1, "serial_adapters": 0, }, "server_id": 1, "type": "IOUDevice", "vm_id": uuid } with patch("gns3.modules.iou.iou_device.IOUDevice.setup") as mock: iou_device.load(nio_node) iou_device._addAdapters(1, 0) assert mock.called (path, name, vm_id, settings), kwargs = mock.call_args assert path == fake_bin assert name == "IOU 1" assert settings == { "ethernet_adapters": 1, "serial_adapters": 0, "startup_config": "/tmp" } assert vm_id == uuid iou_device.loaded_signal.emit() assert iou_device._ports[0].name() == "Hyper Ethernet0/0"
def test_dump(local_server, project): iou_device = IOUDevice(IOU(), local_server, project) iou_device._settings["name"] = "IOU 1" iou_device._settings["path"] = "test.bin" iou_device._settings["initial_config"] = "/tmp" iou_device._settings["ethernet_adapters"] = 2 iou_device._settings["serial_adapters"] = 2 iou_device._settings["l1_keepalives"] = True iou_device._settings["ram"] = 256 iou_device._settings["nvram"] = 128 iou_device._settings["use_default_iou_values"] = True iou_device._addAdapters(iou_device._settings["ethernet_adapters"], iou_device._settings["serial_adapters"]) assert iou_device.dump() == { "description": "IOU device", "id": iou_device.id(), "ports": [ {"adapter_number": 0, "id": 1, "name": "Ethernet0/0", "port_number": 0}, {"adapter_number": 0, "id": 2, "name": "Ethernet0/1", "port_number": 1}, {"adapter_number": 0, "id": 3, "name": "Ethernet0/2", "port_number": 2}, {"adapter_number": 0, "id": 4, "name": "Ethernet0/3", "port_number": 3}, {"adapter_number": 1, "id": 5, "name": "Ethernet1/0", "port_number": 0}, {"adapter_number": 1, "id": 6, "name": "Ethernet1/1", "port_number": 1}, {"adapter_number": 1, "id": 7, "name": "Ethernet1/2", "port_number": 2}, {"adapter_number": 1, "id": 8, "name": "Ethernet1/3", "port_number": 3}, {"adapter_number": 2, "id": 9, "name": "Serial2/0", "port_number": 0}, {"adapter_number": 2, "id": 10, "name": "Serial2/1", "port_number": 1}, {"adapter_number": 2, "id": 11, "name": "Serial2/2", "port_number": 2}, {"adapter_number": 2, "id": 12, "name": "Serial2/3", "port_number": 3}, {"adapter_number": 3, "id": 13, "name": "Serial3/0", "port_number": 0}, {"adapter_number": 3, "id": 14, "name": "Serial3/1", "port_number": 1}, {"adapter_number": 3, "id": 15, "name": "Serial3/2", "port_number": 2}, {"adapter_number": 3, "id": 16, "name": "Serial3/3", "port_number": 3} ], "properties": { "name": "IOU 1", "path": "test.bin", "initial_config": "/tmp", "ethernet_adapters": 2, "serial_adapters": 2, "l1_keepalives": True, "ram": 256, "nvram": 128, "use_default_iou_values": True }, "server_id": local_server.id(), "type": "IOUDevice", "vm_id": None }
log = logging.getLogger(__name__) CATEGORY_TO_ID = { "firewall": 3, "guest": 2, "switch": 1, "multilayer_switch": 1, "router": 0 } TEMPLATE_TYPE_TO_CONFIGURATION_PAGE = { "ethernet_switch": Builtin.configurationPage("ethernet_switch"), "ethernet_hub": Builtin.configurationPage("ethernet_hub"), "cloud": Builtin.configurationPage("cloud"), "dynamips": Dynamips.configurationPage(), "iou": IOU.configurationPage(), "vpcs": VPCS.configurationPage(), "traceng": TraceNG.configurationPage(), "virtualbox": VirtualBox.configurationPage(), "qemu": Qemu.configurationPage(), "vmware": VMware.configurationPage(), "docker": Docker.configurationPage() } class NodesView(QtWidgets.QTreeWidget): """ Nodes view to list the nodes. :param parent: parent widget """
def test_dump(local_server, project): iou_device = IOUDevice(IOU(), local_server, project) iou_device._settings["name"] = "IOU 1" iou_device._settings["path"] = "test.bin" iou_device._settings["initial_config"] = "/tmp" assert iou_device.dump() == { "description": "IOU device", "id": iou_device.id(), "ports": [{ "adapter_number": 0, "id": 1, "name": "Ethernet0/0", "port_number": 0 }, { "adapter_number": 0, "id": 2, "name": "Ethernet0/1", "port_number": 1 }, { "adapter_number": 0, "id": 3, "name": "Ethernet0/2", "port_number": 2 }, { "adapter_number": 0, "id": 4, "name": "Ethernet0/3", "port_number": 3 }, { "adapter_number": 1, "id": 5, "name": "Ethernet1/0", "port_number": 0 }, { "adapter_number": 1, "id": 6, "name": "Ethernet1/1", "port_number": 1 }, { "adapter_number": 1, "id": 7, "name": "Ethernet1/2", "port_number": 2 }, { "adapter_number": 1, "id": 8, "name": "Ethernet1/3", "port_number": 3 }, { "adapter_number": 2, "id": 9, "name": "Serial2/0", "port_number": 0 }, { "adapter_number": 2, "id": 10, "name": "Serial2/1", "port_number": 1 }, { "adapter_number": 2, "id": 11, "name": "Serial2/2", "port_number": 2 }, { "adapter_number": 2, "id": 12, "name": "Serial2/3", "port_number": 3 }, { "adapter_number": 3, "id": 13, "name": "Serial3/0", "port_number": 0 }, { "adapter_number": 3, "id": 14, "name": "Serial3/1", "port_number": 1 }, { "adapter_number": 3, "id": 15, "name": "Serial3/2", "port_number": 2 }, { "adapter_number": 3, "id": 16, "name": "Serial3/3", "port_number": 3 }], "properties": { "name": "IOU 1", "path": "test.bin", "initial_config": "/tmp" }, "server_id": local_server.id(), "type": "IOUDevice", "vm_id": None }
CATEGORY_TO_ID = { "firewall": 3, "guest": 2, "switch": 1, "multilayer_switch": 1, "router": 0 } TEMPLATE_TYPE_TO_CONFIGURATION_PAGE = { "ethernet_switch": Builtin.configurationPage("ethernet_switch"), "ethernet_hub": Builtin.configurationPage("ethernet_hub"), "cloud": Builtin.configurationPage("cloud"), "dynamips": Dynamips.configurationPage(), "iou": IOU.configurationPage(), "vpcs": VPCS.configurationPage(), "traceng": TraceNG.configurationPage(), "virtualbox": VirtualBox.configurationPage(), "qemu": Qemu.configurationPage(), "vmware": VMware.configurationPage(), "docker": Docker.configurationPage() } class NodesView(QtWidgets.QTreeWidget): """ Nodes view to list the nodes. :param parent: parent widget