Use Dynamips, IOU and VPCS identifiers to correctly load a topology.

This commit is contained in:
grossmj committed 2014-06-15 05:18:33 -06:00
1 parent f9ee38dd55
commit cb763e0926
18 files changed
+115 -55

No files matched your search

+4 -5
View File
@@ -132,9 +132,8 @@ class VM(object):
image = request["image"]
ram = request["ram"]
hypervisor = None
chassis = None
if "chassis" in request:
chassis = request["chassis"]
chassis = request.get("chassis")
router_id = request.get("router_id")
try:
@@ -147,9 +146,9 @@ class VM(object):
hypervisor = self._hypervisor_manager.allocate_hypervisor_for_router(image, ram)
if chassis:
router = PLATFORMS[platform](hypervisor, name, chassis=chassis)
router = PLATFORMS[platform](hypervisor, name, router_id, chassis=chassis)
else:
router = PLATFORMS[platform](hypervisor, name)
router = PLATFORMS[platform](hypervisor, name, router_id)
router.ram = ram
router.image = image
router.sparsemem = self._hypervisor_manager.sparse_memory_support
+3 -2
View File
@@ -34,13 +34,14 @@ class C1700(Router):
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param router_id: router instance ID
:param chassis: chassis for this router:
1720, 1721, 1750, 1751 or 1760 (default = 1720).
1710 is not supported.
"""
def __init__(self, hypervisor, name, chassis="1720"):
Router.__init__(self, hypervisor, name, platform="c1700")
def __init__(self, hypervisor, name, router_id=None, chassis="1720"):
Router.__init__(self, hypervisor, name, router_id, platform="c1700")
# Set default values for this platform
self._ram = 64
+3 -2
View File
@@ -36,6 +36,7 @@ class C2600(Router):
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param router_id: router instance ID
:param chassis: chassis for this router:
2610, 2611, 2620, 2621, 2610XM, 2611XM
2620XM, 2621XM, 2650XM or 2651XM (default = 2610).
@@ -54,8 +55,8 @@ class C2600(Router):
"2650XM": C2600_MB_1FE,
"2651XM": C2600_MB_2FE}
def __init__(self, hypervisor, name, chassis="2610"):
Router.__init__(self, hypervisor, name, platform="c2600")
def __init__(self, hypervisor, name, router_id=None, chassis="2610"):
Router.__init__(self, hypervisor, name, router_id, platform="c2600")
# Set default values for this platform
self._ram = 64
+3 -2
View File
@@ -33,10 +33,11 @@ class C2691(Router):
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param router_id: router instance ID
"""
def __init__(self, hypervisor, name):
Router.__init__(self, hypervisor, name, platform="c2691")
def __init__(self, hypervisor, name, router_id=None):
Router.__init__(self, hypervisor, name, router_id, platform="c2691")
# Set default values for this platform
self._ram = 128
+3 -2
View File
@@ -33,12 +33,13 @@ class C3600(Router):
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param router_id: router instance ID
:param chassis: chassis for this router:
3620, 3640 or 3660 (default = 3640).
"""
def __init__(self, hypervisor, name, chassis="3640"):
Router.__init__(self, hypervisor, name, platform="c3600")
def __init__(self, hypervisor, name, router_id=None, chassis="3640"):
Router.__init__(self, hypervisor, name, router_id, platform="c3600")
# Set default values for this platform
self._ram = 128
+3 -2
View File
@@ -33,10 +33,11 @@ class C3725(Router):
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param router_id: router instance ID
"""
def __init__(self, hypervisor, name):
Router.__init__(self, hypervisor, name, platform="c3725")
def __init__(self, hypervisor, name, router_id=None):
Router.__init__(self, hypervisor, name, router_id, platform="c3725")
# Set default values for this platform
self._ram = 128
+3 -2
View File
@@ -33,10 +33,11 @@ class C3745(Router):
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param router_id: router instance ID
"""
def __init__(self, hypervisor, name):
Router.__init__(self, hypervisor, name, platform="c3745")
def __init__(self, hypervisor, name, router_id=None):
Router.__init__(self, hypervisor, name, router_id, platform="c3745")
# Set default values for this platform
self._ram = 128
+3 -2
View File
@@ -35,11 +35,12 @@ class C7200(Router):
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param router_id: router instance ID
:param npe: default NPE
"""
def __init__(self, hypervisor, name, npe="npe-400"):
Router.__init__(self, hypervisor, name, platform="c7200")
def __init__(self, hypervisor, name, router_id=None, npe="npe-400"):
Router.__init__(self, hypervisor, name, router_id, platform="c7200")
# Set default values for this platform
self._ram = 256
+17 -10
View File
@@ -37,6 +37,7 @@ class Router(object):
:param hypervisor: Dynamips hypervisor instance
:param name: name for this router
:param router_id: router instance ID
:param platform: c7200, c3745, c3725, c3600, c2691, c2600 or c1700
:param ghost_flag: used when creating a ghost IOS.
"""
@@ -49,20 +50,26 @@ class Router(object):
2: "running",
3: "suspended"}
def __init__(self, hypervisor, name, platform="c7200", ghost_flag=False):
def __init__(self, hypervisor, name, router_id=None, platform="c7200", ghost_flag=False):
if not ghost_flag:
# find an instance identifier (0 < id <= 4096)
self._id = 0
for identifier in range(1, 4097):
if identifier not in self._instances:
self._id = identifier
self._instances.append(self._id)
break
if not router_id:
# find an instance identifier if none is provided (0 < id <= 4096)
self._id = 0
for identifier in range(1, 4097):
if identifier not in self._instances:
self._id = identifier
self._instances.append(self._id)
break
if self._id == 0:
raise DynamipsError("Maximum number of instances reached")
if self._id == 0:
raise DynamipsError("Maximum number of instances reached")
else:
if router_id in self._instances:
raise DynamipsError("Router identifier {} is already used by another router".format(router_id))
self._id = router_id
self._instances.append(self._id)
else:
log.info("creating a new ghost IOS file")
@@ -25,6 +25,10 @@ VM_CREATE_SCHEMA = {
"type": "string",
"minLength": 1,
},
"router_id": {
"description": "VM/router instance ID",
"type": "integer"
},
"platform": {
"description": "router platform",
"type": "string",