Add watch_deploy script.

Add the watch_deploy.py script for use on jenkins slaves deploying
onto bare metal hardware.  It tails a logfile from rsyslog
(configuration of which will be in openstack-ci-puppet) and looks
for puppet completion messages, exiting when they are found.

Change-Id: I50501845ef226a1946bcb5af40af94c0fbe3125a
Reviewed-on: https://review.openstack.org/335
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
James E. Blair
2011-08-24 16:17:19 -07:00
committed by Jenkins
parent 397e9af267
commit 74cfd300d8

39
slave_scripts/watch_deploy.py Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env python
# Tail a syslog file printing each line while looking for indications
# that puppet has completed its initial run on each host.
# Once puppet is finished, wait 30 seconds (for any further interesting
# log entries), then exit.
import re
import time
import sys
HOSTS = set(['baremetal%02i'%(x+1) for x in range(4)])
LOGFILE = "/var/log/deploy.log"
COMPLETE_RE = re.compile(r'^\w+ \w+ \d\d:\d\d:\d\d (\w+) puppet-agent\[\d+\]: Finished catalog run in \S+ seconds$')
EXIT_DELAY = 30
logf = open(LOGFILE)
completed_hosts = set()
exit_time = None
while True:
now = time.time()
if exit_time and exit_time < now:
sys.exit(0)
where = logf.tell()
line = logf.readline()
if not line:
time.sleep(1)
logf.seek(where)
continue
sys.stdout.write(line)
sys.stdout.flush()
m = COMPLETE_RE.match(line)
if m:
completed_hosts |= set([m.group(1)])
if completed_hosts == HOSTS:
exit_time = time.time() + EXIT_DELAY