Beispiel #1
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
}
Beispiel #2
0
func Pbs_statnode(handle int, id string, attribs []Attrib, extend string) ([]BatchStatus, error) {
	i := C.CString(id)
	defer C.free(unsafe.Pointer(i))

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

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

	batch_status := C.pbs_statnode(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
}