END_TEST




START_TEST(confirm_reservation_test)
  {
  char      *rsv_id = (char *)"20";
  long long  pagg = 20;
  int        rc;

  /* this test only works if you're root */
  if (getuid() == 0)
    {
    rc = confirm_reservation(jobids[0], rsv_id, pagg, NULL, apbasil_protocol);
    /*fail_unless(rc == 0, "Couldn't execute the reservation");*/
    snprintf(buf, sizeof(buf), "Reservation id should be 20 but was %s", rsv_id);
    fail_unless(!strcmp(rsv_id, "20"), buf);
    
    rc = confirm_reservation(jobids[1], rsv_id, pagg, blank_cmd, apbasil_protocol);
    fail_unless(rc != 0, "Somehow parsed the blank command's output?");
    
    rc = parse_confirmation_output((char *)"tom");
    fail_unless(rc == ALPS_PARSING_ERROR, "We parsed non-xml?");
    }
  }
예제 #2
0
int create_alps_reservation(

  char       *exec_hosts,
  char       *username,
  char       *jobid,
  char       *apbasil_path,
  char       *apbasil_protocol,
  long long   pagg_id_value,
  char      **reservation_id)

  {
  resizable_array *host_req_list;
  dynamic_string  *command;
  int              rc = 1;
  int              retry_count = 0;
  char            *user = strdup(username);
  char            *aroba;

  host_req_list = parse_exec_hosts(exec_hosts);

  if (host_req_list->num == 0)
    {
    /* this is a login only job */
    return(PBSE_NONE);
    }

  if ((aroba = strchr(user, '@')) != NULL)
    *aroba = '\0';
  
  command = get_reservation_command(host_req_list, user, jobid, apbasil_path, apbasil_protocol);

  free(user);

  /* retry on failure up to  */
  while ((retry_count++ < APBASIL_RETRIES) &&
         (rc != apbasil_fail_permanent) &&
         (rc != PBSE_NONE))
    {
    rc = execute_reservation(command->str, reservation_id);

    if (rc != PBSE_NONE)
      usleep(100);
    }

  free_dynamic_string(command);

  if (rc == PBSE_NONE)
    {
    rc = 1;
    retry_count = 0;
  
    while ((retry_count++ < APBASIL_RETRIES) &&
           (rc != apbasil_fail_permanent) &&
           (rc != PBSE_NONE))
      {
      rc = confirm_reservation(jobid, *reservation_id, pagg_id_value, apbasil_path, apbasil_protocol);

      if (rc != PBSE_NONE)
        usleep(100);
      }
    }

  return(rc);
  } /* END create_alps_reservation() */
예제 #3
0
int create_alps_reservation(

  char       *exec_hosts,
  char       *username,
  char       *jobid,
  char       *apbasil_path,
  char       *apbasil_protocol,
  long long   pagg_id_value,
  int         use_nppn,
  int         nppcu,
  int         mppdepth,
  char      **reservation_id,
  const char *mppnodes)

  {
  resizable_array *host_req_list;
  dynamic_string  *command;
  int              rc = 1;
  int              retry_count = 0;
  char            *user = strdup(username);
  char            *aroba;

  if ((aroba = strchr(user, '@')) != NULL)
    *aroba = '\0';

  if (strchr(exec_hosts, '|') == NULL)
    {
    host_req_list = parse_exec_hosts(exec_hosts,mppnodes);
    
    if (host_req_list->num == 0)
      {
      free(user);
      free_resizable_array(host_req_list);
      /* this is a login only job */
      return(PBSE_NONE);
      }
  
    command = get_reservation_command(host_req_list, user, jobid, apbasil_path, apbasil_protocol, NULL, use_nppn, nppcu, mppdepth);
  
    free_resizable_array(host_req_list);
    }
  else
    {
    command = get_reservation_command(NULL, user, jobid, apbasil_path, apbasil_protocol, exec_hosts, use_nppn, nppcu, mppdepth);
    }

  free(user);

  /* retry on failure up to  */
  while ((retry_count++ < APBASIL_RETRIES) &&
         (rc != apbasil_fail_permanent) &&
         (rc != PBSE_NONE))
    {
    rc = execute_reservation(command->str, reservation_id);

    if (rc != PBSE_NONE)
      usleep(100);
    }

  if (rc == PBSE_NONE)
    {
    char confirm_command_buf[MAXLINE * 2];

    if (LOGLEVEL >= 3)
      {
      snprintf(log_buffer, sizeof(log_buffer),
        "Successful reservation command is: %s", command->str);
      log_event(PBSEVENT_JOB | PBSEVENT_SYSLOG, PBS_EVENTCLASS_JOB, __func__, log_buffer);
      }

    rc = 1;
    retry_count = 0;
  
    while ((retry_count++ < APBASIL_RETRIES) &&
           (rc != apbasil_fail_permanent) &&
           (rc != PBSE_NONE))
      {
      rc = confirm_reservation(jobid, *reservation_id, pagg_id_value, apbasil_path, apbasil_protocol,
                               confirm_command_buf, sizeof(confirm_command_buf));

      if (rc != PBSE_NONE)
        usleep(100);
      }

    if (rc != PBSE_NONE)
      {
      snprintf(log_buffer, sizeof(log_buffer),
        "Failed confirmation command is: %s", confirm_command_buf);
      log_err(-1, __func__, confirm_command_buf);
      }
    else if (LOGLEVEL >= 3)
      {
      snprintf(log_buffer, sizeof(log_buffer),
        "Successful confirmation command is: %s", confirm_command_buf);
      log_event(PBSEVENT_JOB | PBSEVENT_SYSLOG, PBS_EVENTCLASS_JOB, __func__, log_buffer);
      }
    }
  else
    {
    snprintf(log_buffer, sizeof(log_buffer),
      "Failed reservation command is: %s", command->str);
    log_err(-1, __func__, log_buffer);
    }

  free_dynamic_string(command);

  return(rc);
  } /* END create_alps_reservation() */