Skip to content

Commit 7619080

Browse files
committed
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
2 parents a1666dd + f1294cf commit 7619080

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

gns3server/compute/docker/docker_vm.py

+1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ async def create(self):
465465
"Memory": self._memory * (1024 * 1024), # convert memory to bytes
466466
"NanoCpus": int(self._cpus * 1e9), # convert cpus to nano cpus
467467
},
468+
"UsernsMode": "host",
468469
"Volumes": {},
469470
"Env": ["container=docker"], # Systemd compliant: https://github.com/GNS3/gns3-server/issues/573
470471
"Cmd": [],

gns3server/compute/dynamips/nodes/router.py

+20
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,26 @@ async def set_aux(self, aux):
10301030
self.aux = aux
10311031
await self._hypervisor.send(f'vm set_aux_tcp_port "{self._name}" {aux}')
10321032

1033+
async def set_aux_type(self, aux_type):
1034+
"""
1035+
Sets the aux type.
1036+
1037+
:param aux_type: auxiliary console type
1038+
"""
1039+
1040+
if self.aux_type != aux_type:
1041+
status = await self.get_status()
1042+
if status == "running":
1043+
raise DynamipsError('"{name}" must be stopped to change the auxiliary console type to {aux_type}'.format(
1044+
name=self._name,
1045+
aux_type=aux_type)
1046+
)
1047+
1048+
self.aux_type = aux_type
1049+
1050+
if self._aux and aux_type == "telnet":
1051+
await self._hypervisor.send(f'vm set_aux_tcp_port "{self._name}" {self._aux}')
1052+
10331053
async def reset_console(self):
10341054
"""
10351055
Reset console

tests/compute/docker/test_docker_vm.py

+47-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ async def test_create(compute_project, manager):
123123
"Memory": 0,
124124
"NanoCpus": 0
125125
},
126+
"UsernsMode": "host",
126127
"Volumes": {},
127128
"NetworkDisabled": True,
128129
"Hostname": "test",
@@ -173,6 +174,7 @@ async def test_create_with_tag(compute_project, manager):
173174
"Memory": 0,
174175
"NanoCpus": 0
175176
},
177+
"UsernsMode": "host",
176178
"Volumes": {},
177179
"NetworkDisabled": True,
178180
"Hostname": "test",
@@ -232,6 +234,7 @@ async def test_create_vnc(compute_project, manager):
232234
"Memory": 0,
233235
"NanoCpus": 0
234236
},
237+
"UsernsMode": "host",
235238
"Volumes": {},
236239
"NetworkDisabled": True,
237240
"Hostname": "test",
@@ -377,6 +380,7 @@ async def test_create_start_cmd(compute_project, manager):
377380
"Memory": 0,
378381
"NanoCpus": 0
379382
},
383+
"UsernsMode": "host",
380384
"Volumes": {},
381385
"Entrypoint": ["/gns3/init.sh"],
382386
"Cmd": ["/bin/ls"],
@@ -489,6 +493,7 @@ async def information():
489493
"Memory": 0,
490494
"NanoCpus": 0
491495
},
496+
"UsernsMode": "host",
492497
"Volumes": {},
493498
"NetworkDisabled": True,
494499
"Hostname": "test",
@@ -544,6 +549,7 @@ async def test_create_with_user(compute_project, manager):
544549
"Memory": 0,
545550
"NanoCpus": 0
546551
},
552+
"UsernsMode": "host",
547553
"Volumes": {},
548554
"NetworkDisabled": True,
549555
"Hostname": "test",
@@ -647,6 +653,7 @@ async def test_create_with_extra_volumes_duplicate_1_image(compute_project, mana
647653
"Memory": 0,
648654
"NanoCpus": 0
649655
},
656+
"UsernsMode": "host",
650657
"Volumes": {},
651658
"NetworkDisabled": True,
652659
"Hostname": "test",
@@ -702,6 +709,7 @@ async def test_create_with_extra_volumes_duplicate_2_user(compute_project, manag
702709
"Memory": 0,
703710
"NanoCpus": 0
704711
},
712+
"UsernsMode": "host",
705713
"Volumes": {},
706714
"NetworkDisabled": True,
707715
"Hostname": "test",
@@ -757,6 +765,7 @@ async def test_create_with_extra_volumes_duplicate_3_subdir(compute_project, man
757765
"Memory": 0,
758766
"NanoCpus": 0
759767
},
768+
"UsernsMode": "host",
760769
"Volumes": {},
761770
"NetworkDisabled": True,
762771
"Hostname": "test",
@@ -812,6 +821,7 @@ async def test_create_with_extra_volumes_duplicate_4_backslash(compute_project,
812821
"Memory": 0,
813822
"NanoCpus": 0
814823
},
824+
"UsernsMode": "host",
815825
"Volumes": {},
816826
"NetworkDisabled": True,
817827
"Hostname": "test",
@@ -862,6 +872,7 @@ async def test_create_with_extra_volumes_duplicate_5_subdir_issue_1595(compute_p
862872
"Memory": 0,
863873
"NanoCpus": 0
864874
},
875+
"UsernsMode": "host",
865876
"Volumes": {},
866877
"NetworkDisabled": True,
867878
"Hostname": "test",
@@ -912,6 +923,7 @@ async def test_create_with_extra_volumes_duplicate_6_subdir_issue_1595(compute_p
912923
"Memory": 0,
913924
"NanoCpus": 0
914925
},
926+
"UsernsMode": "host",
915927
"Volumes": {},
916928
"NetworkDisabled": True,
917929
"Hostname": "test",
@@ -978,6 +990,7 @@ async def test_create_with_extra_volumes(compute_project, manager):
978990
"Memory": 0,
979991
"NanoCpus": 0
980992
},
993+
"UsernsMode": "host",
981994
"Volumes": {},
982995
"NetworkDisabled": True,
983996
"Hostname": "test",
@@ -1254,6 +1267,7 @@ async def test_update(vm):
12541267
"Memory": 0,
12551268
"NanoCpus": 0
12561269
},
1270+
"UsernsMode": "host",
12571271
"Volumes": {},
12581272
"NetworkDisabled": True,
12591273
"Hostname": "test",
@@ -1335,6 +1349,7 @@ async def test_update_running(vm):
13351349
"Memory": 0,
13361350
"NanoCpus": 0
13371351
},
1352+
"UsernsMode": "host",
13381353
"Volumes": {},
13391354
"NetworkDisabled": True,
13401355
"Hostname": "test",
@@ -1430,7 +1445,37 @@ async def test_add_ubridge_connection(vm):
14301445
call.send('bridge start bridge0')
14311446
]
14321447
assert 'bridge0' in vm._bridges
1433-
# We need to check any_order ortherwise mock is confused by asyncio
1448+
# We need to check any_order otherwise mock is confused by asyncio
1449+
vm._ubridge_hypervisor.assert_has_calls(calls, any_order=True)
1450+
1451+
1452+
async def test_add_ubridge_connections_with_base_mac_address(vm):
1453+
1454+
vm._ubridge_hypervisor = MagicMock()
1455+
vm._namespace = 42
1456+
vm.adapters = 2
1457+
vm.mac_address = "02:42:42:42:42:00"
1458+
1459+
nio_params = {
1460+
"type": "nio_udp",
1461+
"lport": 4242,
1462+
"rport": 4343,
1463+
"rhost": "127.0.0.1"}
1464+
1465+
nio = vm.manager.create_nio(nio_params)
1466+
await vm._add_ubridge_connection(nio, 0)
1467+
1468+
nio = vm.manager.create_nio(nio_params)
1469+
await vm._add_ubridge_connection(nio, 1)
1470+
1471+
calls = [
1472+
call.send('bridge create bridge0'),
1473+
call.send('bridge create bridge1'),
1474+
call.send('docker set_mac_addr tap-gns3-e0 02:42:42:42:42:00'),
1475+
call.send('docker set_mac_addr tap-gns3-e0 02:42:42:42:42:01')
1476+
]
1477+
1478+
# We need to check any_order otherwise mock is confused by asyncio
14341479
vm._ubridge_hypervisor.assert_has_calls(calls, any_order=True)
14351480

14361481

@@ -1654,6 +1699,7 @@ async def test_start_vnc_missing(vm):
16541699
@pytest.mark.asyncio
16551700
async def test_start_aux(vm):
16561701

1702+
vm.aux_type = "telnet"
16571703
with asyncio_patch("asyncio.subprocess.create_subprocess_exec", return_value=MagicMock()) as mock_exec:
16581704
await vm._start_aux()
16591705
mock_exec.assert_called_with(

0 commit comments

Comments
 (0)