/* * convert job_step_create_response_msg_t to perl HV */ int job_step_create_response_msg_to_hv(job_step_create_response_msg_t *resp_msg, HV *hv) { HV *hv; STORE_FIELD(hv, resp_msg, job_step_id, uint32_t); if (resp_msg->resv_ports) STORE_FIELD(hv, resp_msg, resv_ports, charp); hv = newHV(); if (slurm_step_layout_to_hv(resp->step_layout, hv) < 0) { Perl_warn(aTHX_ "Failed to convert slurm_step_layout_t to hv for job_step_create_response_msg_t"); SvREFCNT_dec(hv); return -1; } hv_store(hv, "step_layout", 11, newRV_noinc((SV*)hv)); STORE_PTR_FIELD(hv, resp_msg, cred, "TODO"); STORE_PTR_FIELD(hv, resp_msg, switch_job, "TODO"); return 0; }
/* * convert job_step_stat_t to perl HV */ int job_step_stat_to_hv(job_step_stat_t *stat, HV *hv) { HV *hv_pids; STORE_PTR_FIELD(hv, stat, jobacct, "Slurm::jobacctinfo_t"); STORE_FIELD(hv, stat, num_tasks, uint32_t); STORE_FIELD(hv, stat, return_code, uint32_t); hv_pids = newHV(); if (job_step_pids_to_hv(stat->step_pids, hv_pids) < 0) { Perl_warn(aTHX_ "failed to convert job_step_pids_t to hv for job_step_stat_t"); SvREFCNT_dec(hv_pids); return -1; } hv_store_sv(hv, "step_pids", newRV_noinc((SV*)hv_pids)); return 0; }
/* * convert node_info_t to perl HV */ int node_info_to_hv(node_info_t *node_info, uint16_t node_scaling, HV *hv) { uint16_t err_cpus = 0, alloc_cpus = 0; #ifdef HAVE_BG int cpus_per_node = 1; if(node_scaling) cpus_per_node = node_info->cpus / node_scaling; #endif if(node_info->arch) STORE_FIELD(hv, node_info, arch, charp); STORE_FIELD(hv, node_info, boot_time, time_t); STORE_FIELD(hv, node_info, cores, uint16_t); STORE_FIELD(hv, node_info, cpu_load, uint32_t); STORE_FIELD(hv, node_info, cpus, uint16_t); if (node_info->features) STORE_FIELD(hv, node_info, features, charp); if (node_info->features_act) STORE_FIELD(hv, node_info, features_act, charp); if (node_info->gres) STORE_FIELD(hv, node_info, gres, charp); if (node_info->name) STORE_FIELD(hv, node_info, name, charp); else { Perl_warn (aTHX_ "node name missing in node_info_t"); return -1; } STORE_FIELD(hv, node_info, node_state, uint32_t); if(node_info->os) STORE_FIELD(hv, node_info, os, charp); STORE_FIELD(hv, node_info, real_memory, uint64_t); if(node_info->reason) STORE_FIELD(hv, node_info, reason, charp); STORE_FIELD(hv, node_info, reason_time, time_t); STORE_FIELD(hv, node_info, reason_uid, uint32_t); STORE_FIELD(hv, node_info, slurmd_start_time, time_t); STORE_FIELD(hv, node_info, boards, uint16_t); STORE_FIELD(hv, node_info, sockets, uint16_t); STORE_FIELD(hv, node_info, threads, uint16_t); STORE_FIELD(hv, node_info, tmp_disk, uint32_t); slurm_get_select_nodeinfo(node_info->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ALLOCATED, &alloc_cpus); #ifdef HAVE_BG if(!alloc_cpus && (IS_NODE_ALLOCATED(node_info) || IS_NODE_COMPLETING(node_info))) alloc_cpus = node_info->cpus; else alloc_cpus *= cpus_per_node; #endif slurm_get_select_nodeinfo(node_info->select_nodeinfo, SELECT_NODEDATA_SUBCNT, NODE_STATE_ERROR, &err_cpus); #ifdef HAVE_BG err_cpus *= cpus_per_node; #endif hv_store_uint16_t(hv, "alloc_cpus", alloc_cpus); hv_store_uint16_t(hv, "err_cpus", err_cpus); STORE_PTR_FIELD(hv, node_info, select_nodeinfo, "Slurm::dynamic_plugin_data_t"); STORE_FIELD(hv, node_info, weight, uint32_t); return 0; }
/* * convert slurm_ctl_conf_t into perl HV */ int slurm_ctl_conf_to_hv(slurm_ctl_conf_t *conf, HV *hv) { STORE_FIELD(hv, conf, last_update, time_t); if(conf->acct_gather_profile_type) STORE_FIELD(hv, conf, acct_gather_profile_type, charp); if(conf->acct_gather_infiniband_type) STORE_FIELD(hv, conf, acct_gather_infiniband_type, charp); if(conf->acct_gather_filesystem_type) STORE_FIELD(hv, conf, acct_gather_filesystem_type, charp); STORE_FIELD(hv, conf, accounting_storage_enforce, uint16_t); if(conf->accounting_storage_backup_host) STORE_FIELD(hv, conf, accounting_storage_backup_host, charp); if(conf->accounting_storage_host) STORE_FIELD(hv, conf, accounting_storage_host, charp); if(conf->accounting_storage_loc) STORE_FIELD(hv, conf, accounting_storage_loc, charp); /* accounting_storage_pass */ STORE_FIELD(hv, conf, accounting_storage_port, uint32_t); if(conf->accounting_storage_type) STORE_FIELD(hv, conf, accounting_storage_type, charp); if(conf->accounting_storage_user) STORE_FIELD(hv, conf, accounting_storage_user, charp); if(conf->authinfo) STORE_FIELD(hv, conf, authinfo, charp); if(conf->authtype) STORE_FIELD(hv, conf, authtype, charp); if(conf->backup_addr) STORE_FIELD(hv, conf, backup_addr, charp); if(conf->backup_controller) STORE_FIELD(hv, conf, backup_controller, charp); STORE_FIELD(hv, conf, batch_start_timeout, uint16_t); STORE_FIELD(hv, conf, boot_time, time_t); if(conf->checkpoint_type) STORE_FIELD(hv, conf, checkpoint_type, charp); if(conf->cluster_name) STORE_FIELD(hv, conf, cluster_name, charp); STORE_FIELD(hv, conf, complete_wait, uint16_t); if(conf->control_addr) STORE_FIELD(hv, conf, control_addr, charp); if(conf->control_machine) STORE_FIELD(hv, conf, control_machine, charp); if(conf->crypto_type) STORE_FIELD(hv, conf, crypto_type, charp); STORE_FIELD(hv, conf, debug_flags, uint32_t); STORE_FIELD(hv, conf, def_mem_per_cpu, uint32_t); STORE_FIELD(hv, conf, disable_root_jobs, uint16_t); STORE_FIELD(hv, conf, dynalloc_port, uint16_t); STORE_FIELD(hv, conf, enforce_part_limits, uint16_t); if(conf->epilog) STORE_FIELD(hv, conf, epilog, charp); STORE_FIELD(hv, conf, epilog_msg_time, uint32_t); if(conf->epilog_slurmctld) STORE_FIELD(hv, conf, epilog_slurmctld, charp); if(conf->ext_sensors_type) STORE_FIELD(hv, conf, ext_sensors_type, charp); STORE_FIELD(hv, conf, ext_sensors_freq, uint16_t); STORE_FIELD(hv, conf, fast_schedule, uint16_t); STORE_FIELD(hv, conf, first_job_id, uint32_t); STORE_FIELD(hv, conf, get_env_timeout, uint16_t); if(conf->gres_plugins) STORE_FIELD(hv, conf, gres_plugins, charp); STORE_FIELD(hv, conf, group_info, uint16_t); STORE_FIELD(hv, conf, hash_val, uint32_t); STORE_FIELD(hv, conf, health_check_interval, uint16_t); STORE_FIELD(hv, conf, health_check_node_state, uint16_t); if(conf->health_check_program) STORE_FIELD(hv, conf, health_check_program, charp); STORE_FIELD(hv, conf, inactive_limit, uint16_t); if (conf->job_acct_gather_type) STORE_FIELD(hv, conf, job_acct_gather_freq, charp); if(conf->job_acct_gather_type) STORE_FIELD(hv, conf, job_acct_gather_type, charp); if(conf->job_ckpt_dir) STORE_FIELD(hv, conf, job_ckpt_dir, charp); if(conf->job_comp_host) STORE_FIELD(hv, conf, job_comp_host, charp); if(conf->job_comp_loc) STORE_FIELD(hv, conf, job_comp_loc, charp); /* job_comp_pass */ STORE_FIELD(hv, conf, job_comp_port, uint32_t); if(conf->job_comp_type) STORE_FIELD(hv, conf, job_comp_type, charp); if(conf->job_comp_user) STORE_FIELD(hv, conf, job_comp_user, charp); if(conf->job_credential_private_key) STORE_FIELD(hv, conf, job_credential_private_key, charp); if(conf->job_credential_public_certificate) STORE_FIELD(hv, conf, job_credential_public_certificate, charp); STORE_FIELD(hv, conf, job_file_append, uint16_t); STORE_FIELD(hv, conf, job_requeue, uint16_t); if(conf->job_submit_plugins) STORE_FIELD(hv, conf, job_submit_plugins, charp); STORE_FIELD(hv, conf, keep_alive_time, uint16_t); STORE_FIELD(hv, conf, kill_on_bad_exit, uint16_t); STORE_FIELD(hv, conf, kill_wait, uint16_t); if(conf->licenses) STORE_FIELD(hv, conf, licenses, charp); if(conf->mail_prog) STORE_FIELD(hv, conf, mail_prog, charp); STORE_FIELD(hv, conf, max_array_sz, uint16_t); STORE_FIELD(hv, conf, max_job_cnt, uint16_t); STORE_FIELD(hv, conf, max_mem_per_cpu, uint32_t); STORE_FIELD(hv, conf, max_tasks_per_node, uint16_t); STORE_FIELD(hv, conf, min_job_age, uint16_t); if(conf->mpi_default) STORE_FIELD(hv, conf, mpi_default, charp); if(conf->mpi_params) STORE_FIELD(hv, conf, mpi_params, charp); STORE_FIELD(hv, conf, msg_timeout, uint16_t); STORE_FIELD(hv, conf, next_job_id, uint32_t); if(conf->node_prefix) STORE_FIELD(hv, conf, node_prefix, charp); STORE_FIELD(hv, conf, over_time_limit, uint16_t); if(conf->plugindir) STORE_FIELD(hv, conf, plugindir, charp); if(conf->plugstack) STORE_FIELD(hv, conf, plugstack, charp); STORE_FIELD(hv, conf, preempt_mode, uint16_t); if(conf->preempt_type) STORE_FIELD(hv, conf, preempt_type, charp); STORE_FIELD(hv, conf, priority_decay_hl, uint32_t); STORE_FIELD(hv, conf, priority_favor_small, uint16_t); STORE_FIELD(hv, conf, priority_max_age, uint32_t); STORE_FIELD(hv, conf, priority_reset_period, uint16_t); if(conf->priority_type) STORE_FIELD(hv, conf, priority_type, charp); STORE_FIELD(hv, conf, prolog_flags, uint16_t); STORE_FIELD(hv, conf, priority_weight_age, uint32_t); STORE_FIELD(hv, conf, priority_weight_fs, uint32_t); STORE_FIELD(hv, conf, priority_weight_js, uint32_t); STORE_FIELD(hv, conf, priority_weight_part, uint32_t); STORE_FIELD(hv, conf, priority_weight_qos, uint32_t); STORE_FIELD(hv, conf, private_data, uint16_t); if(conf->proctrack_type) STORE_FIELD(hv, conf, proctrack_type, charp); if(conf->prolog) STORE_FIELD(hv, conf, prolog, charp); if(conf->prolog_slurmctld) STORE_FIELD(hv, conf, prolog_slurmctld, charp); STORE_FIELD(hv, conf, propagate_prio_process, uint16_t); if(conf->propagate_rlimits) STORE_FIELD(hv, conf, propagate_rlimits, charp); if(conf->propagate_rlimits_except) STORE_FIELD(hv, conf, propagate_rlimits_except, charp); STORE_FIELD(hv, conf, reconfig_flags, uint16_t); if(conf->resume_program) STORE_FIELD(hv, conf, resume_program, charp); STORE_FIELD(hv, conf, resume_rate, uint16_t); STORE_FIELD(hv, conf, resume_timeout, uint16_t); if(conf->resv_epilog) STORE_FIELD(hv, conf, resv_epilog, charp); STORE_FIELD(hv, conf, resv_over_run, uint16_t); if(conf->resv_prolog) STORE_FIELD(hv, conf, resv_prolog, charp); STORE_FIELD(hv, conf, ret2service, uint16_t); if(conf->salloc_default_command) STORE_FIELD(hv, conf, salloc_default_command, charp); if(conf->sched_logfile) STORE_FIELD(hv, conf, sched_logfile, charp); STORE_FIELD(hv, conf, sched_log_level, uint16_t); if(conf->sched_params) STORE_FIELD(hv, conf, sched_params, charp); STORE_FIELD(hv, conf, sched_time_slice, uint16_t); if(conf->schedtype) STORE_FIELD(hv, conf, schedtype, charp); STORE_FIELD(hv, conf, schedport, uint16_t); STORE_FIELD(hv, conf, schedrootfltr, uint16_t); if(conf->select_type) STORE_FIELD(hv, conf, select_type, charp); STORE_PTR_FIELD(hv, conf, select_conf_key_pairs, "Slurm::List"); /* TODO: Think about memory management */ STORE_FIELD(hv, conf, select_type_param, uint16_t); if(conf->slurm_conf) STORE_FIELD(hv, conf, slurm_conf, charp); STORE_FIELD(hv, conf, slurm_user_id, uint32_t); if(conf->slurm_user_name) STORE_FIELD(hv, conf, slurm_user_name, charp); STORE_FIELD(hv, conf, slurmd_user_id, uint32_t); if(conf->slurmd_user_name) STORE_FIELD(hv, conf, slurmd_user_name, charp); STORE_FIELD(hv, conf, slurmctld_debug, uint16_t); if(conf->slurmctld_logfile) STORE_FIELD(hv, conf, slurmctld_logfile, charp); if(conf->slurmctld_pidfile) STORE_FIELD(hv, conf, slurmctld_pidfile, charp); if(conf->slurmctld_plugstack) STORE_FIELD(hv, conf, slurmctld_plugstack, charp); STORE_FIELD(hv, conf, slurmctld_port, uint32_t); STORE_FIELD(hv, conf, slurmctld_port_count, uint16_t); STORE_FIELD(hv, conf, slurmctld_timeout, uint16_t); STORE_FIELD(hv, conf, slurmd_debug, uint16_t); if(conf->slurmd_logfile) STORE_FIELD(hv, conf, slurmd_logfile, charp); if(conf->slurmd_pidfile) STORE_FIELD(hv, conf, slurmd_pidfile, charp); STORE_FIELD(hv, conf, slurmd_port, uint32_t); if(conf->slurmd_spooldir) STORE_FIELD(hv, conf, slurmd_spooldir, charp); STORE_FIELD(hv, conf, slurmd_timeout, uint16_t); if(conf->srun_epilog) STORE_FIELD(hv, conf, srun_epilog, charp); if(conf->srun_prolog) STORE_FIELD(hv, conf, srun_prolog, charp); if(conf->state_save_location) STORE_FIELD(hv, conf, state_save_location, charp); if(conf->suspend_exc_nodes) STORE_FIELD(hv, conf, suspend_exc_nodes, charp); if(conf->suspend_exc_parts) STORE_FIELD(hv, conf, suspend_exc_parts, charp); if(conf->suspend_program) STORE_FIELD(hv, conf, suspend_program, charp); STORE_FIELD(hv, conf, suspend_rate, uint16_t); STORE_FIELD(hv, conf, suspend_time, uint32_t); STORE_FIELD(hv, conf, suspend_timeout, uint16_t); if(conf->switch_type) STORE_FIELD(hv, conf, switch_type, charp); if(conf->task_epilog) STORE_FIELD(hv, conf, task_epilog, charp); if(conf->task_plugin) STORE_FIELD(hv, conf, task_plugin, charp); STORE_FIELD(hv, conf, task_plugin_param, uint16_t); if(conf->task_prolog) STORE_FIELD(hv, conf, task_prolog, charp); if(conf->tmp_fs) STORE_FIELD(hv, conf, tmp_fs, charp); if(conf->topology_plugin) STORE_FIELD(hv, conf, topology_plugin, charp); STORE_FIELD(hv, conf, track_wckey, uint16_t); STORE_FIELD(hv, conf, tree_width, uint16_t); if(conf->unkillable_program) STORE_FIELD(hv, conf, unkillable_program, charp); STORE_FIELD(hv, conf, unkillable_timeout, uint16_t); STORE_FIELD(hv, conf, use_pam, uint16_t); if(conf->version) STORE_FIELD(hv, conf, version, charp); STORE_FIELD(hv, conf, vsize_factor, uint16_t); STORE_FIELD(hv, conf, wait_time, uint16_t); return 0; }
/* * convert job_info_t to perl HV */ int job_info_to_hv(job_info_t *job_info, HV *hv) { int j; AV *av; if(job_info->account) STORE_FIELD(hv, job_info, account, charp); if(job_info->alloc_node) STORE_FIELD(hv, job_info, alloc_node, charp); STORE_FIELD(hv, job_info, alloc_sid, uint32_t); STORE_FIELD(hv, job_info, assoc_id, uint32_t); STORE_FIELD(hv, job_info, batch_flag, uint16_t); if(job_info->command) STORE_FIELD(hv, job_info, command, charp); if(job_info->comment) STORE_FIELD(hv, job_info, comment, charp); STORE_FIELD(hv, job_info, contiguous, uint16_t); STORE_FIELD(hv, job_info, cpus_per_task, uint16_t); if(job_info->dependency) STORE_FIELD(hv, job_info, dependency, charp); STORE_FIELD(hv, job_info, derived_ec, uint32_t); STORE_FIELD(hv, job_info, eligible_time, time_t); STORE_FIELD(hv, job_info, end_time, time_t); if(job_info->exc_nodes) STORE_FIELD(hv, job_info, exc_nodes, charp); av = newAV(); for(j = 0; ; j += 2) { if(job_info->exc_node_inx[j] == -1) break; av_store(av, j, newSVuv(job_info->exc_node_inx[j])); av_store(av, j+1, newSVuv(job_info->exc_node_inx[j+1])); } hv_store_sv(hv, "exc_node_inx", newRV_noinc((SV*)av)); STORE_FIELD(hv, job_info, exit_code, uint32_t); if(job_info->features) STORE_FIELD(hv, job_info, features, charp); if(job_info->gres) STORE_FIELD(hv, job_info, gres, charp); STORE_FIELD(hv, job_info, group_id, uint32_t); STORE_FIELD(hv, job_info, job_id, uint32_t); STORE_FIELD(hv, job_info, job_state, uint16_t); if(job_info->licenses) STORE_FIELD(hv, job_info, licenses, charp); STORE_FIELD(hv, job_info, max_cpus, uint32_t); STORE_FIELD(hv, job_info, max_nodes, uint32_t); STORE_FIELD(hv, job_info, sockets_per_node, uint16_t); STORE_FIELD(hv, job_info, cores_per_socket, uint16_t); STORE_FIELD(hv, job_info, threads_per_core, uint16_t); if(job_info->name) STORE_FIELD(hv, job_info, name, charp); if(job_info->network) STORE_FIELD(hv, job_info, network, charp); STORE_FIELD(hv, job_info, nice, uint16_t); if(job_info->nodes) STORE_FIELD(hv, job_info, nodes, charp); av = newAV(); for(j = 0; ; j += 2) { if(job_info->node_inx[j] == -1) break; av_store(av, j, newSVuv(job_info->node_inx[j])); av_store(av, j+1, newSVuv(job_info->node_inx[j+1])); } hv_store_sv(hv, "node_inx", newRV_noinc((SV*)av)); STORE_FIELD(hv, job_info, ntasks_per_core, uint16_t); STORE_FIELD(hv, job_info, ntasks_per_node, uint16_t); STORE_FIELD(hv, job_info, ntasks_per_socket, uint16_t); #ifdef HAVE_BG slurm_get_select_jobinfo(job_info->select_jobinfo, SELECT_JOBDATA_NODE_CNT, &job_info->num_nodes); #endif STORE_FIELD(hv, job_info, num_nodes, uint32_t); STORE_FIELD(hv, job_info, num_cpus, uint32_t); STORE_FIELD(hv, job_info, pn_min_memory, uint32_t); STORE_FIELD(hv, job_info, pn_min_cpus, uint16_t); STORE_FIELD(hv, job_info, pn_min_tmp_disk, uint32_t); if(job_info->partition) STORE_FIELD(hv, job_info, partition, charp); STORE_FIELD(hv, job_info, pre_sus_time, time_t); STORE_FIELD(hv, job_info, priority, uint32_t); if(job_info->qos) STORE_FIELD(hv, job_info, qos, charp); if(job_info->req_nodes) STORE_FIELD(hv, job_info, req_nodes, charp); av = newAV(); for(j = 0; ; j += 2) { if(job_info->req_node_inx[j] == -1) break; av_store(av, j, newSVuv(job_info->req_node_inx[j])); av_store(av, j+1, newSVuv(job_info->req_node_inx[j+1])); } hv_store_sv(hv, "req_node_inx", newRV_noinc((SV*)av)); STORE_FIELD(hv, job_info, req_switch, uint32_t); STORE_FIELD(hv, job_info, requeue, uint16_t); STORE_FIELD(hv, job_info, resize_time, time_t); STORE_FIELD(hv, job_info, restart_cnt, uint16_t); if(job_info->resv_name) STORE_FIELD(hv, job_info, resv_name, charp); STORE_PTR_FIELD(hv, job_info, select_jobinfo, "Slurm::dynamic_plugin_data_t"); STORE_PTR_FIELD(hv, job_info, job_resrcs, "Slurm::job_resources_t"); STORE_FIELD(hv, job_info, shared, uint16_t); STORE_FIELD(hv, job_info, show_flags, uint16_t); STORE_FIELD(hv, job_info, start_time, time_t); if(job_info->state_desc) STORE_FIELD(hv, job_info, state_desc, charp); STORE_FIELD(hv, job_info, state_reason, uint16_t); STORE_FIELD(hv, job_info, submit_time, time_t); STORE_FIELD(hv, job_info, suspend_time, time_t); STORE_FIELD(hv, job_info, time_limit, uint32_t); STORE_FIELD(hv, job_info, time_min, uint32_t); STORE_FIELD(hv, job_info, user_id, uint32_t); STORE_FIELD(hv, job_info, wait4switch, uint32_t); if(job_info->wckey) STORE_FIELD(hv, job_info, wckey, charp); if(job_info->work_dir) STORE_FIELD(hv, job_info, work_dir, charp); return 0; }