util: add method to get rados connection

New go-ceph admin package api's expects to
pass the rados connection as argument.
added new method called GetRBDAdmin
to get admin connection to administrate
rbd volumes.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2021-06-28 12:16:25 +05:30 committed by mergify[bot]
parent 8732bec369
commit b1710f4c53

View File

@ -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