1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-30 18:50:58 +00:00

Merge branch '2.2' into 3.0

# Conflicts:
#	gns3server/compute/base_node.py
#	gns3server/compute/docker/docker_vm.py
#	gns3server/compute/dynamips/nodes/c1700.py
#	gns3server/compute/dynamips/nodes/c2600.py
#	gns3server/compute/dynamips/nodes/c2691.py
#	gns3server/compute/dynamips/nodes/c3600.py
#	gns3server/compute/dynamips/nodes/c3725.py
#	gns3server/compute/dynamips/nodes/c3745.py
#	gns3server/compute/dynamips/nodes/c7200.py
#	gns3server/compute/dynamips/nodes/router.py
#	gns3server/compute/qemu/qemu_vm.py
#	gns3server/controller/node.py
#	gns3server/handlers/api/compute/docker_handler.py
#	gns3server/handlers/api/compute/dynamips_vm_handler.py
#	gns3server/handlers/api/compute/qemu_handler.py
#	gns3server/schemas/docker.py
#	gns3server/schemas/docker_template.py
#	gns3server/schemas/dynamips_template.py
#	gns3server/schemas/dynamips_vm.py
#	gns3server/schemas/node.py
#	gns3server/schemas/qemu.py
#	gns3server/schemas/qemu_template.py
This commit is contained in:
grossmj 2024-09-22 22:01:06 +07:00
commit 7619080a50
No known key found for this signature in database
GPG Key ID: 0A2D76AC45EA25CD
3 changed files with 68 additions and 1 deletions

View File

@ -465,6 +465,7 @@ class DockerVM(BaseNode):
"Memory": self._memory * (1024 * 1024), # convert memory to bytes
"NanoCpus": int(self._cpus * 1e9), # convert cpus to nano cpus
},
"UsernsMode": "host",
"Volumes": {},
"Env": ["container=docker"], # Systemd compliant: https://github.com/GNS3/gns3-server/issues/573
"Cmd": [],

View File

@ -1030,6 +1030,26 @@ class Router(BaseNode):
self.aux = aux
await self._hypervisor.send(f'vm set_aux_tcp_port "{self._name}" {aux}')
async def set_aux_type(self, aux_type):
"""
Sets the aux type.
:param aux_type: auxiliary console type
"""
if self.aux_type != aux_type:
status = await self.get_status()
if status == "running":
raise DynamipsError('"{name}" must be stopped to change the auxiliary console type to {aux_type}'.format(
name=self._name,
aux_type=aux_type)
)
self.aux_type = aux_type
if self._aux and aux_type == "telnet":
await self._hypervisor.send(f'vm set_aux_tcp_port "{self._name}" {self._aux}')
async def reset_console(self):
"""
Reset console

View File

@ -123,6 +123,7 @@ async def test_create(compute_project, manager):
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -173,6 +174,7 @@ async def test_create_with_tag(compute_project, manager):
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -232,6 +234,7 @@ async def test_create_vnc(compute_project, manager):
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -377,6 +380,7 @@ async def test_create_start_cmd(compute_project, manager):
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/ls"],
@ -489,6 +493,7 @@ async def test_create_image_not_available(compute_project, manager):
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -544,6 +549,7 @@ async def test_create_with_user(compute_project, manager):
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -647,6 +653,7 @@ async def test_create_with_extra_volumes_duplicate_1_image(compute_project, mana
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -702,6 +709,7 @@ async def test_create_with_extra_volumes_duplicate_2_user(compute_project, manag
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -757,6 +765,7 @@ async def test_create_with_extra_volumes_duplicate_3_subdir(compute_project, man
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -812,6 +821,7 @@ async def test_create_with_extra_volumes_duplicate_4_backslash(compute_project,
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -862,6 +872,7 @@ async def test_create_with_extra_volumes_duplicate_5_subdir_issue_1595(compute_p
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -912,6 +923,7 @@ async def test_create_with_extra_volumes_duplicate_6_subdir_issue_1595(compute_p
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -978,6 +990,7 @@ async def test_create_with_extra_volumes(compute_project, manager):
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -1254,6 +1267,7 @@ async def test_update(vm):
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -1335,6 +1349,7 @@ async def test_update_running(vm):
"Memory": 0,
"NanoCpus": 0
},
"UsernsMode": "host",
"Volumes": {},
"NetworkDisabled": True,
"Hostname": "test",
@ -1430,7 +1445,37 @@ async def test_add_ubridge_connection(vm):
call.send('bridge start bridge0')
]
assert 'bridge0' in vm._bridges
# We need to check any_order ortherwise mock is confused by asyncio
# We need to check any_order otherwise mock is confused by asyncio
vm._ubridge_hypervisor.assert_has_calls(calls, any_order=True)
async def test_add_ubridge_connections_with_base_mac_address(vm):
vm._ubridge_hypervisor = MagicMock()
vm._namespace = 42
vm.adapters = 2
vm.mac_address = "02:42:42:42:42:00"
nio_params = {
"type": "nio_udp",
"lport": 4242,
"rport": 4343,
"rhost": "127.0.0.1"}
nio = vm.manager.create_nio(nio_params)
await vm._add_ubridge_connection(nio, 0)
nio = vm.manager.create_nio(nio_params)
await vm._add_ubridge_connection(nio, 1)
calls = [
call.send('bridge create bridge0'),
call.send('bridge create bridge1'),
call.send('docker set_mac_addr tap-gns3-e0 02:42:42:42:42:00'),
call.send('docker set_mac_addr tap-gns3-e0 02:42:42:42:42:01')
]
# We need to check any_order otherwise mock is confused by asyncio
vm._ubridge_hypervisor.assert_has_calls(calls, any_order=True)
@ -1654,6 +1699,7 @@ async def test_start_vnc_missing(vm):
@pytest.mark.asyncio
async def test_start_aux(vm):
vm.aux_type = "telnet"
with asyncio_patch("asyncio.subprocess.create_subprocess_exec", return_value=MagicMock()) as mock_exec:
await vm._start_aux()
mock_exec.assert_called_with(