From fe62348cfbaad80e731033dbb6e20699eb7eed56 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 5 Aug 2020 16:30:47 +0200 Subject: [PATCH] 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 --- internal/util/connection.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/util/connection.go b/internal/util/connection.go index 172faffe8..713e1ab43 100644 --- a/internal/util/connection.go +++ b/internal/util/connection.go @@ -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 +}