Example #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
}
Example #2
0
// StatNode return stat all nodes.
func (t *Torque) StatNode() ([]Node, error) {
	bs := C.pbs_statnode(C.int(t.serverID), nil, nil, nil)
	if bs == nil {
		return nil, GetLastError()
	}
	defer C.pbs_statfree(bs)

	nodes := make([]Node, 0, 1)

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

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

		status := n.attr["status"]
		delete(n.attr, "status")
		n.status = kvlistToMap(status.value)

		nodes = append(nodes, n)
	}
	return nodes, nil
}
Example #3
0
// StatServer return statserver.
func (t *Torque) StatServer() (Server, error) {
	bs := C.pbs_statserver(C.int(t.serverID), nil, nil)
	if bs == nil {
		return Server{}, GetLastError()
	}
	defer C.pbs_statfree(bs)

	srv := Server{name: C.GoString(bs.name)}

	srv.attr = make(map[string]Attribute)
	for name, attr := range attrlToAttributeMap(bs.attribs) {
		srv.attr[name] = attr
	}

	return srv, nil
}
Example #4
0
File: pbs.go Project: jbarber/pbs
func Pbs_statserver(handle int, attribs []Attrib, extend string) ([]BatchStatus, error) {
	a := attrib2attribl(attribs)
	defer freeattribl(a)

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

	batch_status := C.pbs_statserver(C.int(handle), 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
}
Example #5
0
File: pbs.go Project: jbarber/pbs
func Pbs_selstat(handle int, attribs []Attrib, extend string) ([]BatchStatus, error) {
	a := attrib2attribl(attribs)
	defer freeattribl(a)

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

	batch_status := C.pbs_selstat(C.int(handle), (*C.struct_attropl)(unsafe.Pointer(a)), e)

	// FIXME: nil also indicates no jobs matched selection criteria...
	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
}
Example #6
0
// StatQeueu return stat all queue.
func (t *Torque) StatQue() ([]Queue, error) {
	bs := C.pbs_statque(C.int(t.serverID), nil, nil, nil)
	if bs == nil {
		return nil, GetLastError()
	}
	defer C.pbs_statfree(bs)

	queues := make([]Queue, 0, 1)

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

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

	return queues, nil
}