예제 #1
0
파일: do_reserve.c 프로젝트: A1ve5/slurm
/**
 * basil_reserve  -  wrapper around rsvn_new.
 * @user:       owner of the reservation
 * @batch_id:   (numeric) job ID
 * @width:      mppwidth (aprun -n)
 * @depth:      mppdepth (aprun -d)
 * @nppn:       mppnppn  (aprun -N)
 * @mem_mb:     mppmem   (aprun -m)
 * @ns_head:    list of requested mppnodes (will be freed if not NULL)
 * @accel_head: optional accelerator parameters
 * Returns reservation ID > 0 if ok, negative %enum basil_error on error.
 */
long basil_reserve(const char *user, const char *batch_id,
		   uint32_t width, uint32_t depth, uint32_t nppn,
		   uint32_t mem_mb, uint32_t nppcu, struct nodespec *ns_head,
		   struct basil_accel_param *accel_head)
{
	struct basil_reservation *rsvn;
	struct basil_parse_data bp = {0};
	/* do not free mppnodes it is stored/freed in the rsvn struct */
	char *mppnodes = ns_to_string(ns_head);
	long rc;

	free_nodespec(ns_head);
	rsvn = _rsvn_new(user, batch_id, width, depth, nppn, mem_mb,
			 nppcu, mppnodes, accel_head);
	if (rsvn == NULL)
		return -BE_INTERNAL;

	bp.method    = BM_reserve;
	bp.mdata.res = rsvn;
	bp.version   = BV_1_0;
	/*
	 * Rule:
	 * - if *res->batch_id is set, we are using Basil 1.1
	 * - if *res->batch_id == '\0' we have to fall back to Basil 1.0
	 */
	if (batch_id && *batch_id)
		bp.version = get_basil_version();

	rc = basil_request(&bp);
	if (rc >= 0)
		rc = rsvn->rsvn_id;
	free_rsvn(rsvn);
	return rc;
}
예제 #2
0
파일: do_query.c 프로젝트: xabellan/slurm
/** Perform a detailed inventory */
extern struct basil_inventory *get_full_inventory(enum basil_version version)
{
    struct basil_parse_data bp = {0};

    bp.version   = version;
    bp.method    = BM_inventory;
    bp.mdata.inv = xmalloc(sizeof(*bp.mdata.inv));

    if (bp.mdata.inv) {
        bp.mdata.inv->f = xmalloc(sizeof(struct basil_full_inventory));
        if (bp.mdata.inv->f == NULL) {
            xfree(bp.mdata.inv);
            bp.mdata.inv = NULL;
        }
    }

    if (bp.mdata.inv == NULL)
        return NULL;

    if (basil_request(&bp) < 0) {
        free_inv(bp.mdata.inv);
        return NULL;
    }

    return bp.mdata.inv;
}
예제 #3
0
파일: do_release.c 프로젝트: HPCNow/slurm
static int rsvn_release(struct basil_reservation *res)
{
	struct basil_parse_data bp = {0};

	bp.method    = BM_release;
	bp.mdata.res = res;
	bp.version   = get_basil_version();
	/* NOTE - for simplicity we could use BV_1_0 here */

	return basil_request(&bp);
}
예제 #4
0
파일: do_switch.c 프로젝트: jtfrey/slurm
/**
 * basil_switch - suspend/resume an existing reservation
 * @rsvn_id:    the reservation id
 * @suspend:    to suspend or not to suspend
 * Returns 0 if ok, a negative %basil_error otherwise.
 *
 */
int basil_switch(uint32_t rsvn_id, bool suspend)
{
	struct basil_reservation rsvn = {0};
	struct basil_parse_data bp = {0};

	rsvn.rsvn_id = rsvn_id;
	rsvn.suspended = suspend;

	bp.method    = BM_switch;
	bp.mdata.res = &rsvn;
	bp.version   = get_basil_version();
	/* NOTE - for simplicity we could use BV_1_0 here */

	return basil_request(&bp);
}
예제 #5
0
파일: do_query.c 프로젝트: xabellan/slurm
/**
 * _get_alps_engine  -  run QUERY of type ENGINE
 * This uses the convention of returning the Engine.version attribute via 'msg'.
 * Returns pointer to @buf, NULL on error.
 */
static const char *_get_alps_engine(char *buf, size_t buflen)
{
    struct basil_parse_data bp = {0};

    if (cray_conf->alps_engine) {
        strncpy(buf, cray_conf->alps_engine, buflen);
        return buf;
    }

    /* For this query use Basil 1.0 as lowest common denominator */
    bp.version = BV_1_0;
    bp.method  = BM_engine;

    if (basil_request(&bp) < 0)
        return NULL;
    strncpy(buf, bp.msg, buflen);
    return buf;
}