def _handleAssignmentStateTransition(self, workload, request_args, dn): req_status = request_args["RequestStatus"] if req_status == "assigned" and not request_args.get('Team', '').strip(): raise InvalidSpecParameterValue("Team must be set during workflow assignment: %s" % request_args) if ('SoftTimeout' in request_args) and ('GracePeriod' in request_args): request_args['SoftTimeout'] = int(request_args['SoftTimeout']) #TODO: not sure why GracePeriod when passed from web ingerface but convert here request_args['GracePeriod'] = int(request_args['GracePeriod']) request_args['HardTimeout'] = request_args['SoftTimeout'] + request_args['GracePeriod'] #Only allow extra value update for assigned status cherrypy.log("INFO: Assign request, input args: %s ..." % request_args) try: workload.updateArguments(request_args) except Exception as ex: msg = traceback.format_exc() cherrypy.log("Error for request args %s: %s" % (request_args, msg)) raise InvalidSpecParameterValue(str(ex)) # validate/update OutputDatasets after ProcessingString and AcquisionEra is updated request_args['OutputDatasets'] = workload.listOutputDatasets() validateOutputDatasets(request_args['OutputDatasets'], workload.getDbsUrl()) # legacy update schema to support ops script loadRequestSchema(workload, request_args) report = self.reqmgr_db_service.updateRequestProperty(workload.name(), request_args, dn) workload.saveCouch(self.config.couch_host, self.config.couch_reqmgr_db) return report
def _handleAssignmentStateTransition(self, workload, request_args, dn): req_status = request_args["RequestStatus"] if req_status == "assigned" and not request_args.get('Team', '').strip(): raise InvalidSpecParameterValue( "Team must be set during workflow assignment: %s" % request_args) if ('SoftTimeout' in request_args) and ('GracePeriod' in request_args): request_args['SoftTimeout'] = int(request_args['SoftTimeout']) #TODO: not sure why GracePeriod when passed from web ingerface but convert here request_args['GracePeriod'] = int(request_args['GracePeriod']) request_args['HardTimeout'] = request_args[ 'SoftTimeout'] + request_args['GracePeriod'] #Only allow extra value update for assigned status try: workload.updateArguments(request_args) except Exception as ex: msg = traceback.format_exc() cherrypy.log("Error for request args %s: %s" % (request_args, msg)) raise InvalidSpecParameterValue(str(ex)) # legacy update schema to support ops script loadRequestSchema(workload, request_args) #update OutputDatasets after ProcessingString and AcquisionEra is updated request_args['OutputDatasets'] = workload.listOutputDatasets() report = self.reqmgr_db_service.updateRequestProperty( workload.name(), request_args, dn) workload.saveCouch(self.config.couch_host, self.config.couch_reqmgr_db) return report
def _handleAssignmentStateTransition(self, workload, request_args, dn): req_status = request_args["RequestStatus"] if not request_args.get('Team', '').strip() and \ not request_args.get('Teams', []) and req_status == "assigned": raise InvalidSpecParameterValue("Team need to be set when assign the workflow: %s" % request_args) if ('SoftTimeout' in request_args) and ('GracePeriod' in request_args): request_args['SoftTimeout'] = int(request_args['SoftTimeout']) #TODO: not sure why GracePeriod when passed from web ingerface but convert here request_args['GracePeriod'] = int(request_args['GracePeriod']) request_args['HardTimeout'] = request_args['SoftTimeout'] + request_args['GracePeriod'] #Only allow extra value update for assigned status try: workload.updateArguments(request_args) except Exception as ex: msg = traceback.format_exc() cherrypy.log("Error for request args %s: %s" % (request_args, msg)) raise InvalidSpecParameterValue(str(ex)) # legacy update schema to support ops script loadRequestSchema(workload, request_args) # trailing / is needed for the savecouchUrl function report = self.reqmgr_db_service.updateRequestProperty(workload.name(), request_args, dn) workload.saveCouch(self.config.couch_host, self.config.couch_reqmgr_db) return report
def _handleAssignmentStateTransition(self, workload, request_args, dn): if ('SoftTimeout' in request_args) and ('GracePeriod' in request_args): request_args['HardTimeout'] = request_args['SoftTimeout'] + request_args['GracePeriod'] # Only allow extra value update for assigned status cherrypy.log("INFO: Assign request %s, input args: %s ..." % (workload.name(), request_args)) try: workload.updateArguments(request_args) except Exception as ex: msg = traceback.format_exc() cherrypy.log("Error for request args %s: %s" % (request_args, msg)) raise InvalidSpecParameterValue(str(ex)) # validate/update OutputDatasets after ProcessingString and AcquisionEra is updated request_args['OutputDatasets'] = workload.listOutputDatasets() validateOutputDatasets(request_args['OutputDatasets'], workload.getDbsUrl()) # by default, it contains all unmerged LFNs (used by sites to protect the unmerged area) request_args['OutputModulesLFNBases'] = workload.listAllOutputModulesLFNBases() # FIXME: remove it on HG1710, when this #7355 is complete fixed if not request_args['Team'] or not isinstance(request_args['Team'], basestring): raise InvalidSpecParameterValue("Team MUST be a non-empty string") # legacy update schema to support ops script loadRequestSchema(workload, request_args) # save the spec first before update the reqmgr request status to prevent race condition # when workflow is pulled to GQ before site white list is updated workload.saveCouch(self.config.couch_host, self.config.couch_reqmgr_db) report = self.reqmgr_db_service.updateRequestProperty(workload.name(), request_args, dn) return report
def _handleAssignmentStateTransition(self, workload, request_args, dn): if 'Team' not in request_args or not request_args['Team'].strip(): raise InvalidSpecParameterValue("A Team name must be set during workflow assignment") if 'SiteWhitelist' not in request_args or not request_args['SiteWhitelist']: raise InvalidSpecParameterValue("A non-empty SiteWhitelist must be set at assignment") if ('SoftTimeout' in request_args) and ('GracePeriod' in request_args): request_args['SoftTimeout'] = int(request_args['SoftTimeout']) request_args['GracePeriod'] = int(request_args['GracePeriod']) request_args['HardTimeout'] = request_args['SoftTimeout'] + request_args['GracePeriod'] # Only allow extra value update for assigned status cherrypy.log("INFO: Assign request %s, input args: %s ..." % (workload.name(), request_args)) try: workload.updateArguments(request_args) except Exception as ex: msg = traceback.format_exc() cherrypy.log("Error for request args %s: %s" % (request_args, msg)) raise InvalidSpecParameterValue(str(ex)) # validate/update OutputDatasets after ProcessingString and AcquisionEra is updated request_args['OutputDatasets'] = workload.listOutputDatasets() validateOutputDatasets(request_args['OutputDatasets'], workload.getDbsUrl()) # legacy update schema to support ops script loadRequestSchema(workload, request_args) report = self.reqmgr_db_service.updateRequestProperty(workload.name(), request_args, dn) workload.saveCouch(self.config.couch_host, self.config.couch_reqmgr_db) return report
def post(self, workload_pair_list, multi_update_flag=False, multi_names_flag=False): """ Create and update couchDB with a new request. request argument is passed from validation (validation convert cherrypy.request.body data to argument) TODO: this method will have some parts factored out so that e.g. clone call can share functionality. NOTES: 1) do not strip spaces, #4705 will fails upon injection with spaces; currently the chain relies on a number of things coming in #4705 2) reqInputArgs = Utilities.unidecode(JsonWrapper.loads(body)) (from ReqMgrRESTModel.putRequest) """ # storing the request document into Couch if multi_update_flag: return self.put(workload_pair_list) if multi_names_flag: return self.get(name=workload_pair_list) out = [] for workload, request_args in workload_pair_list: self._update_additional_request_args(workload, request_args) # legacy update schema to support ops script loadRequestSchema(workload, request_args) cherrypy.log("INFO: Create request, input args: %s ..." % request_args) workload.saveCouch(request_args["CouchURL"], request_args["CouchWorkloadDBName"], metadata=request_args) out.append({"request": workload.name()}) return out
def _handleAssignmentStateTransition(self, workload, request_args, dn): req_status = request_args["RequestStatus"] if not request_args.get("Team", "").strip() and not request_args.get("Teams", []) and req_status == "assigned": raise InvalidSpecParameterValue("Team need to be set when assign the workflow: %s" % request_args) if ("SoftTimeout" in request_args) and ("GracePeriod" in request_args): request_args["SoftTimeout"] = int(request_args["SoftTimeout"]) # TODO: not sure why GracePeriod when passed from web ingerface but convert here request_args["GracePeriod"] = int(request_args["GracePeriod"]) request_args["HardTimeout"] = request_args["SoftTimeout"] + request_args["GracePeriod"] # Only allow extra value update for assigned status try: workload.updateArguments(request_args) except Exception as ex: msg = traceback.format_exc() cherrypy.log("Error for request args %s: %s" % (request_args, msg)) raise InvalidSpecParameterValue(str(ex)) # legacy update schema to support ops script loadRequestSchema(workload, request_args) # update OutputDatasets after ProcessingString and AcquisionEra is updated request_args["OutputDatasets"] = workload.listOutputDatasets() report = self.reqmgr_db_service.updateRequestProperty(workload.name(), request_args, dn) workload.saveCouch(self.config.couch_host, self.config.couch_reqmgr_db) return report
def post(self, workload_pair_list, multi_update_flag=False, multi_names_flag=False): """ Create and update couchDB with a new request. request argument is passed from validation (validation convert cherrypy.request.body data to argument) TODO: this method will have some parts factored out so that e.g. clone call can share functionality. NOTES: 1) do not strip spaces, #4705 will fails upon injection with spaces; currently the chain relies on a number of things coming in #4705 2) reqInputArgs = Utilities.unidecode(json.loads(body)) (from ReqMgrRESTModel.putRequest) """ # storing the request document into Couch if multi_update_flag: return self.put(workload_pair_list) if multi_names_flag: return self.get(name=workload_pair_list) out = [] for workload, request_args in workload_pair_list: self._update_additional_request_args(workload, request_args) # legacy update schema to support ops script loadRequestSchema(workload, request_args) cherrypy.log("INFO: Create request, input args: %s ..." % request_args) workload.saveCouch(request_args["CouchURL"], request_args["CouchWorkloadDBName"], metadata=request_args) out.append({'request': workload.name()}) return out