From d88bac8a6df680a8f36037dc1476e373f179972b Mon Sep 17 00:00:00 2001 From: Nick Hurley Date: Wed, 16 Jan 2013 12:40:58 -0800 Subject: [PATCH] Pass around srid for a single ID per run --- srcloner.py | 3 +++ srdeferrer.py | 12 +++++++----- srmaster.py | 5 +++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/srcloner.py b/srcloner.py index 4a1436b..c49d15a 100644 --- a/srcloner.py +++ b/srcloner.py @@ -53,6 +53,7 @@ class StoneRidgeCloner(object): self.path = '/'.join([root, path]) self.nightly = nightly self.outroot = stoneridge.get_config('cloner', 'output') + self.srid = srid self.outdir = os.path.join(self.outroot, srid) self.keep = stoneridge.get_config_int('cloner', 'keep', default=50) self.max_attempts = stoneridge.get_config_int('cloner', 'attempts') @@ -68,6 +69,7 @@ class StoneRidgeCloner(object): logging.debug('host: %s' % (self.host,)) logging.debug('path: %s' % (self.path,)) logging.debug('nightly: %s' % (self.nightly,)) + logging.debug('srid: %s' % (self.srid,)) logging.debug('output root: %s' % (self.outroot,)) logging.debug('output directory: %s' % (self.outdir,)) logging.debug('keep history: %s' % (self.keep,)) @@ -253,6 +255,7 @@ class StoneRidgeCloner(object): def defer(self): args = ['srdeferrer.py', + '--srid', self.srid, '--config', None, # TODO '--log', '/dev/null', '--pidfile', tempfile.mktemp(), diff --git a/srdeferrer.py b/srdeferrer.py index 73f8804..ec73c42 100644 --- a/srdeferrer.py +++ b/srdeferrer.py @@ -10,8 +10,9 @@ import stoneridge class StoneRidgeDeferrer(object): - def __init__(self, nightly, ldap, sha, netconfigs, operating_systems, + def __init__(self, srid, nightly, ldap, sha, netconfigs, operating_systems, attempt): + self.srid = srid self.nightly = nightly self.ldap = ldap self.sha = sha @@ -30,8 +31,8 @@ class StoneRidgeDeferrer(object): time.sleep(30) now = int(time.time()) - stoneridge.enqueue(nightly=self.nightly, ldap=self.ldap, sha=self.sha, - netconfigs=self.netconfigs, + stoneridge.enqueue(srid=self.srid, nightly=self.nightly, ldap=self.ldap, + sha=self.sha, netconfigs=self.netconfigs, operating_systems=self.operating_systems, attempt=self.attempt) @@ -46,7 +47,8 @@ def daemon(deferrer, args): def main(): parser = stoneridge.DaemonArgumentParser() - parser.add_argument('--attempt', dest='attempt', type=int) + parser.add_argument('--srid', dest='srid', required=True) + parser.add_argument('--attempt', dest='attempt', type=int, required=True) parser.add_argument('--nightly', dest='nightly', action='store_true', default=False) parser.add_argument('--ldap', dest='ldap', default='') @@ -60,7 +62,7 @@ def main(): args = parser.parse_args() - deferrer = StoneRidgeDeferrer(args.nightly, args.ldap, args.sha, + deferrer = StoneRidgeDeferrer(args.srid, args.nightly, args.ldap, args.sha, args.netconfigs, args.operating_systems, args.attempt, args.interval) diff --git a/srmaster.py b/srmaster.py index fa1dd19..55e7d2a 100644 --- a/srmaster.py +++ b/srmaster.py @@ -21,8 +21,9 @@ class StoneRidgeMaster(stoneridge.QueueListener): self.config = config def handle(self, nightly, ldap, sha, netconfigs, operating_systems, - attempt=1): - srid = str(uuid.uuid4()) + srid=None, attempt=1): + if srid is None: + srid = str(uuid.uuid4()) logfile = 'cloner_%s.log' % (srid,) cloner_log = os.path.join(self.logdir, logfile) args = ['srcloner.py', '--config', self.config, '--srid', srid,