diff --git a/gns3server/modules/iou/__init__.py b/gns3server/modules/iou/__init__.py index 4a3a295a..5ae65f98 100644 --- a/gns3server/modules/iou/__init__.py +++ b/gns3server/modules/iou/__init__.py @@ -479,7 +479,6 @@ class IOU(IModule): return try: - log.debug("starting IOU with command: {}".format(iou_instance.command())) iou_instance.iouyap = self._iouyap iou_instance.iourc = self._iourc iou_instance.start() diff --git a/gns3server/modules/iou/iou_device.py b/gns3server/modules/iou/iou_device.py index fc7ec837..90e00e1a 100644 --- a/gns3server/modules/iou/iou_device.py +++ b/gns3server/modules/iou/iou_device.py @@ -104,6 +104,7 @@ class IOUDevice(object): self._nvram = 128 # Kilobytes self._startup_config = "" self._ram = 256 # Megabytes + self._l1_keepalives = True # update the working directory self.working_dir = working_dir @@ -136,7 +137,8 @@ class IOUDevice(object): "nvram": self._nvram, "ethernet_adapters": len(self._ethernet_adapters), "serial_adapters": len(self._serial_adapters), - "console": self._console} + "console": self._console, + "l1_keepalives": self._l1_keepalives} return iou_defaults @@ -708,6 +710,26 @@ class IOUDevice(object): return nio + def _enable_l1_keepalives(self, command): + """ + Enables L1 keepalive messages if supported. + + :param command: command line + """ + + env = os.environ.copy() + env["IOURC"] = self._iourc + output = b"" + try: + output = subprocess.check_output([self._path, "-h"], stderr=subprocess.STDOUT, cwd=self._working_dir, env=env) + except OSError as e: + log.warn("could not determine if layer 1 keepalive messages are supported by {}: {}".format(os.path.basename(self._path), e)) + else: + if re.search("-l\s+Enable Layer 1 keepalive messages", output.decode("utf-8")): + command.extend(["-l"]) + else: + log.warn("layer 1 keepalive messages are not supported by {}".format(os.path.basename(self._path))) + def _build_command(self): """ Command to start the IOU process. @@ -750,6 +772,8 @@ class IOUDevice(object): command.extend(["-L"]) # disable local console, use remote console if self._startup_config: command.extend(["-c", self._startup_config]) + if self._l1_keepalives: + self._enable_l1_keepalives(command) command.extend([str(self._id)]) return command @@ -777,6 +801,30 @@ class IOUDevice(object): else: log.info("IOU {name} [id={id}]: does not use the default IOU image values".format(name=self._name, id=self._id)) + @property + def l1_keepalives(self): + """ + Returns either layer 1 keepalive messages option is enabled or disabled. + + :returns: boolean + """ + + return self._l1_keepalives + + @l1_keepalives.setter + def l1_keepalives(self, state): + """ + Enables or disables layer 1 keepalive messages. + + :param state: boolean + """ + + self._l1_keepalives = state + if state: + log.info("IOU {name} [id={id}]: has activated layer 1 keepalive messages".format(name=self._name, id=self._id)) + else: + log.info("IOU {name} [id={id}]: has deactivated layer 1 keepalive messages".format(name=self._name, id=self._id)) + @property def ram(self): """ diff --git a/gns3server/modules/iou/schemas.py b/gns3server/modules/iou/schemas.py index 5d37ffed..ad232a4c 100644 --- a/gns3server/modules/iou/schemas.py +++ b/gns3server/modules/iou/schemas.py @@ -102,6 +102,10 @@ IOU_UPDATE_SCHEMA = { "description": "use the default IOU RAM & NVRAM values", "type": "boolean" }, + "l1_keepalives": { + "description": "enable or disable layer 1 keepalive messages", + "type": "boolean" + }, "startup_config_base64": { "description": "startup configuration base64 encoded", "type": "string" diff --git a/gns3server/modules/vpcs/__init__.py b/gns3server/modules/vpcs/__init__.py index 585f9abd..3ef9347c 100644 --- a/gns3server/modules/vpcs/__init__.py +++ b/gns3server/modules/vpcs/__init__.py @@ -390,7 +390,6 @@ class VPCS(IModule): return try: - log.debug("starting VPCS with command: {}".format(vpcs_instance.command())) vpcs_instance.start() except VPCSError as e: self.send_custom_error(str(e))