From 351dc49dfd7f8982312bed1766cbab7b89d2eeed Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 18 Apr 2008 21:36:15 +0000 Subject: [PATCH] added rotate_logfile() --- qaapi/qa/Nodes.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qaapi/qa/Nodes.py b/qaapi/qa/Nodes.py index a290d5b..076db38 100644 --- a/qaapi/qa/Nodes.py +++ b/qaapi/qa/Nodes.py @@ -42,6 +42,19 @@ class Node(dict, Remote): filename = '/var/log/%s.log' % self['hostname'] self.logfile = Logfile(filename) + def rotate_logfile(self): + if os.path.isfile(self.logfile.filename): + (status, output) = utils.commands("ls %s*" % self.logfile.filename) + files = output.split("\n") + files.sort() + lastfile = files[-1:][0] + index = lastfile.split(self.logfile.filename)[1].replace(".", "") + if not index: + index = "1" + else: + index = str(int(index) + 1) + utils.commands("mv %s %s.%s" % (self.logfile.filename, self.logfile.filename, index)) + def get_host_ip(self): self.__init_logfile__() -- 2.47.0