nfs: use go-ceph API for creating/deleting exports

Recent versions of Ceph allow calling the NFS-export management
functions over the go-ceph API.

This seems incompatible with older versions that have been tested with
the `ceph nfs` commands that this commit replaces.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2022-03-30 10:45:07 +02:00
committed by mergify[bot]
parent d886ab0d66
commit 28369702d2
2 changed files with 57 additions and 50 deletions

View File

@ -22,6 +22,7 @@ import (
"time"
ca "github.com/ceph/go-ceph/cephfs/admin"
"github.com/ceph/go-ceph/common/admin/nfs"
"github.com/ceph/go-ceph/rados"
ra "github.com/ceph/go-ceph/rbd/admin"
)
@ -140,3 +141,13 @@ func (cc *ClusterConnection) GetTaskAdmin() (*ra.TaskAdmin, error) {
return rbdAdmin.Task(), nil
}
// GetNFSAdmin returns an Admin type that can be used to interact with the
// NFS-cluster that is managed by Ceph.
func (cc *ClusterConnection) GetNFSAdmin() (*nfs.Admin, error) {
if cc.conn == nil {
return nil, errors.New("cluster is not connected yet")
}
return nfs.NewFromConn(cc.conn), nil
}