mirror of
https://github.com/ceph/ceph
synced 2025-01-10 05:00:59 +00:00
mgr/volumes/nfs: get export in a nfs cluster
Fixes: https://tracker.ceph.com/issues/45741 Signed-off-by: Ramana Raja <rraja@redhat.com>
This commit is contained in:
parent
6f8d20f2cb
commit
7dcefb158d
@ -560,6 +560,19 @@ class FSExport(object):
|
||||
|
||||
return 0, json.dumps(result, indent=2), ''
|
||||
|
||||
def get_export(self, cluster_id, pseudo_path):
|
||||
if not f"ganesha-{cluster_id}" in available_clusters(self.mgr):
|
||||
return -errno.ENOENT, "", f"NFS cluster '{cluster_id}' not found"
|
||||
export_dict = {}
|
||||
for export in self.exports[cluster_id]:
|
||||
if export.pseudo == pseudo_path:
|
||||
export_dict = export.to_dict()
|
||||
break
|
||||
if not export_dict:
|
||||
return (-errno.ENOENT, "",
|
||||
f"export with pseudo path '{pseudo_path}' not found in NFS cluster '{cluster_id}'")
|
||||
return 0, json.dumps(export_dict, indent=2), ''
|
||||
|
||||
def make_rados_url(self, obj):
|
||||
if self.rados_namespace:
|
||||
return "rados://{}/{}/{}".format(self.rados_pool, self.rados_namespace, obj)
|
||||
|
@ -277,6 +277,13 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
|
||||
'desc': "List exports of a NFS cluster",
|
||||
'perm': 'r'
|
||||
},
|
||||
{
|
||||
'cmd': 'nfs export get '
|
||||
'name=clusterid,type=CephString '
|
||||
'name=binding,type=CephString ',
|
||||
'desc': "Fetch a export of a NFS cluster given the pseudo path/binding",
|
||||
'perm': 'r'
|
||||
},
|
||||
{
|
||||
'cmd': 'nfs cluster create '
|
||||
'name=type,type=CephString '
|
||||
@ -498,6 +505,9 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
|
||||
def _cmd_nfs_export_ls(self, inbuf, cmd):
|
||||
return self.fs_export.list_exports(cluster_id=cmd['clusterid'], detailed=cmd.get('detailed', False))
|
||||
|
||||
def _cmd_nfs_export_get(self, inbuf, cmd):
|
||||
return self.fs_export.get_export(cluster_id=cmd['clusterid'], pseudo_path=cmd['binding'])
|
||||
|
||||
def _cmd_nfs_cluster_create(self, inbuf, cmd):
|
||||
return self.nfs.create_nfs_cluster(cluster_id=cmd['clusterid'], export_type=cmd['type'],
|
||||
placement=cmd.get('placement', None))
|
||||
|
Loading…
Reference in New Issue
Block a user