~ubuntu-branches/ubuntu/vivid/slurm-llnl/vivid

« back to all changes in this revision

Viewing changes to src/api/update_config.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2009-09-24 23:28:15 UTC
  • mfrom: (1.1.11 upstream) (3.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090924232815-enh65jn32q1ebg07
Tags: 2.0.5-1
* New upstream release 
* Changed dependecy from lib-mysqlclient15 to lib-mysqlclient 
* Added Default-Start for runlevel 2 and 4 and $remote_fs requirement in
  init.d scripts (Closes: #541252)
* Postinst checks for wrong runlevels 2 and 4 links
* Upgraded to standard version 3.8.3
* Add lintian overrides for missing slurm-llnl-configurator.html in doc
  base registration
* modified postrm scripts to ignore pkill return value in order to avoid
  postrm failure when no slurm process is running
* Checking for slurmctld.pid before cancelling running and pending
  jobs during package removal 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************\
2
2
 *  update_config.c - request that slurmctld update its configuration
3
 
 *  $Id: update_config.c 13672 2008-03-19 23:10:58Z jette $
 
3
 *  $Id: update_config.c 17334 2009-04-22 23:49:13Z da $
4
4
 *****************************************************************************
5
 
 *  Copyright (C) 2002 The Regents of the University of California.
 
5
 *  Copyright (C) 2002-2007 The Regents of the University of California.
 
6
 *  Copyright (C) 2008-2009 Lawrence Livermore National Security.
6
7
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
7
8
 *  Written by Morris Jette <jette1@llnl.gov> and Kevin Tew <tew1@llnl.gov>.
8
 
 *  LLNL-CODE-402394.
 
9
 *  CODE-OCEC-09-009. All rights reserved.
9
10
 *  
10
11
 *  This file is part of SLURM, a resource management program.
11
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
12
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
13
 *  Please also read the included file: DISCLAIMER.
12
14
 *  
13
15
 *  SLURM is free software; you can redistribute it and/or modify it under
14
16
 *  the terms of the GNU General Public License as published by the Free
16
18
 *  any later version.
17
19
 *
18
20
 *  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 
 
21
 *  to link the code of portions of this program with the OpenSSL library under
20
22
 *  certain conditions as described in each individual source file, and 
21
23
 *  distribute linked combinations including the two. You must obey the GNU 
22
24
 *  General Public License in all respects for all of the code used other than 
43
45
#include <errno.h>
44
46
#include <stdio.h>
45
47
#include <stdlib.h>
 
48
#include <string.h>
46
49
 
47
50
#include <slurm/slurm.h>
48
51
 
75
78
}
76
79
 
77
80
/*
 
81
 * slurm_create_partition - create a new partition, only usable by user root
 
82
 * IN part_msg - description of partition configuration
 
83
 * RET 0 on success, otherwise return -1 and set errno to indicate the error
 
84
 */
 
85
int 
 
86
slurm_create_partition ( update_part_msg_t * part_msg ) 
 
87
{
 
88
        return _slurm_update ((void *) part_msg, REQUEST_CREATE_PARTITION);
 
89
}
 
90
 
 
91
/*
78
92
 * slurm_update_partition - issue RPC to a partition's configuration per  
79
93
 *      request, only usable by user root
80
94
 * IN part_msg - description of partition updates
89
103
/*
90
104
 * slurm_delete_partition - issue RPC to delete a partition, only usable 
91
105
 *      by user root
92
 
 * IN part_msg - description of partition updates
 
106
 * IN part_msg - description of partition to delete
93
107
 * RET 0 on success, otherwise return -1 and set errno to indicate the error
94
108
 */
95
109
int 
98
112
        return _slurm_update ((void *) part_msg, REQUEST_DELETE_PARTITION);
99
113
}
100
114
 
 
115
/*
 
116
 * slurm_create_reservation - create a new reservation, only usable by user root
 
117
 * IN resv_msg - description of reservation
 
118
 * RET name of reservation on success (caller must free the memory),
 
119
 *      otherwise return NULL and set errno to indicate the error
 
120
 */
 
121
char * 
 
122
slurm_create_reservation (resv_desc_msg_t * resv_msg ) 
 
123
{
 
124
        int rc;
 
125
        char *resv_name = NULL;
 
126
        slurm_msg_t req_msg;
 
127
        slurm_msg_t resp_msg;
 
128
        reservation_name_msg_t *resp;
 
129
 
 
130
        slurm_msg_t_init(&req_msg);
 
131
        slurm_msg_t_init(&resp_msg);
 
132
 
 
133
        req_msg.msg_type = REQUEST_CREATE_RESERVATION;
 
134
        req_msg.data     = resv_msg; 
 
135
                        
 
136
        rc = slurm_send_recv_controller_msg(&req_msg, &resp_msg);
 
137
        switch (resp_msg.msg_type) {
 
138
        case RESPONSE_CREATE_RESERVATION:
 
139
                resp = (reservation_name_msg_t *) resp_msg.data;
 
140
                resv_name = strdup(resp->name);
 
141
                break;
 
142
        case RESPONSE_SLURM_RC:
 
143
                rc = ((return_code_msg_t *) resp_msg.data)->return_code;
 
144
                if (rc) 
 
145
                        slurm_seterrno(rc);
 
146
                break;
 
147
        default:
 
148
                slurm_seterrno(SLURM_UNEXPECTED_MSG_ERROR);
 
149
        }
 
150
        slurm_free_msg_data(resp_msg.msg_type, resp_msg.data);
 
151
        return resv_name;
 
152
}
 
153
 
 
154
/*
 
155
 * slurm_update_reservation - modify an existing reservation, only usable by 
 
156
 *      user root
 
157
 * IN resv_msg - description of reservation
 
158
 * RET 0 on success, otherwise return -1 and set errno to indicate the error
 
159
 */
 
160
extern int slurm_update_reservation ( resv_desc_msg_t * resv_msg )
 
161
{
 
162
        return _slurm_update ((void *) resv_msg, REQUEST_UPDATE_RESERVATION);
 
163
}
 
164
 
 
165
/*
 
166
 * slurm_delete_reservation - issue RPC to delete a reservation, only usable 
 
167
 *      by user root
 
168
 * IN resv_msg - description of reservation to delete
 
169
 * RET 0 on success, otherwise return -1 and set errno to indicate the error
 
170
 */
 
171
int 
 
172
slurm_delete_reservation ( reservation_name_msg_t * resv_msg ) 
 
173
{
 
174
        return _slurm_update ((void *) resv_msg, REQUEST_DELETE_RESERVATION);
 
175
}
 
176
 
 
177
 
101
178
/* _slurm_update - issue RPC for all update requests */
102
179
static int 
103
180
_slurm_update (void *data, slurm_msg_type_t msg_type)