def process_messages(self): while 1: request = self.bean.reserve() tube = request.stats()['tube'] if tube == cf.TUBE_WEB_UPDATES: logger.debug("processing %r" % request.body) try: job = json.loads(request.body) approved = True if job['status'] == 'approved' else False rsync_tools.gateway_full_read() kimcode = job['kimid'] if database.isuuid(kimcode): leader = database.uuid_type(kimcode) insert_one_result(leader, kimcode) else: insert_one_object(kimcode) self.bean.send_msg(cf.TUBE_UPDATES, request.body) except Exception as e: logger.error("%r" % e) elif tube == cf.TUBE_RESULTS or tube == cf.TUBE_ERRORS: logger.debug("processing %r" % request.body) try: kimcode = json.loads(request.body)['jobid'] leader = database.uuid_type(kimcode) rsync_tools.gateway_write_result(leader, kimcode) except Exception as e: logger.error("%r" % e) self.bean.send_msg(cf.TUBE_WEB_RESULTS, request.body) request.delete()
def new(self, itemid, status='approved', priority='normal', force=False): """ New KIM object submitted to web-app """ priority = network.transform_priority(priority) leader = database.get_leader(itemid).lower() approved = (status == 'approved') self.rsync_kimid(itemid, approved=approved) # insert this object into the database if database.isuuid(itemid): mongodb.insert_one_result(leader, itemid) else: mongodb.insert_one_object(itemid) # pass the message along to the director msg = network.director_update_message( itemid=itemid, status=status, priority=priority, force=force ) self.send_job('pipeline.tasks.director_run', kwargs=msg)
def result(self, jobid, uuid, status='approved', priority='normal', force=False): # got an update request internally, a result or error has come in priority = network.transform_priority(priority) self.logger.debug("processing jobid %r" % jobid) leader = database.uuid_type(uuid) # insert the test result into the mongo database mongodb.insert_one_result(leader, uuid) # sync this test result / error to the webapp if not cf.GATEWAY_DISABLE_WRITE_RESULT: rsync_tools.gateway_write_result(leader, uuid) rsync_tools.ssh_touch_done(leader, uuid) # automatically recycle the result back into updates queue to # trigger dependency runs by the director (this it not the # same as the webapp queue!) if leader == 'tr': msg = network.director_update_message( itemid=uuid, status='approved', priority=priority, force=force ) self.send_job('pipeline.tasks.director_run', kwargs=msg)