- Pretty much completed set of examples and tests on 'pool' APIs implemented so far
This commit is contained in:
parent
c1288a9a2e
commit
f7f90fe57f
7
zpool.go
7
zpool.go
|
@ -136,6 +136,13 @@ func PoolPropertyToName(p PoolProp) (name string) {
|
|||
return
|
||||
}
|
||||
|
||||
// Map POOL STATE to string.
|
||||
func PoolStateToName(state PoolState) (name string) {
|
||||
ps := C.pool_state_t(state)
|
||||
name = C.GoString(C.zpool_pool_state_to_name(ps))
|
||||
return
|
||||
}
|
||||
|
||||
// Re-read ZFS pool properties and features, refresh Pool.Properties and
|
||||
// Pool.Features map
|
||||
func (pool *Pool) ReloadProperties() (err error) {
|
||||
|
|
|
@ -227,6 +227,17 @@ func zpoolTestPoolProp(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
// this test pool should not be bootable
|
||||
prop, err := pool.GetProperty(zfs.PoolPropBootfs)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if prop.Value != "-" {
|
||||
t.Errorf("Failed at bootable fs property evaluation")
|
||||
return
|
||||
}
|
||||
|
||||
// fetch all properties
|
||||
if err = pool.ReloadProperties(); err != nil {
|
||||
t.Error(err)
|
||||
|
@ -253,10 +264,12 @@ func zpoolTestPoolStatusAndState(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
if _, err = pool.State(); err != nil {
|
||||
var pstate zfs.PoolState
|
||||
if pstate, err = pool.State(); err != nil {
|
||||
t.Error(err.Error())
|
||||
return
|
||||
}
|
||||
println("POOL", TST_POOL_NAME, "state:", zfs.PoolStateToName(pstate))
|
||||
|
||||
println("PASS\n")
|
||||
}
|
||||
|
@ -412,3 +425,16 @@ func ExamplePool_ExportForce() {
|
|||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func ExamplePool_State() {
|
||||
p, err := zfs.PoolOpen("TESTPOOL")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer p.Close()
|
||||
pstate, err := p.State()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
println("POOL TESTPOOL state:", zfs.PoolStateToName(pstate))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue