summaryrefslogtreecommitdiffstats
path: root/ipatests/test_integration/host.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-06-27 10:40:39 +0200
committerPetr Viktorin <pviktori@redhat.com>2013-07-25 12:32:33 +0200
commit4b439356b735d55c7da664bdf8d9f40468fb9c4d (patch)
tree7bd8d6868737791ee4435d58b8c6a67b53e9aced /ipatests/test_integration/host.py
parent65dfcb7cec7b641a87f9c59657eb7acbbecf911e (diff)
downloadfreeipa-4b439356b735d55c7da664bdf8d9f40468fb9c4d.tar.gz
freeipa-4b439356b735d55c7da664bdf8d9f40468fb9c4d.tar.xz
freeipa-4b439356b735d55c7da664bdf8d9f40468fb9c4d.zip
test_integration: Add log collection to Host
This allows collecting logs when a test context is not available.
Diffstat (limited to 'ipatests/test_integration/host.py')
-rw-r--r--ipatests/test_integration/host.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/ipatests/test_integration/host.py b/ipatests/test_integration/host.py
index 0d363f93a..5647e0dc2 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)