From 58d92f1584c224746ad245d0d60528612f92f6f3 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Thu, 26 Feb 2015 16:15:44 -0700 Subject: [PATCH] Fixes Dynamips console/aux ports restoration when loading a project. --- gns3server/handlers/api/dynamips_vm_handler.py | 4 +++- gns3server/modules/dynamips/__init__.py | 2 +- gns3server/modules/dynamips/nodes/c1700.py | 6 ++++-- gns3server/modules/dynamips/nodes/c2600.py | 6 ++++-- gns3server/modules/dynamips/nodes/c2691.py | 6 ++++-- gns3server/modules/dynamips/nodes/c3600.py | 6 ++++-- gns3server/modules/dynamips/nodes/c3725.py | 6 ++++-- gns3server/modules/dynamips/nodes/c3745.py | 6 ++++-- gns3server/modules/dynamips/nodes/c7200.py | 6 ++++-- gns3server/modules/dynamips/nodes/router.py | 12 ++++++++---- 10 files changed, 40 insertions(+), 20 deletions(-) diff --git a/gns3server/handlers/api/dynamips_vm_handler.py b/gns3server/handlers/api/dynamips_vm_handler.py index c17ceb71..dd5d5720 100644 --- a/gns3server/handlers/api/dynamips_vm_handler.py +++ b/gns3server/handlers/api/dynamips_vm_handler.py @@ -58,7 +58,9 @@ class DynamipsVMHandler: request.match_info["project_id"], request.json.get("vm_id"), request.json.get("dynamips_id"), - request.json.pop("platform")) + request.json.pop("platform"), + console=request.json.get("console"), + aux=request.json.get("aux")) yield from dynamips_manager.update_vm_settings(vm, request.json) yield from dynamips_manager.ghost_ios_support(vm) diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py index 004dc14a..0e8b648a 100644 --- a/gns3server/modules/dynamips/__init__.py +++ b/gns3server/modules/dynamips/__init__.py @@ -314,7 +314,7 @@ class Dynamips(BaseManager): hypervisor = Hypervisor(self._dynamips_path, working_dir, "127.0.0.1", port) - log.info("Ceating new hypervisor {}:{} with working directory {}".format(hypervisor.host, hypervisor.port, working_dir)) + log.info("Creating new hypervisor {}:{} with working directory {}".format(hypervisor.host, hypervisor.port, working_dir)) yield from hypervisor.start() yield from self._wait_for_hypervisor("127.0.0.1", port) diff --git a/gns3server/modules/dynamips/nodes/c1700.py b/gns3server/modules/dynamips/nodes/c1700.py index 707c2baf..1f7db1a0 100644 --- a/gns3server/modules/dynamips/nodes/c1700.py +++ b/gns3server/modules/dynamips/nodes/c1700.py @@ -39,13 +39,15 @@ class C1700(Router): :param project: Project instance :param manager: Parent VM Manager :param dynamips_id: ID to use with Dynamips + :param console: console port + :param aux: auxiliary console port :param chassis: chassis for this router: 1720, 1721, 1750, 1751 or 1760 (default = 1720). 1710 is not supported. """ - def __init__(self, name, vm_id, project, manager, dynamips_id, chassis="1720"): - Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c1700") + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None, chassis="1720"): + Router.__init__(self, name, vm_id, project, manager, dynamips_id, console, aux, platform="c1700") # Set default values for this platform (must be the same as Dynamips) self._ram = 64 diff --git a/gns3server/modules/dynamips/nodes/c2600.py b/gns3server/modules/dynamips/nodes/c2600.py index 9a63c487..ce5721d1 100644 --- a/gns3server/modules/dynamips/nodes/c2600.py +++ b/gns3server/modules/dynamips/nodes/c2600.py @@ -41,6 +41,8 @@ class C2600(Router): :param project: Project instance :param manager: Parent VM Manager :param dynamips_id: ID to use with Dynamips + :param console: console port + :param aux: auxiliary console port :param chassis: chassis for this router: 2610, 2611, 2620, 2621, 2610XM, 2611XM 2620XM, 2621XM, 2650XM or 2651XM (default = 2610). @@ -59,8 +61,8 @@ class C2600(Router): "2650XM": C2600_MB_1FE, "2651XM": C2600_MB_2FE} - def __init__(self, name, vm_id, project, manager, dynamips_id, chassis="2610"): - Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c2600") + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None, chassis="2610"): + Router.__init__(self, name, vm_id, project, manager, dynamips_id, console, aux, platform="c2600") # Set default values for this platform (must be the same as Dynamips) self._ram = 64 diff --git a/gns3server/modules/dynamips/nodes/c2691.py b/gns3server/modules/dynamips/nodes/c2691.py index 3b5b7332..d161c90e 100644 --- a/gns3server/modules/dynamips/nodes/c2691.py +++ b/gns3server/modules/dynamips/nodes/c2691.py @@ -38,10 +38,12 @@ class C2691(Router): :param project: Project instance :param manager: Parent VM Manager :param dynamips_id: ID to use with Dynamips + :param console: console port + :param aux: auxiliary console port """ - def __init__(self, name, vm_id, project, manager, dynamips_id): - Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c2691") + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None): + Router.__init__(self, name, vm_id, project, manager, dynamips_id, console, aux, platform="c2691") # Set default values for this platform (must be the same as Dynamips) self._ram = 128 diff --git a/gns3server/modules/dynamips/nodes/c3600.py b/gns3server/modules/dynamips/nodes/c3600.py index aa0d2249..9eff5964 100644 --- a/gns3server/modules/dynamips/nodes/c3600.py +++ b/gns3server/modules/dynamips/nodes/c3600.py @@ -38,12 +38,14 @@ class C3600(Router): :param project: Project instance :param manager: Parent VM Manager :param dynamips_id: ID to use with Dynamips + :param console: console port + :param aux: auxiliary console port :param chassis: chassis for this router: 3620, 3640 or 3660 (default = 3640). """ - def __init__(self, name, vm_id, project, manager, dynamips_id, chassis="3640"): - Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c3600") + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None, chassis="3640"): + Router.__init__(self, name, vm_id, project, manager, dynamips_id, console, aux, platform="c3600") # Set default values for this platform (must be the same as Dynamips) self._ram = 128 diff --git a/gns3server/modules/dynamips/nodes/c3725.py b/gns3server/modules/dynamips/nodes/c3725.py index 6a1481a1..41c3b19c 100644 --- a/gns3server/modules/dynamips/nodes/c3725.py +++ b/gns3server/modules/dynamips/nodes/c3725.py @@ -38,10 +38,12 @@ class C3725(Router): :param project: Project instance :param manager: Parent VM Manager :param dynamips_id: ID to use with Dynamips + :param console: console port + :param aux: auxiliary console port """ - def __init__(self, name, vm_id, project, manager, dynamips_id): - Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c3725") + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None): + Router.__init__(self, name, vm_id, project, manager, dynamips_id, console, aux, platform="c3725") # Set default values for this platform (must be the same as Dynamips) self._ram = 128 diff --git a/gns3server/modules/dynamips/nodes/c3745.py b/gns3server/modules/dynamips/nodes/c3745.py index e9bd84e1..62a4f267 100644 --- a/gns3server/modules/dynamips/nodes/c3745.py +++ b/gns3server/modules/dynamips/nodes/c3745.py @@ -38,10 +38,12 @@ class C3745(Router): :param project: Project instance :param manager: Parent VM Manager :param dynamips_id: ID to use with Dynamips + :param console: console port + :param aux: auxiliary console port """ - def __init__(self, name, vm_id, project, manager, dynamips_id): - Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c3745") + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None): + Router.__init__(self, name, vm_id, project, manager, dynamips_id, console, aux, platform="c3745") # Set default values for this platform (must be the same as Dynamips) self._ram = 128 diff --git a/gns3server/modules/dynamips/nodes/c7200.py b/gns3server/modules/dynamips/nodes/c7200.py index 218d35ab..784bb241 100644 --- a/gns3server/modules/dynamips/nodes/c7200.py +++ b/gns3server/modules/dynamips/nodes/c7200.py @@ -41,11 +41,13 @@ class C7200(Router): :param project: Project instance :param manager: Parent VM Manager :param dynamips_id: ID to use with Dynamips + :param console: console port + :param aux: auxiliary console port :param npe: Default NPE """ - def __init__(self, name, vm_id, project, manager, dynamips_id, npe="npe-400"): - Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c7200") + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None, npe="npe-400"): + Router.__init__(self, name, vm_id, project, manager, dynamips_id, console, aux, platform="c7200") # Set default values for this platform (must be the same as Dynamips) self._ram = 256 diff --git a/gns3server/modules/dynamips/nodes/router.py b/gns3server/modules/dynamips/nodes/router.py index e8c6dfef..16045537 100644 --- a/gns3server/modules/dynamips/nodes/router.py +++ b/gns3server/modules/dynamips/nodes/router.py @@ -48,6 +48,8 @@ class Router(BaseVM): :param project: Project instance :param manager: Parent VM Manager :param dynamips_id: ID to use with Dynamips + :param console: console port + :param aux: auxiliary console port :param platform: Platform of this router """ @@ -57,9 +59,9 @@ class Router(BaseVM): 2: "running", 3: "suspended"} - def __init__(self, name, vm_id, project, manager, dynamips_id=None, platform="c7200", hypervisor=None, ghost_flag=False): + def __init__(self, name, vm_id, project, manager, dynamips_id=None, console=None, aux=None, platform="c7200", hypervisor=None, ghost_flag=False): - super().__init__(name, vm_id, project, manager) + super().__init__(name, vm_id, project, manager, console=console) self._hypervisor = hypervisor self._dynamips_id = dynamips_id @@ -86,7 +88,7 @@ class Router(BaseVM): self._disk0 = 0 # Megabytes self._disk1 = 0 # Megabytes self._confreg = "0x2102" - self._aux = None + self._aux = aux self._mac_addr = "" self._system_id = "FTX0945W0MY" # processor board ID in IOS self._slots = [] @@ -200,7 +202,9 @@ class Router(BaseVM): id=self._id)) yield from self._hypervisor.send('vm set_con_tcp_port "{name}" {console}'.format(name=self._name, console=self._console)) - yield from self._hypervisor.send('vm set_aux_tcp_port "{name}" {aux}'.format(name=self._name, aux=self._aux)) + + if self._aux is not None: + yield from self._hypervisor.send('vm set_aux_tcp_port "{name}" {aux}'.format(name=self._name, aux=self._aux)) # get the default base MAC address mac_addr = yield from self._hypervisor.send('{platform} get_mac_addr "{name}"'.format(platform=self._platform,