Exemplo n.º 1
0
// StatJob return stat all jobs.
// if id is not empty, return specified job
func (t *Torque) StatJob(jobid string) ([]Job, error) {
	var cid *C.char
	if len(jobid) != 0 {
		cid = C.CString(jobid)
		defer C.free(unsafe.Pointer(cid))
	}

	bs := C.pbs_statjob(C.int(t.serverID), cid, nil, nil)
	if bs == nil {
		return nil, GetLastError()
	}
	defer C.pbs_statfree(bs)

	jobs := make([]Job, 0, 1)

	for cur := bs; cur != nil; cur = cur.next {
		j := Job{}
		j.name = C.GoString(cur.name)
		j.attr = make(map[string]Attribute)

		for name, attr := range attrlToAttributeMap(cur.attribs) {
			j.attr[name] = attr
		}

		vl := j.attr["Variable_List"]
		delete(j.attr, "Variable_List")
		j.variableList = kvlistToMap(vl.value)

		jobs = append(jobs, j)
	}

	return jobs, nil
}
Exemplo n.º 2
0
Arquivo: pbs.go Projeto: jbarber/pbs
func Pbs_statjob(handle int, id string, attribs []Attrib, extend string) ([]BatchStatus, error) {
	i := C.CString(id)
	defer C.free(unsafe.Pointer(i))

	e := C.CString(extend)
	defer C.free(unsafe.Pointer(e))

	a := attrib2attribl(attribs)
	defer freeattribl(a)

	batch_status := C.pbs_statjob(C.int(handle), i, a, e)

	if batch_status == nil {
		return nil, errors.New(Pbs_strerror(int(C.pbs_errno)))
	}
	defer C.pbs_statfree(batch_status)

	batch := get_pbs_batch_status(batch_status)

	return batch, nil
}