From 66f2a7f0bd561c11302e9998caed0b34a4cbf4bb Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Wed, 25 Nov 2009 23:43:12 -0500 Subject: [PATCH 1/1] First stab at the remctl script to handle new build queue submission for the Invirtibuilder. svn path=/trunk/packages/invirt-dev/; revision=2563 --- invirt-submit-build | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 invirt-submit-build diff --git a/invirt-submit-build b/invirt-submit-build new file mode 100755 index 0000000..caa949f --- /dev/null +++ b/invirt-submit-build @@ -0,0 +1,52 @@ +#!/usr/bin/python + +"""Validate and add a new item to the Invirt build queue. + +This script, intended to be invoked by remctl, first validates the +build submitted parameters, and then adds a new item to the +Invirtibuilder build queue, triggering the Invirtibuilder to start the +build. + +The expected arguments are + + pocket package commit + +This script will also automatically extract the Kerberos principal +used to submit the job, and include that in the queue file for records +keeping. +""" + + +import datetime +import os +import sys +import tempfile +import uuid + +import invirt.builder as b + + +def main(): + pocket, package, commit = sys.argv[1:4] + principal = os.environ['REMOTE_USER'] + request_time = datetime.datetime.utcnow() + q_path = os.path.join(b._QUEUE_DIR, + '%s_%s' % (request_time.strftime('%Y%m%d%H%M%S'), + uuid.uuid4())) + + try: + validateBuild(pocket, package, commit) + except b.InvalidBuild, e: + print >>sys.stderr, "E: %s" % e + sys.exit(1) + + # To keep from triggering the Invirtibuilder before we've actually + # written the file out, first write the queue entry to a temporary + # file, and then move it into the queue directory. + q = tempfile.NamedTemporaryFile(delete=False) + print >>q, "%s %s %s %s" % (pocket, package, commit, principal) + os.rename(q.name, q_path) + + +if __name__ == '__main__': + main() -- 1.7.9.5