util: add ClusterConnection.GetFSAdmin()

The go-ceph CephFS Admin API needs a rados.Conn to connect the Admin
interface to the Ceph cluster. As the rados.Conn is internal to the
ClusterConnection type, add GetFSAdmin() to create a new FSAdmin
instance for a specific connection.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-08-05 16:30:47 +02:00 committed by mergify[bot]
parent 1fcd1ed7c7
commit fe62348cfb

View File

@ -21,6 +21,7 @@ import (
"fmt"
"time"
ca "github.com/ceph/go-ceph/cephfs/admin"
"github.com/ceph/go-ceph/rados"
)
@ -83,3 +84,11 @@ func (cc *ClusterConnection) GetIoctx(pool string) (*rados.IOContext, error) {
return ioctx, nil
}
func (cc *ClusterConnection) GetFSAdmin() (*ca.FSAdmin, error) {
if cc.conn == nil {
return nil, errors.New("cluster is not connected yet")
}
return ca.NewFromConn(cc.conn), nil
}