Beispiel #1
0
def test_load_1_2(local_server, project, fake_bin):

    uuid = uuid4()
    iou_device = IOUDevice(IOU(), local_server, project)
    nio_node = {
        "description": "IOU device",
        "id": 1,
        "ports": [
            {
                "slot_number": 0,
                "id": 1,
                "name": "Hyper Ethernet0/0",
                "port_number": 0},
        ],
        "properties": {
            "name": "IOU 1",
            "path": fake_bin,
            "initial_config": "/tmp"
        },
        "server_id": 1,
        "type": "IOUDevice",
        "vm_id": uuid
    }
    with patch("gns3.modules.iou.iou_device.IOUDevice.setup") as mock:
        iou_device.load(nio_node)

        assert mock.called
        (path, name, vm_id, settings), kwargs = mock.call_args
        assert path == fake_bin
        assert name == "IOU 1"
        assert settings == {"initial_config": "/tmp"}
        assert vm_id == uuid

    iou_device.updated_signal.emit()
    assert iou_device._ports[0].name() == "Hyper Ethernet0/0"
Beispiel #2
0
def reset_modules():
    """
    Reset modules (VPCS, VirtualBox...) internal variables.
    """

    from gns3.ports.port import Port
    from gns3.modules.vpcs.vpcs_node import VPCSNode
    from gns3.modules.virtualbox.virtualbox_vm import VirtualBoxVM
    from gns3.modules.iou.iou_device import IOUDevice
    from gns3.compute_manager import ComputeManager

    ComputeManager.reset()
    VPCSNode.reset()
    VirtualBoxVM.reset()
    IOUDevice.reset()
Beispiel #3
0
def reset_modules():
    """
    Reset modules (VPCS, VirtualBox...) internal variables.
    """

    from gns3.ports.port import Port
    from gns3.modules.vpcs.vpcs_node import VPCSNode
    from gns3.modules.virtualbox.virtualbox_vm import VirtualBoxVM
    from gns3.modules.iou.iou_device import IOUDevice
    from gns3.compute_manager import ComputeManager

    ComputeManager.reset()
    VPCSNode.reset()
    VirtualBoxVM.reset()
    IOUDevice.reset()
Beispiel #4
0
def reset_modules():
    """
    Reset modules (VPCS, VirtualBox...) internal variables.
    """

    from gns3.http_client import HTTPClient
    from gns3.ports.port import Port
    from gns3.modules.vpcs.vpcs_device import VPCSDevice
    from gns3.modules.virtualbox.virtualbox_vm import VirtualBoxVM
    from gns3.modules.iou.iou_device import IOUDevice

    Port.reset()
    VPCSDevice.reset()
    VirtualBoxVM.reset()
    HTTPClient.reset()
    IOUDevice.reset()
Beispiel #5
0
def test_load_1_2(local_server, project, fake_bin):

    uuid = uuid4()
    iou_device = IOUDevice(IOU(), local_server, project)
    nio_node = {
        "description":
        "IOU device",
        "id":
        1,
        "ports": [
            {
                "slot_number": 0,
                "id": 1,
                "name": "Hyper Ethernet0/0",
                "port_number": 0
            },
        ],
        "properties": {
            "name": "IOU 1",
            "path": fake_bin,
            "initial_config": "/tmp"
        },
        "server_id":
        1,
        "type":
        "IOUDevice",
        "vm_id":
        uuid
    }
    with patch("gns3.modules.iou.iou_device.IOUDevice.setup") as mock:
        iou_device.load(nio_node)

        assert mock.called
        (path, name, console, vm_id, settings), kwargs = mock.call_args
        assert path == fake_bin
        assert name == "IOU 1"
        assert console is None
        assert settings == {"initial_config": "/tmp"}
        assert vm_id == uuid

    iou_device.updated_signal.emit()
    assert iou_device._ports[0].name() == "Hyper Ethernet0/0"
Beispiel #6
0
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
Beispiel #7
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["startup_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._settings["md5sum"] = "0cc175b9c0f1b6a831c399e269772661"
    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",
            "md5sum": "0cc175b9c0f1b6a831c399e269772661",
            "startup_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
    }
Beispiel #8
0
def test_iou_device_init(local_server, project):

    iou_device = IOUDevice(None, local_server, project)
Beispiel #9
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
    }
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
    }
Beispiel #11
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"
    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
    }