func (p *VirStoragePool) GetInfo() (VirStoragePoolInfo, error) { pi := VirStoragePoolInfo{} var ptr C.virStoragePoolInfo result := C.virStoragePoolGetInfo(p.ptr, (*C.virStoragePoolInfo)(unsafe.Pointer(&ptr))) if result == -1 { return pi, errors.New(GetLastError()) } pi.ptr = ptr return pi, nil }
// InfoAvailable extracts the storage pool remaining free space (bytes) func (pool StoragePool) InfoAvailable() (uint64, error) { var cInfo C.virStoragePoolInfo pool.log.Println("reading storage pool available space...") cRet := C.virStoragePoolGetInfo(pool.virStoragePool, &cInfo) ret := int32(cRet) if ret == -1 { err := LastError() pool.log.Printf("an error occurred: %v\n", err) return 0, err } available := uint64(cInfo.available) pool.log.Printf("available: %v bytes\n", available) return available, nil }
// InfoCapacity extracts the storage pool logical size (bytes). func (pool StoragePool) InfoCapacity() (uint64, error) { var cInfo C.virStoragePoolInfo pool.log.Println("reading storage pool capacity...") cRet := C.virStoragePoolGetInfo(pool.virStoragePool, &cInfo) ret := int32(cRet) if ret == -1 { err := LastError() pool.log.Printf("an error occurred: %v\n", err) return 0, err } capacity := uint64(cInfo.capacity) pool.log.Printf("capacity: %v bytes\n", capacity) return capacity, nil }
// InfoAllocation extracts the storage pool current allocation (bytes). func (pool StoragePool) InfoAllocation() (uint64, error) { var cInfo C.virStoragePoolInfo pool.log.Println("reading storage pool allocation...") cRet := C.virStoragePoolGetInfo(pool.virStoragePool, &cInfo) ret := int32(cRet) if ret == -1 { err := LastError() pool.log.Printf("an error occurred: %v\n", err) return 0, err } allocation := uint64(cInfo.allocation) pool.log.Printf("allocation: %v bytes\n", allocation) return allocation, nil }
// InfoState extracts the storage pool state. func (pool StoragePool) InfoState() (StoragePoolState, error) { var cInfo C.virStoragePoolInfo pool.log.Println("reading storage pool state...") cRet := C.virStoragePoolGetInfo(pool.virStoragePool, &cInfo) ret := int32(cRet) if ret == -1 { err := LastError() pool.log.Printf("an error occurred: %v\n", err) return 0, err } state := StoragePoolState(cInfo.state) pool.log.Printf("state: %v\n", state) return state, nil }