From 4b439356b735d55c7da664bdf8d9f40468fb9c4d Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 27 Jun 2013 10:40:39 +0200 Subject: test_integration: Add log collection to Host This allows collecting logs when a test context is not available. --- ipatests/test_integration/host.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ipatests/test_integration/host.py') diff --git a/ipatests/test_integration/host.py b/ipatests/test_integration/host.py index 0d363f93..5647e0dc 100644 --- a/ipatests/test_integration/host.py +++ b/ipatests/test_integration/host.py @@ -160,11 +160,21 @@ class Host(object): self._command_index = 0 + self.log_collectors = [] + def __repr__(self): template = ('<{s.__module__}.{s.__class__.__name__} ' '{s.hostname} ({s.role})>') return template.format(s=self) + def add_log_collector(self, collector): + """Register a log collector for this host""" + self.log_collectors.append(collector) + + def remove_log_collector(self, collector): + """Unregister a log collector""" + self.log_collectors.remove(collector) + @classmethod def from_env(cls, env, domain, hostname, role, index): ip = env.get('BEAKER%s%s_IP_env%s' % @@ -319,3 +329,7 @@ class Host(object): def put_file(self, localpath, remotepath): self.log.info('PUT %s', remotepath) self.sftp.put(localpath, remotepath) + + def collect_log(self, filename): + for collector in self.log_collectors: + collector(self, filename) -- cgit