diff --git a/internal/util/connection.go b/internal/util/connection.go index b25e35a6d..6d17697d9 100644 --- a/internal/util/connection.go +++ b/internal/util/connection.go @@ -23,6 +23,7 @@ import ( ca "github.com/ceph/go-ceph/cephfs/admin" "github.com/ceph/go-ceph/rados" + ra "github.com/ceph/go-ceph/rbd/admin" ) type ClusterConnection struct { @@ -111,6 +112,15 @@ func (cc *ClusterConnection) GetFSAdmin() (*ca.FSAdmin, error) { return ca.NewFromConn(cc.conn), nil } +// GetRBDAdmin get RBDAdmin to administrate rbd volumes. +func (cc *ClusterConnection) GetRBDAdmin() (*ra.RBDAdmin, error) { + if cc.conn == nil { + return nil, errors.New("cluster is not connected yet") + } + + return ra.NewFromConn(cc.conn), nil +} + // DisableDiscardOnZeroedWriteSame enables the // `rbd_discard_on_zeroed_write_same` option in the cluster connection, so that // writing zero blocks of data are actual writes on the OSDs (doing