mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
feat: allocate IOL Docker application IDs from a pool disjoint from IOU
IOL interface MACs derive from the application ID (aabb.cc{app}{iface}),
so ids must be unique across opened projects sharing computes — the same
reason IOU has its allocator. IOL Docker nodes draw from the upper half
(512-1022, netiomux's fixed peer is 1023) so the two node types can
neither collide nor starve each other; IOU behavior is unchanged.
The controller sniffs the same GNS3_IOL_RUNNER environment marker the
compute uses to select IOLDockerVM (both the nested-properties and
template/top-level-kwarg shapes), stores the id in node properties like
IOU does, and passes it through the Docker create payload. Without an
allocation the compute falls back to a stable node-derived id in the
same upper range.
This commit is contained in:
8 files changed
+177
-24
No files matched your search
@@ -296,6 +296,47 @@ async def test_add_node_iou(controller):
|
||||
assert node3.properties["application_id"] == 3
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_add_node_iol_docker(controller):
|
||||
"""
|
||||
IOL Docker nodes (GNS3_IOL_RUNNER marker) get an application ID from the
|
||||
upper half of the id space, disjoint from IOU's lower half
|
||||
"""
|
||||
|
||||
compute = MagicMock()
|
||||
compute.id = "local"
|
||||
project = await controller.add_project(project_id=str(uuid.uuid4()), name="test1")
|
||||
project.emit_notification = MagicMock()
|
||||
|
||||
response = MagicMock()
|
||||
compute.post = AsyncioMagicMock(return_value=response)
|
||||
|
||||
# template shape: environment as a top-level kwarg
|
||||
node1 = await project.add_node(
|
||||
compute, "iol1", None, node_type="docker", image="iol-xe/iol-xe:17-18-02", environment="GNS3_IOL_RUNNER=1"
|
||||
)
|
||||
# raw API shape: environment nested in properties
|
||||
node2 = await project.add_node(
|
||||
compute,
|
||||
"iol2",
|
||||
None,
|
||||
node_type="docker",
|
||||
properties={"image": "iol-xe/iol-xe:17-18-02", "environment": "GNS3_IOL_RUNNER=1"},
|
||||
)
|
||||
# plain docker nodes are left alone
|
||||
node3 = await project.add_node(
|
||||
compute, "web", None, node_type="docker", image="nginx", environment="FOO=1", adapters=1
|
||||
)
|
||||
|
||||
assert node1.properties["application_id"] == 512
|
||||
assert node2.properties["application_id"] == 513
|
||||
assert "application_id" not in node3.properties
|
||||
|
||||
# IOU keeps its own pool: a subsequent IOU node still gets the lower half
|
||||
node4 = await project.add_node(compute, "iou1", None, node_type="iou")
|
||||
assert node4.properties["application_id"] == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_add_node_iou_with_multiple_projects(controller):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user