From 1071b6366f4e30b4f26ac5b717f150551308a188 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 5 Dec 2015 18:24:08 -0700 Subject: [PATCH] Fixes termination notification to indicate the right process name (IOU vs iouyap). Ref #359. --- gns3server/modules/iou/iou_vm.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gns3server/modules/iou/iou_vm.py b/gns3server/modules/iou/iou_vm.py index a158b20d..80d7cd8e 100644 --- a/gns3server/modules/iou/iou_vm.py +++ b/gns3server/modules/iou/iou_vm.py @@ -34,6 +34,7 @@ import struct import hashlib import glob import binascii +import functools from .iou_error import IOUError from ..adapters.ethernet_adapter import EthernetAdapter @@ -515,7 +516,8 @@ class IOUVM(BaseVM): log.info("IOU instance {} started PID={}".format(self._id, self._iou_process.pid)) self._started = True self.status = "started" - gns3server.utils.asyncio.monitor_process(self._iou_process, self._termination_callback) + callback = functools.partial(self._termination_callback, "IOU") + gns3server.utils.asyncio.monitor_process(self._iou_process, callback) except FileNotFoundError as e: raise IOUError("Could not start IOU: {}: 32-bit binary support is probably not installed".format(e)) except (OSError, subprocess.SubprocessError) as e: @@ -528,19 +530,21 @@ class IOUVM(BaseVM): # connections support yield from self._start_iouyap() - def _termination_callback(self, returncode): + def _termination_callback(self, process_name, returncode): """ Called when the process has stopped. :param returncode: Process returncode """ - log.info("IOU process has stopped, return code: %d", returncode) + log.info("{} process has stopped, return code: {}".format(process_name, returncode)) self._terminate_process_iou() self._terminate_process_iouyap() self._ioucon_thread_stop_event.set() if returncode != 0: - self.project.emit("log.error", {"message": "IOU process has stopped, return code: {}\n{}".format(returncode, self.read_iou_stdout())}) + self.project.emit("log.error", {"message": "{} process has stopped, return code: {}\n{}".format(process_name, + returncode, + self.read_iou_stdout())}) def _rename_nvram_file(self): """ @@ -572,7 +576,8 @@ class IOUVM(BaseVM): stderr=subprocess.STDOUT, cwd=self.working_dir) - gns3server.utils.asyncio.monitor_process(self._iouyap_process, self._termination_callback) + callback = functools.partial(self._termination_callback, "iouyap") + gns3server.utils.asyncio.monitor_process(self._iouyap_process, callback) log.info("iouyap started PID={}".format(self._iouyap_process.pid)) except (OSError, subprocess.SubprocessError) as e: iouyap_stdout = self.read_iouyap_stdout()