mirror of https://github.com/ceph/go-ceph
rbd: add wrapper for rbd_pool_init() function
Added PoolInit function implementing rbd_pool_init which sets the application tag to rbd. Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
This commit is contained in:
parent
0ffebd1f25
commit
0cd2b21224
|
@ -84,3 +84,18 @@ func RemovePoolMetadata(ioctx *rados.IOContext, key string) error {
|
|||
ret := C.rbd_pool_metadata_remove(cephIoctx(ioctx), cKey)
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
// PoolInit initializes a pool for use by rbd.
|
||||
// This function does not create new pools, rather it prepares the pool
|
||||
// to host rbd images.
|
||||
//
|
||||
// Implements:
|
||||
// int rbd_pool_init(rados_ioctx_t io, bool force)
|
||||
func PoolInit(ioctx *rados.IOContext, force bool) error {
|
||||
if ioctx == nil {
|
||||
return ErrNoIOContext
|
||||
}
|
||||
|
||||
ret := C.rbd_pool_init(cephIoctx(ioctx), C.bool(force))
|
||||
return getError(ret)
|
||||
}
|
||||
|
|
|
@ -99,3 +99,35 @@ func TestPoolMetadata(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestPoolInit(t *testing.T) {
|
||||
conn := radosConnect(t)
|
||||
poolName := GetUUID()
|
||||
err := conn.MakePool(poolName)
|
||||
assert.NoError(t, err)
|
||||
|
||||
ioctx, err := conn.OpenIOContext(poolName)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, ioctx)
|
||||
|
||||
defer func() {
|
||||
ioctx.Destroy()
|
||||
conn.DeletePool(poolName)
|
||||
conn.Shutdown()
|
||||
}()
|
||||
|
||||
t.Run("NullIOContext", func(t *testing.T) {
|
||||
err := PoolInit(nil, true)
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("PoolInitWithForce", func(t *testing.T) {
|
||||
err := PoolInit(ioctx, true)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("PoolInitWithoutForce", func(t *testing.T) {
|
||||
err := PoolInit(ioctx, false)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue