Esempio n. 1
0
int create_reserve_params_from_multi_req_list(

  char           *multi_req_list, /* I */
  char           *apbasil_protocol, /* I */
  int             nppcu,          /* I */
  int             mppdepth,       /* I */
  dynamic_string *command)        /* O */

  {
  dynamic_string *node_list = get_dynamic_string(-1, NULL);
  char           *tok;
  char           *str = multi_req_list;
  int             node_count;
  char           *comma;
  unsigned int    width;
  unsigned int    nppn;
  
  while ((tok = threadsafe_tokenizer(&str, "*")) != NULL)
    {
    node_count = 1;

    clear_dynamic_string(node_list);
    append_dynamic_string(node_list, tok);
    
    comma = tok;
    while ((comma = strchr(comma+1, ',')) != NULL)
      node_count++;
    
    tok = threadsafe_tokenizer(&str, "|");
    nppn = atoi(tok);
    
    width = nppn * node_count;

    adjust_for_depth(width, nppn, mppdepth);

    save_current_reserve_param(command, apbasil_protocol, node_list, width, nppn, nppcu, mppdepth);
    }

  if (node_list != NULL)
    free(node_list);

  return(PBSE_NONE);
  } /* END create_reserve_params_from_multi_req_list() */
Esempio n. 2
0
int save_single_mic_status(

  dynamic_string *single_mic_status,
  pbs_attribute  *temp)

  {
  int rc = PBSE_NONE;

  if (single_mic_status->used > 0)
    {
    if ((rc = decode_arst(temp, NULL, NULL, single_mic_status->str, 0)) != PBSE_NONE)
      {
      log_err(ENOMEM, __func__, "");
      free_arst(temp);
      }
    
    clear_dynamic_string(single_mic_status);
    }

  return(rc);
  } /* END save_single_mic_status() */
Esempio n. 3
0
int svr_save_xml(

  struct server *ps,
  int            mode)

  {
  char *id   = "svr_save_xml";
  char  buf[MAXLINE<<8];
  dynamic_string *ds;

  int   fds;
  int   rc;
  int   len;
  int   i;

  fds = open(path_svrdb, O_WRONLY | O_CREAT | O_Sync | O_TRUNC, 0600);

  if (fds < 0)
    {
    log_err(errno,id,msg_svdbopen);

    return(-1);
    }

  /* write the sv_qs info */
  snprintf(buf,sizeof(buf),
    "<server_db>\n<numjobs>%d</numjobs>\n<numque>%d</numque>\n<nextjobid>%d</nextjobid>\n<savetime>%ld</savetime>\n",
    ps->sv_qs.sv_numjobs,
    ps->sv_qs.sv_numque,
    ps->sv_qs.sv_jobidnumber,
    time_now);
  len = strlen(buf);

  if ((rc = write_buffer(buf,len,fds)))
    return(rc);

  /* write the attribute info */
  snprintf(buf,sizeof(buf),"<attributes>");
  if ((rc = write_buffer(buf,strlen(buf),fds)))
    return(rc);

  if ((ds = get_dynamic_string(-1, NULL)) == NULL)
    {
    log_err(ENOMEM, id, "");
    return(ENOMEM);
    }

  i = 0;
  while (i != SRV_ATR_LAST)
    {
    if (ps->sv_attr[i].at_flags & ATR_VFLAG_SET)
      {
      buf[0] = '\0';
      clear_dynamic_string(ds);

      if ((rc = attr_to_str(ds, svr_attr_def + i, ps->sv_attr[i], TRUE) != 0))
        {
        if (rc != NO_ATTR_DATA)
          {
          /* ERROR */
          snprintf(log_buffer,sizeof(log_buffer),
            "Not enough space to print attribute %s",
            svr_attr_def[i].at_name);
          log_err(-1,id,log_buffer);

          free_dynamic_string(ds);
          return(rc);
          }
        }
      else
        {
        snprintf(buf,sizeof(buf),"<%s>%s</%s>\n",
          svr_attr_def[i].at_name,
          ds->str,
          svr_attr_def[i].at_name);
        
        if (buf[0] != '\0')
          {
          if ((rc = write_buffer(buf,strlen(buf),fds)))
            {
            free_dynamic_string(ds);
            return(rc);
            }
          }
        }      
      }

    i++;
    }

  free_dynamic_string(ds);
  
  snprintf(buf,sizeof(buf),"</attributes>\n");
  if ((rc = write_buffer(buf,strlen(buf),fds)))
    return(rc);

  /* close the server_db */
  snprintf(buf,sizeof(buf),"</server_db>");
  if ((rc = write_buffer(buf,strlen(buf),fds)))
    return(rc);

  close(fds);

  return(0);

  } /* END svr_save_xml */
Esempio n. 4
0
int save_attr_xml(

  struct attribute_def *padef,   /* pbs_attribute definition array */
  pbs_attribute        *pattr,   /* ptr to pbs_attribute value array */
  int                   numattr, /* number of attributes in array */
  int                   fds)     /* file descriptor where attributes are written */

  {
  int             i;
  int             rc;
  char            buf[MAXLINE<<8];
  char            log_buf[LOCAL_LOG_BUF_SIZE];
  dynamic_string *ds = get_dynamic_string(-1, NULL);

  /* write the opening tag for attributes */
  snprintf(buf,sizeof(buf),"<attributes>\n");
  if ((rc = write_buffer(buf,strlen(buf),fds)) != 0)
    return(rc);

  for (i = 0; i < numattr; i++)
    {
    if (pattr[i].at_flags & ATR_VFLAG_SET)
      {
      buf[0] = '\0';
      clear_dynamic_string(ds);

      if ((rc = attr_to_str(ds, padef+i, pattr[i], TRUE)) != 0)
        {
        if (rc != NO_ATTR_DATA)
          {
          /* ERROR */
          snprintf(log_buf,sizeof(log_buf),
              "Not enough space to print pbs_attribute %s",
              padef[i].at_name);

          free_dynamic_string(ds);
          return(rc);
          }
        }
      else
        {
        snprintf(buf,sizeof(buf),"<%s>%s</%s>\n",
            padef[i].at_name,
            ds->str,
            padef[i].at_name);

        if ((rc = write_buffer(buf,strlen(buf),fds)) != 0)
          {
          free_dynamic_string(ds);
          return(rc);
          }
        }
      }
    } /* END for each pbs_attribute */

  free_dynamic_string(ds);

  /* close the attributes */
  snprintf(buf,sizeof(buf),"</attributes>\n");
  rc = write_buffer(buf,strlen(buf),fds);

  /* we can just return this since its the last write */
  return(rc);
  } /* END save_attr_xml() */