mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 22:11:14 +02:00
New Dynamips integration part 3
This commit is contained in:
1 parent
37945585b9
commit
79a57ca420
51 files changed
+1257
-2386
No files matched your search
@@ -37,13 +37,14 @@ class C1700(Router):
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param dynamips_id: ID to use with Dynamips
|
||||
: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, chassis="1720"):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c1700")
|
||||
def __init__(self, name, vm_id, project, manager, dynamips_id, chassis="1720"):
|
||||
Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c1700")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 128
|
||||
|
||||
@@ -39,6 +39,7 @@ class C2600(Router):
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param dynamips_id: ID to use with Dynamips
|
||||
:param chassis: chassis for this router:
|
||||
2610, 2611, 2620, 2621, 2610XM, 2611XM
|
||||
2620XM, 2621XM, 2650XM or 2651XM (default = 2610).
|
||||
@@ -57,8 +58,8 @@ class C2600(Router):
|
||||
"2650XM": C2600_MB_1FE,
|
||||
"2651XM": C2600_MB_2FE}
|
||||
|
||||
def __init__(self, name, vm_id, project, manager, chassis="2610"):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c2600")
|
||||
def __init__(self, name, vm_id, project, manager, dynamips_id, chassis="2610"):
|
||||
Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c2600")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 128
|
||||
|
||||
@@ -36,10 +36,11 @@ class C2691(Router):
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param dynamips_id: ID to use with Dynamips
|
||||
"""
|
||||
|
||||
def __init__(self, name, vm_id, project, manager):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c2691")
|
||||
def __init__(self, name, vm_id, project, manager, dynamips_id):
|
||||
Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c2691")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 192
|
||||
|
||||
@@ -36,12 +36,13 @@ class C3600(Router):
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param dynamips_id: ID to use with Dynamips
|
||||
:param chassis: chassis for this router:
|
||||
3620, 3640 or 3660 (default = 3640).
|
||||
"""
|
||||
|
||||
def __init__(self, name, vm_id, project, manager, chassis="3640"):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c3600")
|
||||
def __init__(self, name, vm_id, project, manager, dynamips_id, chassis="3640"):
|
||||
Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c3600")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 192
|
||||
|
||||
@@ -36,10 +36,11 @@ class C3725(Router):
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param dynamips_id: ID to use with Dynamips
|
||||
"""
|
||||
|
||||
def __init__(self, name, vm_id, project, manager):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c3725")
|
||||
def __init__(self, name, vm_id, project, manager, dynamips_id):
|
||||
Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c3725")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 128
|
||||
|
||||
@@ -36,10 +36,11 @@ class C3745(Router):
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param dynamips_id: ID to use with Dynamips
|
||||
"""
|
||||
|
||||
def __init__(self, name, vm_id, project, manager):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c3745")
|
||||
def __init__(self, name, vm_id, project, manager, dynamips_id):
|
||||
Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c3745")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 256
|
||||
|
||||
@@ -39,11 +39,12 @@ class C7200(Router):
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param dynamips_id: ID to use with Dynamips
|
||||
:param npe: Default NPE
|
||||
"""
|
||||
|
||||
def __init__(self, name, vm_id, project, manager, npe="npe-400"):
|
||||
Router.__init__(self, name, vm_id, project, manager, platform="c7200")
|
||||
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")
|
||||
|
||||
# Set default values for this platform
|
||||
self._ram = 512
|
||||
|
||||
@@ -42,20 +42,22 @@ class Router(BaseVM):
|
||||
:param vm_id: Router instance identifier
|
||||
:param project: Project instance
|
||||
:param manager: Parent VM Manager
|
||||
:param dynamips_id: ID to use with Dynamips
|
||||
:param platform: Platform of this router
|
||||
"""
|
||||
|
||||
_instances = []
|
||||
_dynamips_ids = {}
|
||||
_status = {0: "inactive",
|
||||
1: "shutting down",
|
||||
2: "running",
|
||||
3: "suspended"}
|
||||
|
||||
def __init__(self, name, vm_id, project, manager, platform="c7200", ghost_flag=False):
|
||||
def __init__(self, name, vm_id, project, manager, dynamips_id=None, platform="c7200", ghost_flag=False):
|
||||
|
||||
super().__init__(name, vm_id, project, manager)
|
||||
|
||||
self._hypervisor = None
|
||||
self._dynamips_id = dynamips_id
|
||||
self._closed = False
|
||||
self._name = name
|
||||
self._platform = platform
|
||||
@@ -81,12 +83,26 @@ class Router(BaseVM):
|
||||
self._confreg = "0x2102"
|
||||
self._console = None
|
||||
self._aux = None
|
||||
self._mac_addr = None
|
||||
self._mac_addr = ""
|
||||
self._system_id = "FTX0945W0MY" # processor board ID in IOS
|
||||
self._slots = []
|
||||
self._ghost_flag = ghost_flag
|
||||
|
||||
if not ghost_flag:
|
||||
self._dynamips_ids.setdefault(project.id, list())
|
||||
if not dynamips_id:
|
||||
# find a Dynamips ID if none is provided (0 < id <= 4096)
|
||||
self._dynamips_id = 0
|
||||
for identifier in range(1, 4097):
|
||||
if identifier not in self._dynamips_ids[project.id]:
|
||||
self._dynamips_id = identifier
|
||||
break
|
||||
if self._dynamips_id == 0:
|
||||
raise DynamipsError("Maximum number of Dynamips instances reached")
|
||||
else:
|
||||
if dynamips_id in self._dynamips_ids[project.id]:
|
||||
raise DynamipsError("Dynamips identifier {} is already used by another router".format(dynamips_id))
|
||||
self._dynamips_ids[project.id].append(self._dynamips_id)
|
||||
|
||||
if self._console is not None:
|
||||
self._console = self._manager.port_manager.reserve_console_port(self._console)
|
||||
@@ -97,12 +113,17 @@ class Router(BaseVM):
|
||||
self._aux = self._manager.port_manager.reserve_console_port(self._aux)
|
||||
else:
|
||||
self._aux = self._manager.port_manager.get_free_console_port()
|
||||
else:
|
||||
log.info("creating a new ghost IOS file")
|
||||
self._dynamips_id = 0
|
||||
self._name = "Ghost"
|
||||
|
||||
def __json__(self):
|
||||
|
||||
router_info = {"name": self.name,
|
||||
"vm_id": self.id,
|
||||
"project_id": self.project.id,
|
||||
"dynamips_id": self._dynamips_id,
|
||||
"platform": self._platform,
|
||||
"image": self._image,
|
||||
"startup_config": self._startup_config,
|
||||
@@ -138,14 +159,21 @@ class Router(BaseVM):
|
||||
|
||||
return router_info
|
||||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
"""
|
||||
Resets the instance count and the allocated instances list.
|
||||
"""
|
||||
|
||||
cls._dynamips_ids.clear()
|
||||
|
||||
@asyncio.coroutine
|
||||
def create(self):
|
||||
|
||||
self._hypervisor = yield from self.manager.start_new_hypervisor()
|
||||
|
||||
print("{} {} {}".format(self._name, self._id, self._platform))
|
||||
yield from self._hypervisor.send('vm create "{name}" {id} {platform}'.format(name=self._name,
|
||||
id=1, #FIXME: instance ID!
|
||||
id=self._dynamips_id,
|
||||
platform=self._platform))
|
||||
|
||||
if not self._ghost_flag:
|
||||
@@ -270,6 +298,9 @@ class Router(BaseVM):
|
||||
self._manager.port_manager.release_console_port(self._aux)
|
||||
self._aux = None
|
||||
|
||||
if self._dynamips_id in self._dynamips_ids[self._project.id]:
|
||||
self._dynamips_ids[self._project.id].remove(self._dynamips_id)
|
||||
|
||||
self._closed = True
|
||||
|
||||
@asyncio.coroutine
|
||||
|
||||
Reference in new issue
Block a user