From: Evan Broder Date: Thu, 26 Nov 2009 04:43:12 +0000 (-0500) Subject: First stab at the remctl script to handle new build queue submission X-Git-Tag: 0.1.5~69 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-dev.git/commitdiff_plain/66f2a7f0bd561c11302e9998caed0b34a4cbf4bb First stab at the remctl script to handle new build queue submission for the Invirtibuilder. svn path=/trunk/packages/invirt-dev/; revision=2563 --- 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()