def on_put(self, req, resp, worker_id): """ updates a worker's status """ #load json payload in body body = load_body(req) self._validate_req_body_on_put(body) #find the worker in db worker_dict = self.db.find_one('worker', {'worker_id': worker_id}) if not worker_dict: _worker_not_found() worker = Worker(**worker_dict) if 'worker_status' in body: worker.status = body['worker_status'] if 'disk_usage' in body: worker.system_info.disk_usage = body['disk_usage'] if 'load_average' in body: worker.system_info.load_average = body['load_average'] self.db.update('worker', worker.format_for_save()) resp.status = falcon.HTTP_200
def on_put(self, req, resp, worker_id, validated_body): """ updates a worker's status """ #load validated json payload in body body = validated_body['worker_status'] #find the worker in db worker_dict = self.db.find_one('worker', {'worker_id': worker_id}) if not worker_dict: _worker_not_found() worker = Worker(**worker_dict) if 'status' in body: worker.status = body['status'] if 'system_info' in body: worker.system_info = SystemInfo(**body['system_info']) self.db.update('worker', worker.format_for_save()) resp.status = falcon.HTTP_200
def on_put(self, req, resp, worker_id, validated_body): """ updates a worker's status """ #load validated json payload in body body = validated_body['worker_status'] #find the worker in db worker_dict = self.db.find_one('worker', {'worker_id': worker_id}) if not worker_dict: _worker_not_found() worker = Worker(**worker_dict) if 'status' in body: worker.status = body['status'] if 'system_info' in body: worker.system_info = SystemInfo(**body['system_info']) self.db.update('worker', worker.format_for_save()) resp.status = falcon.HTTP_200