Add bare-metal helper scripts.

Remove watch_deploy, and add wait_for_nova and wait_for_puppet
which have superceded it.

Change-Id: Icb771b85ea727b77cd9195be2fcec1c828e90444
This commit is contained in:
James E. Blair
2011-09-07 13:00:57 -07:00
parent a6eac16522
commit a579ac5d45
3 changed files with 33 additions and 39 deletions

12
slave_scripts/wait_for_nova.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
URL=$1
echo "Jenkins: Waiting for Nova to start on infrastructure node"
RET=7
while [ $RET != 0 ]; do
curl -s $URL >/dev/null
RET=$?
sleep 1
done
echo "Jenkins: Nova is running."

View File

@@ -0,0 +1,21 @@
#!/bin/bash
# wait_for_pupet.sh LOGFILE HOSTNAME [HOSTNAME...]
# Search LOGFILE for puppet completion on each host
FINISH_RE="puppet-agent\[.*\]: Finished catalog run in .* seconds"
LOGFILE=$1
shift
HOSTS=$@
echo "Jenkins: Waiting for puppet to complete on all nodes"
DONE=0
while [ $DONE != 1 ]; do
DONE=0
for hostname in $HOSTS
do
if (grep "$hostname $FINISH_RE" $LOGFILE >/dev/null); then DONE=1; fi
done
sleep 5
done
echo "Jenkins: Puppet is complete."

View File

@@ -1,39 +0,0 @@
#!/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