def add_jobs(package, package_type, config, klass, changes): for type in config['job_classes'][klass]: if klass == 'source': suite = "unstable" arch = "all" else: suite = package['suite'] arch = package['arch'] j = Job(package=package['_id'], package_type=package_type, suite=suite, arch=arch, type=type) print(" -> Job: ", j.save(), type) if klass == 'source': # add builds suite = changes['Distribution'] for arch in config['arches']: j = Job(arch=arch, suite=suite, type='build', package=package['_id'], package_type=package_type) print(" -> Bin: ", j.save(), arch, suite)
def close_job(self, job): """ Close a job after pushing reports / binaries up. """ j = Job.load(job) j['finished_at'] = dt.datetime.utcnow() return j.save()
def submit_report(self, report, job, failed): """ Submit a report from a run. report - firehose lint job job - job ID this relates to failed - was it able to complete properly """ job = Job.load(job) package = job.get_package() report = Report(report=report, builder=get_builder_id(), package=package['_id'], package_type=job['package_type'], job=job['_id'], failed=failed) uuid_path = uuid_to_path(job['_id']) path = os.path.join(config['pool'], uuid_path) if not os.path.exists(path): os.makedirs(path) report['log_path'] = os.path.join(uuid_path, 'log') report['firehose_path'] = os.path.join(uuid_path, 'firehose.xml') rid = report.save() if failed: send_failed_email(job, package, report) return rid
def forfeit_job(self, job): j = Job.load(job) buildd = j.get_builder() if buildd['_id'] != get_builder_id(): return None # meh j['assigned_at'] = None j['builder'] = None return j.save()
def get_next_job(self, suites, arches, types): """ Get an unassigned lint job from suite suites, arches arches """ try: nj = Job.next_job(suites, arches, types) except KeyError: return None nj['assigned_at'] = dt.datetime.utcnow() nj['builder'] = get_builder_id() nj.save() return dict(nj)
def accept_binary(config, changes): key = changes.validate_signature() arch = changes['Architecture'] if " " in arch: arches = set(arch.split(" ")) if "all" in arches: arches.remove("all") arches = list(arches) if len(arches) != 1: return reject(config, changes, 'too-many-arches') arch = changes._data['Architecture'] = arches[0] suite = changes['Distribution'] binaries = changes.get_files() try: job = changes['x-lucy-job'] except KeyError: return reject(config, changes, 'no-job') try: job = Job.load(job) except KeyError: return reject(config, changes, 'invalid-job') try: buildd = Machine.get_by_key(key) except KeyError: return reject(config, changes, 'youre-not-a-machine') binary = Binary(job=job['_id'], arch=arch, suite=suite, binaries=[os.path.basename(x) for x in binaries], builder=buildd['_id']) binary.save() add_jobs(binary, 'binary', config, 'binary', changes) path = move_to_pool(config, binary['source'], changes, root=arch) os.unlink(changes.get_filename()) print("accept binary")
def get_current_jobs(self): """ Get the current job for the builder or return None. """ return list(Job.assigned_jobs(get_builder_id()))