From 628dfef0d36a2082e627beeea4d7bef711ee194d Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 21 Mar 2015 13:58:52 -0600 Subject: [PATCH] Initialize chassis when creating an IOS router. Fixes #107. --- gns3server/handlers/api/dynamips_vm_handler.py | 3 ++- gns3server/modules/dynamips/nodes/c2691.py | 6 +++++- gns3server/modules/dynamips/nodes/c3725.py | 6 +++++- gns3server/modules/dynamips/nodes/c3745.py | 6 +++++- gns3server/modules/dynamips/nodes/c7200.py | 7 +++++-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/gns3server/handlers/api/dynamips_vm_handler.py b/gns3server/handlers/api/dynamips_vm_handler.py index 1aea6a7b..a52159e6 100644 --- a/gns3server/handlers/api/dynamips_vm_handler.py +++ b/gns3server/handlers/api/dynamips_vm_handler.py @@ -58,7 +58,8 @@ class DynamipsVMHandler: request.json.get("dynamips_id"), request.json.pop("platform"), console=request.json.get("console"), - aux=request.json.get("aux")) + aux=request.json.get("aux"), + chassis=request.json.pop("chassis", None)) yield from dynamips_manager.update_vm_settings(vm, request.json) yield from dynamips_manager.ghost_ios_support(vm) diff --git a/gns3server/modules/dynamips/nodes/c2691.py b/gns3server/modules/dynamips/nodes/c2691.py index d161c90e..bafca2e0 100644 --- a/gns3server/modules/dynamips/nodes/c2691.py +++ b/gns3server/modules/dynamips/nodes/c2691.py @@ -23,6 +23,7 @@ http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L387 import asyncio from .router import Router from ..adapters.gt96100_fe import GT96100_FE +from ..dynamips_error import DynamipsError import logging log = logging.getLogger(__name__) @@ -42,7 +43,7 @@ class C2691(Router): :param aux: auxiliary console port """ - def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None): + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None, chassis=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) @@ -56,6 +57,9 @@ class C2691(Router): self._create_slots(2) self._slots[0] = GT96100_FE() + if chassis is not None: + raise DynamipsError("c2691 routers do not have chassis") + def __json__(self): c2691_router_info = {"iomem": self._iomem} diff --git a/gns3server/modules/dynamips/nodes/c3725.py b/gns3server/modules/dynamips/nodes/c3725.py index 41c3b19c..69bab887 100644 --- a/gns3server/modules/dynamips/nodes/c3725.py +++ b/gns3server/modules/dynamips/nodes/c3725.py @@ -23,6 +23,7 @@ http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L346 import asyncio from .router import Router from ..adapters.gt96100_fe import GT96100_FE +from ..dynamips_error import DynamipsError import logging log = logging.getLogger(__name__) @@ -42,7 +43,7 @@ class C3725(Router): :param aux: auxiliary console port """ - def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None): + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None, chassis=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) @@ -56,6 +57,9 @@ class C3725(Router): self._create_slots(3) self._slots[0] = GT96100_FE() + if chassis is not None: + raise DynamipsError("c3725 routers do not have chassis") + def __json__(self): c3725_router_info = {"iomem": self._iomem} diff --git a/gns3server/modules/dynamips/nodes/c3745.py b/gns3server/modules/dynamips/nodes/c3745.py index 62a4f267..53e4b1e3 100644 --- a/gns3server/modules/dynamips/nodes/c3745.py +++ b/gns3server/modules/dynamips/nodes/c3745.py @@ -23,6 +23,7 @@ http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L326 import asyncio from .router import Router from ..adapters.gt96100_fe import GT96100_FE +from ..dynamips_error import DynamipsError import logging log = logging.getLogger(__name__) @@ -42,7 +43,7 @@ class C3745(Router): :param aux: auxiliary console port """ - def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None): + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None, chassis=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) @@ -56,6 +57,9 @@ class C3745(Router): self._create_slots(5) self._slots[0] = GT96100_FE() + if chassis is not None: + raise DynamipsError("c3745 routers do not have chassis") + def __json__(self): c3745_router_info = {"iomem": self._iomem} diff --git a/gns3server/modules/dynamips/nodes/c7200.py b/gns3server/modules/dynamips/nodes/c7200.py index 784bb241..07e2ff4e 100644 --- a/gns3server/modules/dynamips/nodes/c7200.py +++ b/gns3server/modules/dynamips/nodes/c7200.py @@ -22,10 +22,10 @@ http://github.com/GNS3/dynamips/blob/master/README.hypervisor#L294 import asyncio -from ..dynamips_error import DynamipsError from .router import Router from ..adapters.c7200_io_fe import C7200_IO_FE from ..adapters.c7200_io_ge_e import C7200_IO_GE_E +from ..dynamips_error import DynamipsError import logging log = logging.getLogger(__name__) @@ -46,7 +46,7 @@ class C7200(Router): :param npe: Default NPE """ - def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None, npe="npe-400"): + def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None, npe="npe-400", chassis=None): 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) @@ -71,6 +71,9 @@ class C7200(Router): self._create_slots(7) + if chassis is not None: + raise DynamipsError("c7200 routers do not have chassis") + def __json__(self): c7200_router_info = {"npe": self._npe,