1 /*****************************************************************************\
2 * job_submit_cray_aries.c - Infrastructure for native Slurm operation on
3 * Cray/Aries computers
4 *****************************************************************************
5 * Copyright (C) 2013 SchedMD LLC.
6 * Copyright (C) 2014 Cray Inc. All Rights Reserved.
7 * Written by Morris Jette <jette@schedmd.com>
8 *
9 * This file is part of Slurm, a resource management program.
10 * For details, see <https://slurm.schedmd.com/>.
11 * Please also read the included file: DISCLAIMER.
12 *
13 * Slurm is free software; you can redistribute it and/or modify it under
14 * the terms of the GNU General Public License as published by the Free
15 * Software Foundation; either version 2 of the License, or (at your option)
16 * any later version.
17 *
18 * In addition, as a special exception, the copyright holders give permission
19 * to link the code of portions of this program with the OpenSSL library under
20 * certain conditions as described in each individual source file, and
21 * distribute linked combinations including the two. You must obey the GNU
22 * General Public License in all respects for all of the code used other than
23 * OpenSSL. If you modify file(s) with this exception, you may extend this
24 * exception to your version of the file(s), but you are not obligated to do
25 * so. If you do not wish to do so, delete this exception statement from your
26 * version. If you delete this exception statement from all source files in
27 * the program, then also delete it here.
28 *
29 * Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
30 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
31 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
32 * details.
33 *
34 * You should have received a copy of the GNU General Public License along
35 * with Slurm; if not, write to the Free Software Foundation, Inc.,
36 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
37 \*****************************************************************************/
38
39 #include <inttypes.h>
40 #include <stdio.h>
41 #include <string.h>
42 #include <sys/types.h>
43 #include <unistd.h>
44
45 #include "slurm/slurm_errno.h"
46 #include "src/common/slurm_xlator.h"
47 #include "src/slurmctld/slurmctld.h"
48
49 #define _DEBUG 0
50
51 /*
52 * These variables are required by the generic plugin interface. If they
53 * are not found in the plugin, the plugin loader will ignore it.
54 *
55 * plugin_name - a string giving a human-readable description of the
56 * plugin. There is no maximum length, but the symbol must refer to
57 * a valid string.
58 *
59 * plugin_type - a string suggesting the type of the plugin or its
60 * applicability to a particular form of data or method of data handling.
61 * If the low-level plugin API is used, the contents of this string are
62 * unimportant and may be anything. Slurm uses the higher-level plugin
63 * interface which requires this string to be of the form
64 *
65 * <application>/<method>
66 *
67 * where <application> is a description of the intended application of
68 * the plugin (e.g., "auth" for Slurm authentication) and <method> is a
69 * description of how this plugin satisfies that application. Slurm will
70 * only load authentication plugins if the plugin_type string has a prefix
71 * of "auth/".
72 *
73 * plugin_version - an unsigned 32-bit integer containing the Slurm version
74 * (major.minor.micro combined into a single number).
75 */
76 const char plugin_name[] = "Job submit Cray/Aries plugin";
77 const char plugin_type[] = "job_submit/cray_aries";
78 const uint32_t plugin_version = SLURM_VERSION_NUMBER;
79
80 #define CRAY_GRES "craynetwork"
81 #define CRAY_GRES_POSTFIX CRAY_GRES":1"
82
83 /*
84 * Append CRAY_GRES_POSTFIX to the gres provided by the user
85 */
_append_gres(job_desc_msg_t * job_desc)86 static void _append_gres(job_desc_msg_t *job_desc)
87 {
88 if (job_desc->tres_per_node == NULL) {
89 job_desc->tres_per_node = xstrdup(CRAY_GRES_POSTFIX);
90 } else if (strlen(job_desc->tres_per_node) == 0) {
91 xstrcat(job_desc->tres_per_node, CRAY_GRES_POSTFIX);
92 } else if (strstr(job_desc->tres_per_node, CRAY_GRES) == NULL) {
93 // Don't append if they already specified craynetwork
94 // Allows the user to ask for more or less than the default
95 xstrcat(job_desc->tres_per_node, "," CRAY_GRES_POSTFIX);
96 }
97 }
98
init(void)99 int init (void)
100 {
101 return SLURM_SUCCESS;
102 }
103
fini(void)104 int fini (void)
105 {
106 return SLURM_SUCCESS;
107 }
108
job_submit(job_desc_msg_t * job_desc,uint32_t submit_uid)109 extern int job_submit(job_desc_msg_t *job_desc, uint32_t submit_uid)
110 {
111 _append_gres(job_desc);
112 return SLURM_SUCCESS;
113 }
114
job_modify(job_desc_msg_t * job_desc,job_record_t * job_ptr,uint32_t submit_uid)115 extern int job_modify(job_desc_msg_t *job_desc, job_record_t *job_ptr,
116 uint32_t submit_uid)
117 {
118 /* Don't call this on modify it shouldn't be needed and will
119 * mess things up if modifying a running job
120 */
121 //_append_gres(job_desc);
122 return SLURM_SUCCESS;
123 }
124