dynamic_string *get_reservation_command( resizable_array *host_req_list, char *username, char *jobid, char *apbasil_path, char *apbasil_protocol) { dynamic_string *command = get_dynamic_string(-1, NULL); dynamic_string *node_list = get_dynamic_string(-1, NULL); char buf[MAXLINE * 2]; unsigned int width = 0; unsigned int nppn = 0; int iter = -1; host_req *hr; /* place the top header */ snprintf(buf, sizeof(buf), APBASIL_RESERVE_REQ, (apbasil_protocol != NULL) ? apbasil_protocol : DEFAULT_APBASIL_PROTOCOL); append_dynamic_string(command, buf); /* place the reserve header */ snprintf(buf, sizeof(buf), APBASIL_RESERVE_ARRAY, username, jobid); append_dynamic_string(command, buf); while ((hr = (host_req *)next_thing(host_req_list, &iter)) != NULL) { width += hr->ppn; nppn = MAX(nppn,hr->ppn); if (node_list->used != 0) append_dynamic_string(node_list, ","); append_dynamic_string(node_list, hr->hostname); free_host_req(hr); } save_current_reserve_param(command, node_list, width, nppn); free_dynamic_string(node_list); /* pipe the output to apbasil */ snprintf(buf, sizeof(buf), "</ReserveParamArray></BasilRequest>\" | %s", (apbasil_path != NULL) ? apbasil_path : DEFAULT_APBASIL_PATH); append_dynamic_string(command, buf); return(command); } /* END get_reservation_command() */
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() */
int create_reserve_params_from_multi_req_list( char *multi_req_list, /* I */ char *apbasil_protocol, /* I */ int nppcu, /* I */ int mppdepth, /* I */ std::string& command, /* O */ std::string& cray_frequency) /* I */ { std::string node_list = ""; 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; node_list.clear(); 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, cray_frequency); } return(PBSE_NONE); } /* END create_reserve_params_from_multi_req_list() */
int create_reserve_params_from_host_req_list( resizable_array *host_req_list, /* I */ char *apbasil_protocol, /* I */ int use_nppn, /* I */ int nppcu, /* I */ int mppdepth, /* I */ dynamic_string *command) /* O */ { dynamic_string *node_list = get_dynamic_string(-1, NULL); host_req *hr; unsigned int nppn = 0; unsigned int width = 0; int iter = -1; while ((hr = (host_req *)next_thing(host_req_list, &iter)) != NULL) { width += hr->ppn; nppn = MAX((unsigned int)nppn, hr->ppn); if (node_list->used != 0) append_dynamic_string(node_list, ","); append_dynamic_string(node_list, hr->hostname); free_host_req(hr); } if (use_nppn == FALSE) nppn = -1; 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_host_req_list() */
int create_reserve_params_from_host_req_list( host_req_list *list, /* I */ char *apbasil_protocol, /* I */ int use_nppn, /* I */ int nppcu, /* I */ int mppdepth, /* I */ std::string& command, /* O */ std::string& cray_frequency) /* I */ { std::string node_list = ""; host_req *hr; unsigned int nppn = 0; unsigned int width = 0; for(host_req_list::iterator iter = list->begin();iter != list->end();iter++) { hr = *iter; width += hr->ppn; nppn = MAX((unsigned int)nppn, hr->ppn); if (node_list.length() != 0) node_list += ","; node_list += hr->hostname; free_host_req(hr); } if (use_nppn == FALSE) nppn = -1; adjust_for_depth(width, nppn, mppdepth); save_current_reserve_param(command, apbasil_protocol, node_list, width, nppn, nppcu, mppdepth, cray_frequency); return(PBSE_NONE); } /* END create_reserve_params_from_host_req_list() */