From 74782d413ff7facf8b0b0d649fdbd65abcfe59a4 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 22 Sep 2024 21:41:10 +0700 Subject: [PATCH] Change method to allocate AUX console for existing Dynamips nodes --- gns3server/compute/base_node.py | 1 - gns3server/compute/dynamips/__init__.py | 4 ---- gns3server/compute/dynamips/nodes/router.py | 22 ++++++++++++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gns3server/compute/base_node.py b/gns3server/compute/base_node.py index c45f287b..d5785d17 100644 --- a/gns3server/compute/base_node.py +++ b/gns3server/compute/base_node.py @@ -653,7 +653,6 @@ class BaseNode: :param aux_type: console type (string) """ - print("SET AUX TYPE", aux_type) if aux_type != self._aux_type: # get a new port if the aux type change if self._aux: diff --git a/gns3server/compute/dynamips/__init__.py b/gns3server/compute/dynamips/__init__.py index 0f81a2bb..ce1d8722 100644 --- a/gns3server/compute/dynamips/__init__.py +++ b/gns3server/compute/dynamips/__init__.py @@ -527,10 +527,6 @@ class Dynamips(BaseManager): if usage is not None and usage != vm.usage: vm.usage = usage - aux_type = settings.get("aux_type") - if aux_type is not None and aux_type != vm.aux_type: - vm.aux_type = aux_type - # update the configs if needed await self.set_vm_configs(vm, settings) diff --git a/gns3server/compute/dynamips/nodes/router.py b/gns3server/compute/dynamips/nodes/router.py index 69553881..15a6aa6f 100644 --- a/gns3server/compute/dynamips/nodes/router.py +++ b/gns3server/compute/dynamips/nodes/router.py @@ -992,7 +992,27 @@ class Router(BaseNode): """ self.aux = aux - await self._hypervisor.send('vm set_aux_tcp_port "{name}" {aux}'.format(name=self._name, aux=aux)) + await self._hypervisor.send('vm set_aux_tcp_port "{name}" {aux}'.format(name=self._name, aux=self._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('vm set_aux_tcp_port "{name}" {aux}'.format(name=self._name, aux=self._aux)) async def reset_console(self): """