Fixes Dynamips console/aux ports restoration when loading a project.

This commit is contained in:
Jeremy 2015-02-26 16:15:44 -07:00
parent 62afef06af
commit 58d92f1584
10 changed files with 40 additions and 20 deletions

View File

@ -58,7 +58,9 @@ class DynamipsVMHandler:
request.match_info["project_id"], request.match_info["project_id"],
request.json.get("vm_id"), request.json.get("vm_id"),
request.json.get("dynamips_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.update_vm_settings(vm, request.json)
yield from dynamips_manager.ghost_ios_support(vm) yield from dynamips_manager.ghost_ios_support(vm)

View File

@ -314,7 +314,7 @@ class Dynamips(BaseManager):
hypervisor = Hypervisor(self._dynamips_path, working_dir, "127.0.0.1", port) 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 hypervisor.start()
yield from self._wait_for_hypervisor("127.0.0.1", port) yield from self._wait_for_hypervisor("127.0.0.1", port)

View File

@ -39,13 +39,15 @@ class C1700(Router):
:param project: Project instance :param project: Project instance
:param manager: Parent VM Manager :param manager: Parent VM Manager
:param dynamips_id: ID to use with Dynamips :param dynamips_id: ID to use with Dynamips
:param console: console port
:param aux: auxiliary console port
:param chassis: chassis for this router: :param chassis: chassis for this router:
1720, 1721, 1750, 1751 or 1760 (default = 1720). 1720, 1721, 1750, 1751 or 1760 (default = 1720).
1710 is not supported. 1710 is not supported.
""" """
def __init__(self, name, vm_id, project, manager, dynamips_id, chassis="1720"): 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, platform="c1700") 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) # Set default values for this platform (must be the same as Dynamips)
self._ram = 64 self._ram = 64

View File

@ -41,6 +41,8 @@ class C2600(Router):
:param project: Project instance :param project: Project instance
:param manager: Parent VM Manager :param manager: Parent VM Manager
:param dynamips_id: ID to use with Dynamips :param dynamips_id: ID to use with Dynamips
:param console: console port
:param aux: auxiliary console port
:param chassis: chassis for this router: :param chassis: chassis for this router:
2610, 2611, 2620, 2621, 2610XM, 2611XM 2610, 2611, 2620, 2621, 2610XM, 2611XM
2620XM, 2621XM, 2650XM or 2651XM (default = 2610). 2620XM, 2621XM, 2650XM or 2651XM (default = 2610).
@ -59,8 +61,8 @@ class C2600(Router):
"2650XM": C2600_MB_1FE, "2650XM": C2600_MB_1FE,
"2651XM": C2600_MB_2FE} "2651XM": C2600_MB_2FE}
def __init__(self, name, vm_id, project, manager, dynamips_id, chassis="2610"): 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, platform="c2600") 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) # Set default values for this platform (must be the same as Dynamips)
self._ram = 64 self._ram = 64

View File

@ -38,10 +38,12 @@ class C2691(Router):
:param project: Project instance :param project: Project instance
:param manager: Parent VM Manager :param manager: Parent VM Manager
:param dynamips_id: ID to use with Dynamips :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): def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None):
Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c2691") 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) # Set default values for this platform (must be the same as Dynamips)
self._ram = 128 self._ram = 128

View File

@ -38,12 +38,14 @@ class C3600(Router):
:param project: Project instance :param project: Project instance
:param manager: Parent VM Manager :param manager: Parent VM Manager
:param dynamips_id: ID to use with Dynamips :param dynamips_id: ID to use with Dynamips
:param console: console port
:param aux: auxiliary console port
:param chassis: chassis for this router: :param chassis: chassis for this router:
3620, 3640 or 3660 (default = 3640). 3620, 3640 or 3660 (default = 3640).
""" """
def __init__(self, name, vm_id, project, manager, dynamips_id, chassis="3640"): 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, platform="c3600") 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) # Set default values for this platform (must be the same as Dynamips)
self._ram = 128 self._ram = 128

View File

@ -38,10 +38,12 @@ class C3725(Router):
:param project: Project instance :param project: Project instance
:param manager: Parent VM Manager :param manager: Parent VM Manager
:param dynamips_id: ID to use with Dynamips :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): def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None):
Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c3725") 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) # Set default values for this platform (must be the same as Dynamips)
self._ram = 128 self._ram = 128

View File

@ -38,10 +38,12 @@ class C3745(Router):
:param project: Project instance :param project: Project instance
:param manager: Parent VM Manager :param manager: Parent VM Manager
:param dynamips_id: ID to use with Dynamips :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): def __init__(self, name, vm_id, project, manager, dynamips_id, console=None, aux=None):
Router.__init__(self, name, vm_id, project, manager, dynamips_id, platform="c3745") 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) # Set default values for this platform (must be the same as Dynamips)
self._ram = 128 self._ram = 128

View File

@ -41,11 +41,13 @@ class C7200(Router):
:param project: Project instance :param project: Project instance
:param manager: Parent VM Manager :param manager: Parent VM Manager
:param dynamips_id: ID to use with Dynamips :param dynamips_id: ID to use with Dynamips
:param console: console port
:param aux: auxiliary console port
:param npe: Default NPE :param npe: Default NPE
""" """
def __init__(self, name, vm_id, project, manager, dynamips_id, npe="npe-400"): 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, platform="c7200") 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) # Set default values for this platform (must be the same as Dynamips)
self._ram = 256 self._ram = 256

View File

@ -48,6 +48,8 @@ class Router(BaseVM):
:param project: Project instance :param project: Project instance
:param manager: Parent VM Manager :param manager: Parent VM Manager
:param dynamips_id: ID to use with Dynamips :param dynamips_id: ID to use with Dynamips
:param console: console port
:param aux: auxiliary console port
:param platform: Platform of this router :param platform: Platform of this router
""" """
@ -57,9 +59,9 @@ class Router(BaseVM):
2: "running", 2: "running",
3: "suspended"} 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._hypervisor = hypervisor
self._dynamips_id = dynamips_id self._dynamips_id = dynamips_id
@ -86,7 +88,7 @@ class Router(BaseVM):
self._disk0 = 0 # Megabytes self._disk0 = 0 # Megabytes
self._disk1 = 0 # Megabytes self._disk1 = 0 # Megabytes
self._confreg = "0x2102" self._confreg = "0x2102"
self._aux = None self._aux = aux
self._mac_addr = "" self._mac_addr = ""
self._system_id = "FTX0945W0MY" # processor board ID in IOS self._system_id = "FTX0945W0MY" # processor board ID in IOS
self._slots = [] self._slots = []
@ -200,6 +202,8 @@ class Router(BaseVM):
id=self._id)) 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_con_tcp_port "{name}" {console}'.format(name=self._name, console=self._console))
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)) 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 # get the default base MAC address