1 /*****************************************************************************\
2 * init_msg.c - initialize RPC messages contents
3 *****************************************************************************
4 * Copyright (C) 2002-2007 The Regents of the University of California.
5 * Copyright (C) 2008-2010 Lawrence Livermore National Security.
6 * Portions Copyright (C) 2010 SchedMD <https://www.schedmd.com>.
7 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
8 * Written by Morris Jette <jette1@llnl.gov>.
9 * CODE-OCEC-09-009. All rights reserved.
10 *
11 * This file is part of Slurm, a resource management program.
12 * For details, see <https://slurm.schedmd.com/>.
13 * Please also read the included file: DISCLAIMER.
14 *
15 * Slurm is free software; you can redistribute it and/or modify it under
16 * the terms of the GNU General Public License as published by the Free
17 * Software Foundation; either version 2 of the License, or (at your option)
18 * any later version.
19 *
20 * In addition, as a special exception, the copyright holders give permission
21 * to link the code of portions of this program with the OpenSSL library under
22 * certain conditions as described in each individual source file, and
23 * distribute linked combinations including the two. You must obey the GNU
24 * General Public License in all respects for all of the code used other than
25 * OpenSSL. If you modify file(s) with this exception, you may extend this
26 * exception to your version of the file(s), but you are not obligated to do
27 * so. If you do not wish to do so, delete this exception statement from your
28 * version. If you delete this exception statement from all source files in
29 * the program, then also delete it here.
30 *
31 * Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
32 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
33 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
34 * details.
35 *
36 * You should have received a copy of the GNU General Public License along
37 * with Slurm; if not, write to the Free Software Foundation, Inc.,
38 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
39 \*****************************************************************************/
40
41 #include <errno.h>
42 #include <stdio.h>
43
44 #include "slurm/slurm.h"
45
46 #include "src/common/slurm_protocol_api.h"
47 #include "src/common/forward.h"
48
49 /*
50 * slurm_init_job_desc_msg - initialize job descriptor with
51 * default values
52 * IN/OUT job_desc_msg - user defined job descriptor
53 */
slurm_init_job_desc_msg(job_desc_msg_t * job_desc_msg)54 void slurm_init_job_desc_msg(job_desc_msg_t * job_desc_msg)
55 {
56 memset(job_desc_msg, 0, sizeof(job_desc_msg_t));
57 job_desc_msg->alloc_sid = NO_VAL;
58 job_desc_msg->contiguous = NO_VAL16;
59 job_desc_msg->core_spec = NO_VAL16;
60 job_desc_msg->cores_per_socket = NO_VAL16;
61 job_desc_msg->cpu_bind_type = NO_VAL16;
62 job_desc_msg->cpu_freq_min = NO_VAL;
63 job_desc_msg->cpu_freq_max = NO_VAL;
64 job_desc_msg->cpu_freq_gov = NO_VAL;
65 job_desc_msg->cpus_per_task = NO_VAL16;
66 job_desc_msg->delay_boot = NO_VAL;
67 job_desc_msg->group_id = NO_VAL;
68 job_desc_msg->job_id = NO_VAL;
69 job_desc_msg->kill_on_node_fail = NO_VAL16;
70 job_desc_msg->max_cpus = NO_VAL;
71 job_desc_msg->max_nodes = NO_VAL;
72 job_desc_msg->mem_bind_type = NO_VAL16;
73 job_desc_msg->mail_type = NO_VAL16;
74 job_desc_msg->min_cpus = NO_VAL;
75 job_desc_msg->min_nodes = NO_VAL;
76 job_desc_msg->nice = NO_VAL;
77 job_desc_msg->ntasks_per_core = NO_VAL16;
78 job_desc_msg->ntasks_per_node = NO_VAL16;
79 job_desc_msg->ntasks_per_socket = NO_VAL16;
80 job_desc_msg->num_tasks = NO_VAL;
81 job_desc_msg->overcommit = NO_VAL8;
82 job_desc_msg->plane_size = NO_VAL16;
83 job_desc_msg->pn_min_cpus = NO_VAL16;
84 job_desc_msg->pn_min_memory = NO_VAL64;
85 job_desc_msg->pn_min_tmp_disk = NO_VAL;
86 job_desc_msg->priority = NO_VAL;
87 job_desc_msg->reboot = NO_VAL16;
88 job_desc_msg->requeue = NO_VAL16;
89 job_desc_msg->req_switch = NO_VAL;
90 job_desc_msg->shared = NO_VAL16;
91 job_desc_msg->site_factor = NO_VAL;
92 job_desc_msg->sockets_per_node = NO_VAL16;
93 job_desc_msg->task_dist = NO_VAL;
94 job_desc_msg->threads_per_core = NO_VAL16;
95 job_desc_msg->time_limit = NO_VAL;
96 job_desc_msg->time_min = NO_VAL;
97 job_desc_msg->user_id = NO_VAL;
98 job_desc_msg->wait_all_nodes = NO_VAL16;
99 job_desc_msg->wait4switch = NO_VAL;
100 }
101
102 /*
103 * slurm_init_update_step_msg - initialize step update message with default
104 * values before calling slurm_update_step()
105 * OUT step_msg - step update messasge descriptor
106 */
slurm_init_update_step_msg(step_update_request_msg_t * step_msg)107 extern void slurm_init_update_step_msg (step_update_request_msg_t * step_msg)
108 {
109 memset(step_msg, 0, sizeof(step_update_request_msg_t));
110 step_msg->job_id = NO_VAL;
111 step_msg->step_id = NO_VAL;
112 step_msg->time_limit = NO_VAL;
113 }
114
115 /*
116 * slurm_init_part_desc_msg - initialize partition descriptor with
117 * default values
118 * IN/OUT update_part_msg - user defined partition descriptor
119 */
slurm_init_part_desc_msg(update_part_msg_t * update_part_msg)120 void slurm_init_part_desc_msg (update_part_msg_t * update_part_msg)
121 {
122 memset(update_part_msg, 0, sizeof(update_part_msg_t));
123 update_part_msg->default_time = NO_VAL;
124 update_part_msg->def_mem_per_cpu = NO_VAL64;
125 update_part_msg->grace_time = NO_VAL;
126 update_part_msg->max_cpus_per_node = NO_VAL;
127 update_part_msg->max_mem_per_cpu = NO_VAL64;
128 update_part_msg->max_nodes = NO_VAL;
129 update_part_msg->max_share = NO_VAL16;
130 update_part_msg->min_nodes = NO_VAL;
131 update_part_msg->max_time = NO_VAL;
132 update_part_msg->over_time_limit = NO_VAL16;
133 update_part_msg->preempt_mode = NO_VAL16;
134 update_part_msg->priority_job_factor = NO_VAL16;
135 update_part_msg->priority_tier = NO_VAL16;
136 update_part_msg->state_up = NO_VAL16;
137 }
138
139 /*
140 * slurm_init_resv_desc_msg - initialize reservation descriptor with
141 * default values
142 * OUT job_desc_msg - user defined partition descriptor
143 */
slurm_init_resv_desc_msg(resv_desc_msg_t * resv_msg)144 void slurm_init_resv_desc_msg (resv_desc_msg_t * resv_msg)
145 {
146 memset(resv_msg, 0, sizeof(resv_desc_msg_t));
147 resv_msg->duration = NO_VAL;
148 resv_msg->end_time = (time_t) NO_VAL;
149 resv_msg->flags = NO_VAL64;
150 resv_msg->max_start_delay = NO_VAL;
151 resv_msg->purge_comp_time = NO_VAL;
152 resv_msg->start_time = (time_t) NO_VAL;
153 resv_msg->resv_watts = NO_VAL;
154 }
155
156 /*
157 * slurm_init_update_node_msg - initialize node update message
158 * OUT update_node_msg - user defined node descriptor
159 */
slurm_init_update_node_msg(update_node_msg_t * update_node_msg)160 void slurm_init_update_node_msg (update_node_msg_t * update_node_msg)
161 {
162 memset(update_node_msg, 0, sizeof(update_node_msg_t));
163 update_node_msg->node_state = NO_VAL;
164 update_node_msg->weight = NO_VAL;
165 }
166
167 /*
168 * slurm_init_update_front_end_msg - initialize front_end node update message
169 * OUT update_front_end_msg - user defined node descriptor
170 */
slurm_init_update_front_end_msg(update_front_end_msg_t * update_front_end_msg)171 void slurm_init_update_front_end_msg (update_front_end_msg_t *
172 update_front_end_msg)
173 {
174 memset(update_front_end_msg, 0, sizeof(update_front_end_msg_t));
175 update_front_end_msg->node_state = NO_VAL;
176 }
177
178 /*
179 * slurm_init_trigger_msg - initialize trigger clear/update message
180 * OUT trigger_info_msg - user defined trigger descriptor
181 */
slurm_init_trigger_msg(trigger_info_t * trigger_info_msg)182 void slurm_init_trigger_msg (trigger_info_t *trigger_info_msg)
183 {
184 memset(trigger_info_msg, 0, sizeof(trigger_info_t));
185 trigger_info_msg->user_id = NO_VAL;
186 }
187