From e52775fa3ac4ed14a3da6e1f66fea3ec21b531a7 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 24 Mar 2018 18:11:21 +0700 Subject: [PATCH] Support for console type "none". --- gns3server/compute/base_node.py | 27 +++++++++++----- gns3server/compute/dynamips/nodes/c1700.py | 4 +-- gns3server/compute/dynamips/nodes/c2600.py | 4 +-- gns3server/compute/dynamips/nodes/c2691.py | 4 +-- gns3server/compute/dynamips/nodes/c3600.py | 4 +-- gns3server/compute/dynamips/nodes/c3725.py | 4 +-- gns3server/compute/dynamips/nodes/c3745.py | 4 +-- gns3server/compute/dynamips/nodes/c7200.py | 4 +-- .../compute/dynamips/nodes/ethernet_switch.py | 26 +++++++++++++--- gns3server/compute/dynamips/nodes/router.py | 30 +++++++++++++++--- gns3server/compute/iou/iou_vm.py | 25 ++++++++++++--- gns3server/compute/qemu/qemu_vm.py | 15 ++++++++- .../compute/virtualbox/virtualbox_vm.py | 31 ++++++++++++++----- gns3server/compute/vmware/vmware_vm.py | 28 ++++++++++++----- gns3server/compute/vpcs/vpcs_vm.py | 19 ++++++++++-- gns3server/controller/node.py | 5 +-- .../api/compute/dynamips_vm_handler.py | 1 + .../api/compute/ethernet_switch_handler.py | 4 +++ .../handlers/api/compute/iou_handler.py | 3 +- .../api/compute/virtualbox_handler.py | 1 + .../handlers/api/compute/vmware_handler.py | 3 +- .../handlers/api/compute/vpcs_handler.py | 2 ++ gns3server/schemas/dynamips_vm.py | 12 +++---- gns3server/schemas/ethernet_switch.py | 8 ++--- gns3server/schemas/iou.py | 6 ++-- gns3server/schemas/virtualbox.py | 8 ++--- gns3server/schemas/vmware.py | 8 ++--- gns3server/schemas/vpcs.py | 8 ++--- 28 files changed, 213 insertions(+), 85 deletions(-) diff --git a/gns3server/compute/base_node.py b/gns3server/compute/base_node.py index 0f7489ba..62e02a25 100644 --- a/gns3server/compute/base_node.py +++ b/gns3server/compute/base_node.py @@ -82,6 +82,8 @@ class BaseNode: if console_type == "vnc": # VNC is a special case and the range must be 5900-6000 self._console = self._manager.port_manager.reserve_tcp_port(self._console, self._project, port_range_start=5900, port_range_end=6000) + elif console_type == "none": + self._console = None else: self._console = self._manager.port_manager.reserve_tcp_port(self._console, self._project) @@ -291,9 +293,7 @@ class BaseNode: Stop the node process. """ - if self._wrapper_telnet_server: - self._wrapper_telnet_server.close() - yield from self._wrapper_telnet_server.wait_closed() + yield from self.stop_wrap_console() self.status = "stopped" def suspend(self): @@ -353,6 +353,16 @@ class BaseNode: server = AsyncioTelnetServer(reader=reader, writer=writer, binary=True, echo=True) self._wrapper_telnet_server = yield from asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console) + @asyncio.coroutine + def stop_wrap_console(self): + """ + Stops the telnet proxy. + """ + + if self._wrapper_telnet_server: + self._wrapper_telnet_server.close() + yield from self._wrapper_telnet_server.wait_closed() + @property def allocate_aux(self): """ @@ -418,7 +428,7 @@ class BaseNode: :params console: Console port (integer) or None to free the port """ - if console == self._console: + if console == self._console or self._console_type == "none": return if self._console_type == "vnc" and console is not None and console < 5900: @@ -470,10 +480,11 @@ class BaseNode: self._console = self._manager.port_manager.get_free_tcp_port(self._project) self._console_type = console_type - log.info("{module}: '{name}' [{id}]: console type set to {console_type}".format(module=self.manager.module_name, - name=self.name, - id=self.id, - console_type=console_type)) + log.info("{module}: '{name}' [{id}]: console type set to {console_type} (console port is {console})".format(module=self.manager.module_name, + name=self.name, + id=self.id, + console_type=console_type, + console=self.console)) @property def ubridge(self): diff --git a/gns3server/compute/dynamips/nodes/c1700.py b/gns3server/compute/dynamips/nodes/c1700.py index c042738b..59df0a01 100644 --- a/gns3server/compute/dynamips/nodes/c1700.py +++ b/gns3server/compute/dynamips/nodes/c1700.py @@ -46,9 +46,9 @@ class C1700(Router): 1710 is not supported. """ - def __init__(self, name, node_id, project, manager, dynamips_id, console=None, aux=None, chassis="1720"): + def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, chassis="1720"): - super().__init__(name, node_id, project, manager, dynamips_id, console, aux, platform="c1700") + super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, platform="c1700") # Set default values for this platform (must be the same as Dynamips) self._ram = 64 diff --git a/gns3server/compute/dynamips/nodes/c2600.py b/gns3server/compute/dynamips/nodes/c2600.py index 79c30d18..a938426c 100644 --- a/gns3server/compute/dynamips/nodes/c2600.py +++ b/gns3server/compute/dynamips/nodes/c2600.py @@ -61,9 +61,9 @@ class C2600(Router): "2650XM": C2600_MB_1FE, "2651XM": C2600_MB_2FE} - def __init__(self, name, node_id, project, manager, dynamips_id, console=None, aux=None, chassis="2610"): + def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, chassis="2610"): - super().__init__(name, node_id, project, manager, dynamips_id, console, aux, platform="c2600") + super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, platform="c2600") # Set default values for this platform (must be the same as Dynamips) self._ram = 64 diff --git a/gns3server/compute/dynamips/nodes/c2691.py b/gns3server/compute/dynamips/nodes/c2691.py index 46338583..ce2b20de 100644 --- a/gns3server/compute/dynamips/nodes/c2691.py +++ b/gns3server/compute/dynamips/nodes/c2691.py @@ -43,9 +43,9 @@ class C2691(Router): :param aux: auxiliary console port """ - def __init__(self, name, node_id, project, manager, dynamips_id, console=None, aux=None, chassis=None): + def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, chassis=None): - super().__init__(name, node_id, project, manager, dynamips_id, console, aux, platform="c2691") + super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, platform="c2691") # Set default values for this platform (must be the same as Dynamips) self._ram = 128 diff --git a/gns3server/compute/dynamips/nodes/c3600.py b/gns3server/compute/dynamips/nodes/c3600.py index 2bf99d30..bcb40377 100644 --- a/gns3server/compute/dynamips/nodes/c3600.py +++ b/gns3server/compute/dynamips/nodes/c3600.py @@ -44,9 +44,9 @@ class C3600(Router): 3620, 3640 or 3660 (default = 3640). """ - def __init__(self, name, node_id, project, manager, dynamips_id, console=None, aux=None, chassis="3640"): + def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, chassis="3640"): - super().__init__(name, node_id, project, manager, dynamips_id, console, aux, platform="c3600") + super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, platform="c3600") # Set default values for this platform (must be the same as Dynamips) self._ram = 128 diff --git a/gns3server/compute/dynamips/nodes/c3725.py b/gns3server/compute/dynamips/nodes/c3725.py index 5d701592..de1775ea 100644 --- a/gns3server/compute/dynamips/nodes/c3725.py +++ b/gns3server/compute/dynamips/nodes/c3725.py @@ -43,9 +43,9 @@ class C3725(Router): :param aux: auxiliary console port """ - def __init__(self, name, node_id, project, manager, dynamips_id, console=None, aux=None, chassis=None): + def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, chassis=None): - super().__init__(name, node_id, project, manager, dynamips_id, console, aux, platform="c3725") + super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, platform="c3725") # Set default values for this platform (must be the same as Dynamips) self._ram = 128 diff --git a/gns3server/compute/dynamips/nodes/c3745.py b/gns3server/compute/dynamips/nodes/c3745.py index 0255e597..2c0eee2f 100644 --- a/gns3server/compute/dynamips/nodes/c3745.py +++ b/gns3server/compute/dynamips/nodes/c3745.py @@ -43,9 +43,9 @@ class C3745(Router): :param aux: auxiliary console port """ - def __init__(self, name, node_id, project, manager, dynamips_id, console=None, aux=None, chassis=None): + def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, chassis=None): - super().__init__(name, node_id, project, manager, dynamips_id, console, aux, platform="c3745") + super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, platform="c3745") # Set default values for this platform (must be the same as Dynamips) self._ram = 128 diff --git a/gns3server/compute/dynamips/nodes/c7200.py b/gns3server/compute/dynamips/nodes/c7200.py index fb0231cd..9fb1eb98 100644 --- a/gns3server/compute/dynamips/nodes/c7200.py +++ b/gns3server/compute/dynamips/nodes/c7200.py @@ -46,9 +46,9 @@ class C7200(Router): :param npe: Default NPE """ - def __init__(self, name, node_id, project, manager, dynamips_id, console=None, aux=None, npe="npe-400", chassis=None): + def __init__(self, name, node_id, project, manager, dynamips_id, console=None, console_type="telnet", aux=None, npe="npe-400", chassis=None): - super().__init__(name, node_id, project, manager, dynamips_id, console, aux, platform="c7200") + super().__init__(name, node_id, project, manager, dynamips_id, console, console_type, aux, platform="c7200") # Set default values for this platform (must be the same as Dynamips) self._ram = 256 diff --git a/gns3server/compute/dynamips/nodes/ethernet_switch.py b/gns3server/compute/dynamips/nodes/ethernet_switch.py index 841a47c9..db40d443 100644 --- a/gns3server/compute/dynamips/nodes/ethernet_switch.py +++ b/gns3server/compute/dynamips/nodes/ethernet_switch.py @@ -80,14 +80,21 @@ class EthernetSwitch(Device): :param hypervisor: Dynamips hypervisor instance """ - def __init__(self, name, node_id, project, manager, ports=None, hypervisor=None): + def __init__(self, name, node_id, project, manager, console=None, console_type="telnet", ports=None, hypervisor=None): super().__init__(name, node_id, project, manager, hypervisor) self._nios = {} self._mappings = {} self._telnet_console = None self._telnet_shell = None - self._console = self._manager.port_manager.get_free_tcp_port(self._project) + self._console = console + self._console_type = console_type + + if self._console is not None: + self._console = self._manager.port_manager.reserve_tcp_port(self._console, self._project) + else: + self._console = self._manager.port_manager.get_free_tcp_port(self._project) + if ports is None: # create 8 ports by default self._ports = [] @@ -103,7 +110,7 @@ class EthernetSwitch(Device): ethernet_switch_info = {"name": self.name, "console": self.console, - "console_type": "telnet", + "console_type": self.console_type, "node_id": self.id, "project_id": self.project.id, "ports_mapping": self._ports, @@ -115,8 +122,16 @@ class EthernetSwitch(Device): return self._console @console.setter - def console(self, val): - self._console = val + def console(self, console): + self._console = console + + @property + def console_type(self): + return self._console_type + + @console_type.setter + def console_type(self, console_type): + self._console_type = console_type @property def ports_mapping(self): @@ -214,6 +229,7 @@ class EthernetSwitch(Device): """ Deletes this Ethernet switch. """ + yield from self._telnet.close() self._telnet_server.close() diff --git a/gns3server/compute/dynamips/nodes/router.py b/gns3server/compute/dynamips/nodes/router.py index 0cf25aa1..2fb25566 100644 --- a/gns3server/compute/dynamips/nodes/router.py +++ b/gns3server/compute/dynamips/nodes/router.py @@ -62,9 +62,9 @@ class Router(BaseNode): 2: "running", 3: "suspended"} - def __init__(self, name, node_id, project, manager, dynamips_id=None, console=None, aux=None, platform="c7200", hypervisor=None, ghost_flag=False): + def __init__(self, name, node_id, project, manager, dynamips_id=None, console=None, console_type="telnet", aux=None, platform="c7200", hypervisor=None, ghost_flag=False): - super().__init__(name, node_id, project, manager, console=console, aux=aux, allocate_aux=aux) + super().__init__(name, node_id, project, manager, console=console, console_type=console_type, aux=aux, allocate_aux=aux) self._working_directory = os.path.join(self.project.module_working_directory(self.manager.module_name.lower()), self.id) try: @@ -162,7 +162,7 @@ class Router(BaseNode): "auto_delete_disks": self._auto_delete_disks, "status": self.status, "console": self.console, - "console_type": "telnet", + "console_type": self.console_type, "aux": self.aux, "mac_addr": self._mac_addr, "system_id": self._system_id} @@ -186,6 +186,7 @@ class Router(BaseNode): else: router_info["wic" + str(wic_slot_number)] = None + return router_info def _memory_changed(self, path): @@ -223,7 +224,8 @@ class Router(BaseNode): platform=self._platform, id=self._id)) - yield from self._hypervisor.send('vm set_con_tcp_port "{name}" {console}'.format(name=self._name, console=self._console)) + if 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)) @@ -965,6 +967,26 @@ class Router(BaseNode): self.console = console yield from self._hypervisor.send('vm set_con_tcp_port "{name}" {console}'.format(name=self._name, console=self.console)) + @asyncio.coroutine + def set_console_type(self, console_type): + """ + Sets the console type. + + :param console_type: console type + """ + + if self.console_type != console_type: + status = yield from self.get_status() + if status == "running": + raise DynamipsError('"{name}" must be stopped to change the console type to {console_type}'.format(name=self._name, + console_type=console_type)) + + + self.console_type = console_type + + if self._console and console_type == "telnet": + yield from self._hypervisor.send('vm set_con_tcp_port "{name}" {console}'.format(name=self._name, console=self._console)) + @asyncio.coroutine def set_aux(self, aux): """ diff --git a/gns3server/compute/iou/iou_vm.py b/gns3server/compute/iou/iou_vm.py index af57e10e..78b34fbb 100644 --- a/gns3server/compute/iou/iou_vm.py +++ b/gns3server/compute/iou/iou_vm.py @@ -63,11 +63,12 @@ class IOUVM(BaseNode): :param project: Project instance :param manager: Manager instance :param console: TCP console port + :param console_type: console type """ - def __init__(self, name, node_id, project, manager, application_id=None, path=None, console=None): + def __init__(self, name, node_id, project, manager, application_id=None, path=None, console=None, console_type="telnet"): - super().__init__(name, node_id, project, manager, console=console) + super().__init__(name, node_id, project, manager, console=console, console_type=console_type) self._iou_process = None self._telnet_server = None @@ -219,7 +220,7 @@ class IOUVM(BaseNode): "node_id": self.id, "node_directory": self.working_path, "console": self._console, - "console_type": "telnet", + "console_type": self._console_type, "status": self.status, "project_id": self.project.id, "path": self.path, @@ -540,8 +541,9 @@ class IOUVM(BaseNode): log.error("Could not start IOU {}: {}\n{}".format(self._path, e, iou_stdout)) raise IOUError("Could not start IOU {}: {}\n{}".format(self._path, e, iou_stdout)) - server = AsyncioTelnetServer(reader=self._iou_process.stdout, writer=self._iou_process.stdin, binary=True, echo=True) - self._telnet_server = yield from asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console) + if self.console and self.console_type == "telnet": + server = AsyncioTelnetServer(reader=self._iou_process.stdout, writer=self._iou_process.stdin, binary=True, echo=True) + self._telnet_server = yield from asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console) # configure networking support yield from self._networking() @@ -684,6 +686,19 @@ class IOUVM(BaseNode): return True return False + @BaseNode.console_type.setter + def console_type(self, new_console_type): + """ + Sets the console type for this IOU VM. + + :param new_console_type: console type (string) + """ + + if self.is_running() and self.console_type != new_console_type: + raise IOUError('"{name}" must be stopped to change the console type to {new_console_type}'.format(name=self._name, new_console_type=new_console_type)) + + super(IOUVM, IOUVM).console_type.__set__(self, new_console_type) + def _create_netmap_config(self): """ Creates the NETMAP file. diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index b05b8482..93d550ab 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -61,9 +61,9 @@ class QemuVM(BaseNode): :param project: Project instance :param manager: Manager instance :param console: TCP console port + :param console_type: Console type :param qemu_path: path to the QEMU binary :param platform: Platform to emulate - :param console: TCP console port """ def __init__(self, name, node_id, project, manager, linked_clone=True, qemu_path=None, console=None, console_type="telnet", platform=None): @@ -1412,6 +1412,19 @@ class QemuVM(BaseNode): return " ".join(self._build_command()) + @BaseNode.console_type.setter + def console_type(self, new_console_type): + """ + Sets the console type for this QEMU VM. + + :param new_console_type: console type (string) + """ + + if self.is_running() and self.console_type != new_console_type: + raise QemuError('"{name}" must be stopped to change the console type to {new_console_type}'.format(name=self._name, new_console_type=new_console_type)) + + super(QemuVM, QemuVM).console_type.__set__(self, new_console_type) + def _serial_options(self): if self._console: diff --git a/gns3server/compute/virtualbox/virtualbox_vm.py b/gns3server/compute/virtualbox/virtualbox_vm.py index eff54fb4..b1513b16 100644 --- a/gns3server/compute/virtualbox/virtualbox_vm.py +++ b/gns3server/compute/virtualbox/virtualbox_vm.py @@ -53,9 +53,9 @@ class VirtualBoxVM(BaseNode): VirtualBox VM implementation. """ - def __init__(self, name, node_id, project, manager, vmname, linked_clone=False, console=None, adapters=0): + def __init__(self, name, node_id, project, manager, vmname, linked_clone=False, console=None, console_type="telnet", adapters=0): - super().__init__(name, node_id, project, manager, console=console, linked_clone=linked_clone, console_type="telnet") + super().__init__(name, node_id, project, manager, console=console, linked_clone=linked_clone, console_type=console_type) self._maximum_adapters = 8 self._system_properties = {} @@ -940,12 +940,14 @@ class VirtualBoxVM(BaseNode): """ Starts remote console support for this VM. """ - self._remote_pipe = yield from asyncio_open_serial(self._get_pipe_name()) - server = AsyncioTelnetServer(reader=self._remote_pipe, - writer=self._remote_pipe, - binary=True, - echo=True) - self._telnet_server = yield from asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console) + + if self.console and self.console_type == "telnet": + self._remote_pipe = yield from asyncio_open_serial(self._get_pipe_name()) + server = AsyncioTelnetServer(reader=self._remote_pipe, + writer=self._remote_pipe, + binary=True, + echo=True) + self._telnet_server = yield from asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console) @asyncio.coroutine def _stop_remote_console(self): @@ -958,6 +960,19 @@ class VirtualBoxVM(BaseNode): self._remote_pipe.close() self._telnet_server = None + @BaseNode.console_type.setter + def console_type(self, new_console_type): + """ + Sets the console type for this VirtualBox VM. + + :param new_console_type: console type (string) + """ + + if self.is_running() and self.console_type != new_console_type: + raise VirtualBoxError('"{name}" must be stopped to change the console type to {new_console_type}'.format(name=self._name, new_console_type=new_console_type)) + + super(VirtualBoxVM, VirtualBoxVM).console_type.__set__(self, new_console_type) + @asyncio.coroutine def adapter_add_nio_binding(self, adapter_number, nio): """ diff --git a/gns3server/compute/vmware/vmware_vm.py b/gns3server/compute/vmware/vmware_vm.py index ac2d9c5c..106ca6f3 100644 --- a/gns3server/compute/vmware/vmware_vm.py +++ b/gns3server/compute/vmware/vmware_vm.py @@ -44,9 +44,9 @@ class VMwareVM(BaseNode): VMware VM implementation. """ - def __init__(self, name, node_id, project, manager, vmx_path, linked_clone=False, console=None): + def __init__(self, name, node_id, project, manager, vmx_path, linked_clone=False, console=None, console_type="telnet"): - super().__init__(name, node_id, project, manager, console=console, linked_clone=linked_clone) + super().__init__(name, node_id, project, manager, console=console, console_type=console_type, linked_clone=linked_clone) self._vmx_pairs = OrderedDict() self._telnet_server = None @@ -842,12 +842,11 @@ class VMwareVM(BaseNode): """ Starts remote console support for this VM. """ - self._remote_pipe = yield from asyncio_open_serial(self._get_pipe_name()) - server = AsyncioTelnetServer(reader=self._remote_pipe, - writer=self._remote_pipe, - binary=True, - echo=True) - self._telnet_server = yield from asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console) + + if self.console and self.console_type == "telnet": + self._remote_pipe = yield from asyncio_open_serial(self._get_pipe_name()) + server = AsyncioTelnetServer(reader=self._remote_pipe, writer=self._remote_pipe, binary=True, echo=True) + self._telnet_server = yield from asyncio.start_server(server.run, self._manager.port_manager.console_host, self.console) @asyncio.coroutine def _stop_remote_console(self): @@ -860,6 +859,19 @@ class VMwareVM(BaseNode): self._remote_pipe.close() self._telnet_server = None + @BaseNode.console_type.setter + def console_type(self, new_console_type): + """ + Sets the console type for this VMware VM. + + :param new_console_type: console type (string) + """ + + if self._started and self.console_type != new_console_type: + raise VMwareError('"{name}" must be stopped to change the console type to {new_console_type}'.format(name=self._name, new_console_type=new_console_type)) + + super(VMwareVM, VMwareVM).console_type.__set__(self, new_console_type) + @asyncio.coroutine def start_capture(self, adapter_number, output_file): """ diff --git a/gns3server/compute/vpcs/vpcs_vm.py b/gns3server/compute/vpcs/vpcs_vm.py index e58abe94..94c43202 100644 --- a/gns3server/compute/vpcs/vpcs_vm.py +++ b/gns3server/compute/vpcs/vpcs_vm.py @@ -59,9 +59,9 @@ class VPCSVM(BaseNode): :param startup_script: content of the startup script file """ - def __init__(self, name, node_id, project, manager, console=None, startup_script=None): + def __init__(self, name, node_id, project, manager, console=None, console_type="telnet", startup_script=None): - super().__init__(name, node_id, project, manager, console=console, wrap_console=True) + super().__init__(name, node_id, project, manager, console=console, console_type=console_type, wrap_console=True) self._process = None self._vpcs_stdout_file = "" self._vpcs_version = None @@ -130,7 +130,7 @@ class VPCSVM(BaseNode): "node_directory": self.working_path, "status": self.status, "console": self._console, - "console_type": "telnet", + "console_type": self._console_type, "project_id": self.project.id, "command_line": self.command_line} @@ -348,6 +348,19 @@ class VPCSVM(BaseNode): return True return False + @BaseNode.console_type.setter + def console_type(self, new_console_type): + """ + Sets the console type for this VPCS VM. + + :param new_console_type: console type (string) + """ + + if self.is_running() and self.console_type != new_console_type: + raise VPCSError('"{name}" must be stopped to change the console type to {new_console_type}'.format(name=self._name, new_console_type=new_console_type)) + + super(VPCSVM, VPCSVM).console_type.__set__(self, new_console_type) + @asyncio.coroutine def port_add_nio_binding(self, port_number, nio): """ diff --git a/gns3server/controller/node.py b/gns3server/controller/node.py index 9749bb96..bf8f2cad 100644 --- a/gns3server/controller/node.py +++ b/gns3server/controller/node.py @@ -376,8 +376,8 @@ class Node: self._list_ports() # We send notif only if object has changed - if old_json != self.__json__(): - self.project.controller.notification.emit("node.updated", self.__json__()) + #if old_json != self.__json__(): + # self.project.controller.notification.emit("node.updated", self.__json__()) if update_compute: data = self._node_data(properties=compute_properties) response = yield from self.put(None, data=data) @@ -389,6 +389,7 @@ class Node: """ Update the object with the remote node object """ + for key, value in response.items(): if key == "console": self._console = value diff --git a/gns3server/handlers/api/compute/dynamips_vm_handler.py b/gns3server/handlers/api/compute/dynamips_vm_handler.py index 1f425365..c3d170df 100644 --- a/gns3server/handlers/api/compute/dynamips_vm_handler.py +++ b/gns3server/handlers/api/compute/dynamips_vm_handler.py @@ -75,6 +75,7 @@ class DynamipsVMHandler: dynamips_id=request.json.get("dynamips_id"), platform=platform, console=request.json.get("console"), + console_type=request.json.get("console_type", "telnet"), aux=request.json.get("aux"), chassis=request.json.pop("chassis", default_chassis), node_type="dynamips") diff --git a/gns3server/handlers/api/compute/ethernet_switch_handler.py b/gns3server/handlers/api/compute/ethernet_switch_handler.py index cfde2bfa..01aa69c0 100644 --- a/gns3server/handlers/api/compute/ethernet_switch_handler.py +++ b/gns3server/handlers/api/compute/ethernet_switch_handler.py @@ -55,6 +55,8 @@ class EthernetSwitchHandler: node = yield from dynamips_manager.create_node(request.json.pop("name"), request.match_info["project_id"], request.json.get("node_id"), + console=request.json.get("console"), + console_type=request.json.get("console_type"), node_type="ethernet_switch", ports=request.json.get("ports_mapping")) @@ -134,6 +136,8 @@ class EthernetSwitchHandler: if "ports_mapping" in request.json: node.ports_mapping = request.json["ports_mapping"] yield from node.update_port_settings() + if "console_type" in request.json: + node.console_type = request.json["console_type"] # builtin_manager = Builtin.instance() # node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) diff --git a/gns3server/handlers/api/compute/iou_handler.py b/gns3server/handlers/api/compute/iou_handler.py index ae661c36..0a64ad2a 100644 --- a/gns3server/handlers/api/compute/iou_handler.py +++ b/gns3server/handlers/api/compute/iou_handler.py @@ -61,7 +61,8 @@ class IOUHandler: request.match_info["project_id"], request.json.get("node_id"), path=request.json.get("path"), - console=request.json.get("console")) + console=request.json.get("console"), + console_type=request.json.get("console_type", "telnet")) for name, value in request.json.items(): if hasattr(vm, name) and getattr(vm, name) != value: diff --git a/gns3server/handlers/api/compute/virtualbox_handler.py b/gns3server/handlers/api/compute/virtualbox_handler.py index f704a6c1..d42a79bd 100644 --- a/gns3server/handlers/api/compute/virtualbox_handler.py +++ b/gns3server/handlers/api/compute/virtualbox_handler.py @@ -59,6 +59,7 @@ class VirtualBoxHandler: request.json.pop("vmname"), linked_clone=request.json.pop("linked_clone", False), console=request.json.get("console", None), + console_type=request.json.get("console_type", "telnet"), adapters=request.json.get("adapters", 0)) if "ram" in request.json: diff --git a/gns3server/handlers/api/compute/vmware_handler.py b/gns3server/handlers/api/compute/vmware_handler.py index 06d8a545..daeb7bf6 100644 --- a/gns3server/handlers/api/compute/vmware_handler.py +++ b/gns3server/handlers/api/compute/vmware_handler.py @@ -57,7 +57,8 @@ class VMwareHandler: request.json.get("node_id"), request.json.pop("vmx_path"), linked_clone=request.json.pop("linked_clone"), - console=request.json.get("console", None)) + console=request.json.get("console", None), + console_type=request.json.get("console_type", "telnet")) for name, value in request.json.items(): if name != "node_id": diff --git a/gns3server/handlers/api/compute/vpcs_handler.py b/gns3server/handlers/api/compute/vpcs_handler.py index 6dbf2bee..ed08de11 100644 --- a/gns3server/handlers/api/compute/vpcs_handler.py +++ b/gns3server/handlers/api/compute/vpcs_handler.py @@ -54,6 +54,7 @@ class VPCSHandler: request.match_info["project_id"], request.json.get("node_id"), console=request.json.get("console"), + console_type=request.json.get("console_type", "telnet"), startup_script=request.json.get("startup_script")) response.set_status(201) response.json(vm) @@ -98,6 +99,7 @@ class VPCSHandler: vm = vpcs_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) vm.name = request.json.get("name", vm.name) vm.console = request.json.get("console", vm.console) + vm.console_type = request.json.get("console_type", vm.console_type) vm.updated() response.json(vm) diff --git a/gns3server/schemas/dynamips_vm.py b/gns3server/schemas/dynamips_vm.py index 43b7da4f..a3cefb8d 100644 --- a/gns3server/schemas/dynamips_vm.py +++ b/gns3server/schemas/dynamips_vm.py @@ -121,13 +121,13 @@ VM_CREATE_SCHEMA = { }, "console": { "description": "Console TCP port", - "type": "integer", + "type": ["integer", "null"], "minimum": 1, "maximum": 65535 }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "aux": { "description": "Auxiliary console TCP port", @@ -339,13 +339,13 @@ VM_UPDATE_SCHEMA = { }, "console": { "description": "Console TCP port", - "type": "integer", + "type": ["integer", "null"], "minimum": 1, "maximum": 65535 }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "aux": { "description": "Auxiliary console TCP port", @@ -579,13 +579,13 @@ VM_OBJECT_SCHEMA = { }, "console": { "description": "Console TCP port", - "type": "integer", + "type": ["integer", "null"], "minimum": 1, "maximum": 65535 }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "aux": { "description": "Auxiliary console TCP port", diff --git a/gns3server/schemas/ethernet_switch.py b/gns3server/schemas/ethernet_switch.py index af9cf952..52951d3b 100644 --- a/gns3server/schemas/ethernet_switch.py +++ b/gns3server/schemas/ethernet_switch.py @@ -62,11 +62,11 @@ ETHERNET_SWITCH_CREATE_SCHEMA = { "description": "Console TCP port", "minimum": 1, "maximum": 65535, - "type": "integer" + "type": ["integer", "null"] }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "node_id": { "description": "Node UUID", @@ -163,11 +163,11 @@ ETHERNET_SWITCH_OBJECT_SCHEMA = { "description": "Console TCP port", "minimum": 1, "maximum": 65535, - "type": "integer" + "type": ["integer", "null"] }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, }, "additionalProperties": False, diff --git a/gns3server/schemas/iou.py b/gns3server/schemas/iou.py index 656eb524..3243c890 100644 --- a/gns3server/schemas/iou.py +++ b/gns3server/schemas/iou.py @@ -44,7 +44,7 @@ IOU_CREATE_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["telnet", None] + "enum": ["telnet", "none", None] }, "path": { "description": "Path of iou binary", @@ -138,11 +138,11 @@ IOU_OBJECT_SCHEMA = { "description": "Console TCP port", "minimum": 1, "maximum": 65535, - "type": "integer" + "type": ["integer", "null"] }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "project_id": { "description": "Project UUID", diff --git a/gns3server/schemas/virtualbox.py b/gns3server/schemas/virtualbox.py index 769d373f..dcde3ca3 100644 --- a/gns3server/schemas/virtualbox.py +++ b/gns3server/schemas/virtualbox.py @@ -64,11 +64,11 @@ VBOX_CREATE_SCHEMA = { "description": "Console TCP port", "minimum": 1, "maximum": 65535, - "type": "integer" + "type": ["integer", "null"] }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "ram": { "description": "Amount of RAM", @@ -154,11 +154,11 @@ VBOX_OBJECT_SCHEMA = { "description": "Console TCP port", "minimum": 1, "maximum": 65535, - "type": "integer" + "type": ["integer", "null"] }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "ram": { "description": "Amount of RAM", diff --git a/gns3server/schemas/vmware.py b/gns3server/schemas/vmware.py index 72a009fe..8a686641 100644 --- a/gns3server/schemas/vmware.py +++ b/gns3server/schemas/vmware.py @@ -46,11 +46,11 @@ VMWARE_CREATE_SCHEMA = { "description": "Console TCP port", "minimum": 1, "maximum": 65535, - "type": "integer" + "type": ["integer", "null"] }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "headless": { "description": "Headless mode", @@ -145,11 +145,11 @@ VMWARE_OBJECT_SCHEMA = { "description": "Console TCP port", "minimum": 1, "maximum": 65535, - "type": "integer" + "type": ["integer", "null"] }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "linked_clone": { "description": "Whether the VM is a linked clone or not", diff --git a/gns3server/schemas/vpcs.py b/gns3server/schemas/vpcs.py index 4e05dd9d..0de28c82 100644 --- a/gns3server/schemas/vpcs.py +++ b/gns3server/schemas/vpcs.py @@ -44,7 +44,7 @@ VPCS_CREATE_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "startup_script": { "description": "Content of the VPCS startup script", @@ -73,7 +73,7 @@ VPCS_UPDATE_SCHEMA = { }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, }, "additionalProperties": False, @@ -108,11 +108,11 @@ VPCS_OBJECT_SCHEMA = { "description": "Console TCP port", "minimum": 1, "maximum": 65535, - "type": "integer" + "type": ["integer", "null"] }, "console_type": { "description": "Console type", - "enum": ["telnet"] + "enum": ["telnet", "none"] }, "project_id": { "description": "Project UUID",