static char * _dump_node(struct node_record *node_ptr, time_t update_time) { char tmp[1024], *buf = NULL; int i; if (!node_ptr) return NULL; snprintf(tmp, sizeof(tmp), "%s:STATE=%s;", node_ptr->name, _get_node_state(node_ptr)); xstrcat(buf, tmp); if (node_ptr->arch) { snprintf(tmp, sizeof(tmp), "ARCH=%s;", node_ptr->arch); xstrcat(buf, tmp); } if (node_ptr->os) { snprintf(tmp, sizeof(tmp), "OS=%s;", node_ptr->os); xstrcat(buf, tmp); } if (node_ptr->config_ptr && node_ptr->config_ptr->feature) { snprintf(tmp, sizeof(tmp), "FEATURES=%s;", node_ptr->config_ptr->feature); /* comma separated to colon */ for (i=0; (tmp[i] != '\0'); i++) { if ((tmp[i] == ',') || (tmp[i] == '|')) tmp[i] = ':'; } xstrcat(buf, tmp); } if (update_time > 0) return buf; if (slurmctld_conf.fast_schedule && node_ptr->config_ptr) { /* config from slurm.conf */ snprintf(tmp, sizeof(tmp), "CMEMORY=%u;CDISK=%u;CPROC=%u;", node_ptr->config_ptr->real_memory, node_ptr->config_ptr->tmp_disk, node_ptr->config_ptr->cpus); } else { /* config as reported by slurmd */ snprintf(tmp, sizeof(tmp), "CMEMORY=%u;CDISK=%u;CPROC=%u;", node_ptr->real_memory, node_ptr->tmp_disk, node_ptr->cpus); } xstrcat(buf, tmp); return buf; }
static char * _dump_node(struct node_record *node_ptr, hostlist_t hl, time_t update_time) { char tmp[16*1024], *buf = NULL; int i; uint32_t cpu_cnt; if (!node_ptr) return NULL; if (hl) { char *node_list; hostlist_sort(hl); hostlist_uniq(hl); node_list = hostlist_ranged_string_xmalloc(hl); xstrcat(buf, node_list); xfree(node_list); } else { snprintf(tmp, sizeof(tmp), "%s", node_ptr->name); xstrcat(buf, tmp); } snprintf(tmp, sizeof(tmp), ":STATE=%s;", _get_node_state(node_ptr)); xstrcat(buf, tmp); if (node_ptr->cpu_load != NO_VAL) { snprintf(tmp, sizeof(tmp), "CPULOAD=%f;", (node_ptr->cpu_load / 100.0)); xstrcat(buf, tmp); } if (node_ptr->reason) { /* Strip out any quotes, they confuse Moab */ char *reason, *bad_char; reason = xstrdup(node_ptr->reason); while ((bad_char = strchr(reason, '\''))) bad_char[0] = ' '; while ((bad_char = strchr(reason, '\"'))) bad_char[0] = ' '; snprintf(tmp, sizeof(tmp), "CAT=\"%s\";", reason); xstrcat(buf, tmp); xfree(reason); } if (update_time > last_node_update) return buf; if (slurmctld_conf.fast_schedule) { /* config from slurm.conf */ cpu_cnt = node_ptr->config_ptr->cpus; } else { /* config as reported by slurmd */ cpu_cnt = node_ptr->cpus; } for (i=0; i<node_ptr->part_cnt; i++) { if (i == 0) xstrcat(buf, "CCLASS="); snprintf(tmp, sizeof(tmp), "[%s:%u]", node_ptr->part_pptr[i]->name, cpu_cnt); xstrcat(buf, tmp); } if (i > 0) xstrcat(buf, ";"); if (node_ptr->arch) { snprintf(tmp, sizeof(tmp), "ARCH=%s;", node_ptr->arch); xstrcat(buf, tmp); } if (node_ptr->os) { snprintf(tmp, sizeof(tmp), "OS=%s;", node_ptr->os); xstrcat(buf, tmp); } if (node_ptr->config_ptr && node_ptr->config_ptr->feature) { snprintf(tmp, sizeof(tmp), "FEATURE=%s;", node_ptr->config_ptr->feature); /* comma separator to colon */ for (i=0; (tmp[i] != '\0'); i++) { if (tmp[i] == ',') tmp[i] = ':'; } xstrcat(buf, tmp); } if (node_ptr->config_ptr && node_ptr->config_ptr->gres) { snprintf(tmp, sizeof(tmp), "GRES=%s;", node_ptr->config_ptr->gres); xstrcat(buf, tmp); } if (update_time > 0) return buf; if (slurmctld_conf.fast_schedule) { /* config from slurm.conf */ snprintf(tmp, sizeof(tmp), "CMEMORY=%u;CDISK=%u;CPROC=%u;", node_ptr->config_ptr->real_memory, node_ptr->config_ptr->tmp_disk, node_ptr->config_ptr->cpus); } else { /* config as reported by slurmd */ snprintf(tmp, sizeof(tmp), "CMEMORY=%u;CDISK=%u;CPROC=%u;", node_ptr->real_memory, node_ptr->tmp_disk, node_ptr->cpus); } xstrcat(buf, tmp); return buf; }