From f876a862c41c16757dda56189eff895eda2e8c84 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 Sep 2014 21:13:09 -0600 Subject: [PATCH] GNS3 server will now create the heardbeat file durining initialization --- gns3dms/main.py | 7 ++++--- gns3server/modules/deadman/__init__.py | 12 +++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gns3dms/main.py b/gns3dms/main.py index e8d245d6..94e412d7 100644 --- a/gns3dms/main.py +++ b/gns3dms/main.py @@ -145,7 +145,6 @@ def parse_cmd_line(argv): else: cmd_line_option_list['syslog'] = ('localhost',514) - get_gns3config(cmd_line_option_list) for opt, val in opts: @@ -225,8 +224,10 @@ def get_gns3config(cmd_line_option_list): except configparser.NoSectionError: pass - cloud_config_file = "%s/.config/GNS3/cloud.conf" - if os.path.isfile(cloud_config_file) + cloud_config_file = "%s/.config/GNS3/cloud.conf" % ( + os.path.expanduser("~/")) + + if os.path.isfile(cloud_config_file): config.read(cloud_config_file) try: diff --git a/gns3server/modules/deadman/__init__.py b/gns3server/modules/deadman/__init__.py index 288d5b2a..86f97363 100644 --- a/gns3server/modules/deadman/__init__.py +++ b/gns3server/modules/deadman/__init__.py @@ -51,13 +51,11 @@ class DeadMan(IModule): self._heartbeat_file = "%s/heartbeat_file_for_gnsdms" % ( self._tempdir) - self.cloud_config = Config.instance().get_section_config("CLOUD_SERVER") - self._heartbeat_file = self.cloud_config["heartbeat_file"] - if 'heartbeat_file' in kwargs: self._heartbeat_file = kwargs['heartbeat_file'] self._deadman_process = None + self.heartbeat() self.start() def _start_deadman_process(self): @@ -72,11 +70,12 @@ class DeadMan(IModule): cmd = [] cmd.append("gns3dms") - cmd.append("--file %s" % (self._heartbeat_file)) + cmd.append("--file") + cmd.append("%s" % (self._heartbeat_file)) cmd.append("--background") log.debug("Deadman: Running %s"%(cmd)) - process = subprocess.Popen(cmd, shell=False) + process = subprocess.Popen(cmd, stderr=subprocess.STDOUT, shell=False) return process def _stop_deadman_process(self): @@ -143,7 +142,7 @@ class DeadMan(IModule): now = time.time() with open(self._heartbeat_file, 'w') as heartbeat_file: - heartbeat_file.write(now) + heartbeat_file.write(str(now)) heartbeat_file.close() log.debug("Deadman: heartbeat_file updated: %s %s" % ( @@ -151,5 +150,4 @@ class DeadMan(IModule): now, )) - self.start() \ No newline at end of file