示例#1
0
/**
 * \brief The cancelJob function cancels a job from its id
 * \param session : The session information
 * \param options : An object containing user-provided options
 * \param infoMsg : The information message
 * \return int : an error code
 */
int
vishnu::cancelJob(const std::string& sessionKey,
                  const TMS_Data::CancelOptions& options)
throw (UMSVishnuException, TMSVishnuException, UserException, SystemException) {

  checkEmptyString(sessionKey, "The session key");

  if (options.getJobId().empty() && options.getMachineId().empty() && options.getUser().empty()) {
    throw UserException(ERRCODE_INVALID_PARAM, "Neither job, machine, nor user target was specified");
  }
  int retCode = 0;
  if (! options.getJobId().empty()) { // cancel a specific job
    TMS_Data::Job job;
    if (options.getMachineId().empty()) {
      vishnu::getJobInfo(sessionKey, options.getJobId(), "", job);
    } else {
      job.setMachine(options.getMachineId());
    }
    retCode = JobProxy(sessionKey, job.getMachine()).cancelJob(options);
  } else {
    std::string machineId = options.getMachineId();
    UMS_Data::ListMachines machines;
    if (! machineId.empty() && machineId != ALL_KEYWORD) { // cancel job on the specified machine
      UMS_Data::Machine_ptr machine = new UMS_Data::Machine();
      machine->setMachineId(machineId);
      machines.getMachines().push_back(machine);
    } else {                                              // cancel job on all machines
      listMachinesWithUserLocalAccount(sessionKey, machines);
    }

    // now perform the request
    for (int i=0; i< machines.getMachines().size(); ++i) {
      retCode += JobProxy(sessionKey, machines.getMachines().get(i)->getMachineId()).cancelJob(options);
    }
  }
  return retCode;
}
示例#2
0
文件: api_tms.cpp 项目: Ecapo/vishnu
/**
 * \brief The cancelJob function cancels a job from its id
 * \param sessionKey : The session key
 * \param machineId : The id of the machine
 * \param jobId : The Id of the job
 * \param infoMsg : The information message
 * \return int : an error code
 */
int
vishnu::cancelJob(const std::string& sessionKey,
		const std::string& machineId,
		const std::string& jobId)
throw (UMSVishnuException, TMSVishnuException, UserException, SystemException) {

	checkEmptyString(sessionKey, "The session key");
	checkEmptyString(machineId, "The machine id");
	checkEmptyString(jobId, "The job id");

	SessionProxy sessionProxy(sessionKey);

	TMS_Data::Job job;
	job.setJobId(jobId);

	return JobProxy(sessionProxy,
			machineId,
			job).cancelJob();

}