summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-10-09 15:00:24 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-10-09 15:00:24 +0100
commit99e021d5135c90662dc470110d584cea3dc7805b (patch)
tree0c55cff666a5bed5753ee98d8822945acfabb96f
parentc0a04093225730d70539147ac858257e84d2309c (diff)
downloadlorry-controller-99e021d5135c90662dc470110d584cea3dc7805b.tar.gz
Support HEAD setting
-rwxr-xr-xlorry-controller13
-rw-r--r--lorrycontroller/confparser.py28
2 files changed, 32 insertions, 9 deletions
diff --git a/lorry-controller b/lorry-controller
index ba793ad..cf5dbae 100755
--- a/lorry-controller
+++ b/lorry-controller
@@ -124,6 +124,8 @@ class LorryController(cliapp.Application):
logging.error(err)
store_state = False
if store_state:
+ self.maybe_runcmd(["ssh", "git@localhost", "set-head",
+ new_lorry, lorry['source-HEAD']])
mgr.lorry_state[new_lorry] = {
'destroy': conf['destroy'],
'conf': conf_uuid,
@@ -142,7 +144,13 @@ class LorryController(cliapp.Application):
if mgr.lorry_state[upd_lorry]['lorry'] != \
self.conf.lorries[upd_lorry]:
lorry = self.conf.lorries[upd_lorry]
+ old_lorry = mgr.lorry_state[upd_lorry]["lorry"]
+ if lorry["source-HEAD"] != \
+ old_lorry.get("source-HEAD", "refs/heads/master"):
+ self.maybe_runcmd(['ssh', 'git@localhost', 'set-head',
+ upd_lorry, lorry["source-HEAD"]])
conf_uuid = lorry['controller-uuid']
+ conf = self.conf.configs[conf_uuid]
nextdue = self.conf.duetimes[upd_lorry]
mgr.lorry_state[upd_lorry] = {
'destroy': conf['destroy'],
@@ -201,7 +209,10 @@ class LorryController(cliapp.Application):
'git'))
def maybe_runcmd(self, *args, **kwargs):
- if not self.settings['dry-run']:
+ cmdargs = args[0]
+ if (not self.settings['dry-run']) or \
+ (cmdargs[0] == "ssh" and \
+ cmdargs[len(cmdargs)-1] == "--verbose"):
return self.runcmd_unchecked(*args, **kwargs)
else:
logging.debug("DRY-RUN: Not running %r" % args)
diff --git a/lorrycontroller/confparser.py b/lorrycontroller/confparser.py
index 9c4e4b4..1df3186 100644
--- a/lorrycontroller/confparser.py
+++ b/lorrycontroller/confparser.py
@@ -190,14 +190,25 @@ class LorryControllerConfig(object):
# 1. Ensure that if we need to 'ls' the trove, we do it
now = time.time()
listcmdargs = ["ssh", "-oStrictHostKeyChecking=no",
- "-oBatchMode=yes", "git@" + trove['trovehost'], "ls"]
- state['next-ls'] = state.get('next-ls', now - 1)
- if state['next-ls'] < now:
+ "-oBatchMode=yes", "git@" + trove['trovehost'], "ls",
+ "--verbose"]
+ state['next-vls'] = state.get('next-vls', now - 1)
+ if state['next-vls'] < now:
exit, out, err = self.app.maybe_runcmd(listcmdargs)
if exit == 0:
- state['last-ls-output'] = [x[3:] for x in out.split("\n")]
- while state['next-ls'] < now:
- state['next-ls'] += trove['ls-interval-parsed']
+ repo_info = {}
+ for entry in [x for x in out.split("\n") if x != ""]:
+ elems = entry.split(" ")
+ this_repo = {
+ "perm": elems[0],
+ "name": elems[1],
+ "head": elems[2],
+ "desc": " ".join(elems[3:]),
+ }
+ repo_info[elems[1]] = this_repo
+ state['last-ls-output'] = repo_info
+ while state['next-vls'] < now:
+ state['next-vls'] += trove['ls-interval-parsed']
else:
# Pass through unchanged
state['last-ls-output'] = state.get('last-ls-output', [])
@@ -210,7 +221,7 @@ class LorryControllerConfig(object):
# 2. For every entry in last-ls-output, construct a lorry if we want it
lorries_made = set()
- for remotereponame in state['last-ls-output']:
+ for remotereponame, info in state['last-ls-output'].iteritems():
localreponame = None
for local, remote in trove['prefixmap'].iteritems():
if remotereponame.startswith(remote+"/"):
@@ -222,7 +233,8 @@ class LorryControllerConfig(object):
"type": "git",
"url": "ssh://git@%s/%s.git" % (trove['trovehost'],
remotereponame),
- "controller-uuid": trove['uuid']
+ "controller-uuid": trove['uuid'],
+ "source-HEAD": info["head"],
}
if localreponame in self.lorries:
logging.warn("Skipping %s (%s from %s) because we already "