Compare the bootstrapped minion commit SHA with the desired one.

This commit is contained in:
Pedro Algarvio 2014-04-06 15:50:39 +01:00
parent ce5d4277a4
commit 32597a7083

View file

@ -13,6 +13,7 @@ from __future__ import print_function
import os
import re
import sys
import json
import time
import random
import shutil
@ -315,6 +316,45 @@ def run(opts):
sys.stdout.flush()
time.sleep(5)
# Let's findout if the installed version meeds the passed in pillar
# information
if opts.commit is not None:
# Let's findout if the installed version meeds the passed in pillar
# information
proc = NonBlockingPopen(
'salt -t 100 {vm_name} --out json test.version'.format(vm_name),
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stream_stds=True
)
proc.poll_and_read_until_finish()
stdout, _ = proc.communicate()
retcode = proc.returncode
if retcode != 0:
print('Failed to get the bootstrapped minion version. Exit code: {0}'.format(retcode))
sys.stdout.flush()
if opts.clean and 'JENKINS_SALTCLOUD_VM_NAME' not in os.environ:
delete_vm(vm_name)
sys.exit(retcode)
if not stdout:
print('Failed to get the bootstrapped minion version(no output). Exit code: {0}'.format(retcode))
sys.stdout.flush()
if opts.clean and 'JENKINS_SALTCLOUD_VM_NAME' not in os.environ:
delete_vm(vm_name)
sys.exit(retcode)
version_info = json.loads(stdout.strip())
if not version_info[vm_name].endswith(opts.commit[:7]):
print('The boostrapped minion version commit does not match the desired commit:')
print(' {0!r} does not end with {1!r}'.format(version_info[vm_name], opts.commit[:7]))
sys.stdout.flush()
if opts.clean and 'JENKINS_SALTCLOUD_VM_NAME' not in os.environ:
delete_vm(vm_name)
sys.exit(retcode)
# Do we need extra setup?
if opts.salt_url != SALT_GIT_URL:
cmds = (