From: Varsha Rao Date: Tue, 18 May 2021 09:16:32 +0000 (+0530) Subject: mgr/nfs: use CLICheckNonemptyFileInput decorator X-Git-Tag: v17.1.0~1822^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6193f386986ced5d64c12a666aee1352efe898f0;p=ceph.git mgr/nfs: use CLICheckNonemptyFileInput decorator Fixes: https://tracker.ceph.com/issues/50858 Signed-off-by: Varsha Rao --- diff --git a/src/pybind/mgr/nfs/cluster.py b/src/pybind/mgr/nfs/cluster.py index aac469412b2f..884dd3be7b72 100644 --- a/src/pybind/mgr/nfs/cluster.py +++ b/src/pybind/mgr/nfs/cluster.py @@ -190,8 +190,6 @@ class NFSCluster: @cluster_setter def set_nfs_cluster_config(self, cluster_id, nfs_config): try: - if not nfs_config: - raise NFSInvalidOperation("Empty Config!!") if cluster_id in available_clusters(self.mgr): rados_obj = NFSRados(self.mgr, self.pool_ns) if rados_obj.check_user_config(): diff --git a/src/pybind/mgr/nfs/export.py b/src/pybind/mgr/nfs/export.py index d7f4f7b29f02..6db66ed798b9 100644 --- a/src/pybind/mgr/nfs/export.py +++ b/src/pybind/mgr/nfs/export.py @@ -332,8 +332,6 @@ class ExportMgr: def update_export(self, export_config): try: - if not export_config: - raise NFSInvalidOperation("Empty Config!!") new_export = json.loads(export_config) # check export type return FSExport(self).update_export(new_export) diff --git a/src/pybind/mgr/nfs/module.py b/src/pybind/mgr/nfs/module.py index 5bd1e9260e88..e32c7d30b1b5 100644 --- a/src/pybind/mgr/nfs/module.py +++ b/src/pybind/mgr/nfs/module.py @@ -1,9 +1,8 @@ -import errno import logging import threading from typing import Tuple, Optional, List -from mgr_module import MgrModule, CLICommand, Option +from mgr_module import MgrModule, CLICommand, Option, CLICheckNonemptyFileInput import orchestrator from .export import ExportMgr @@ -58,6 +57,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): return self.export_mgr.get_export(cluster_id=clusterid, pseudo_path=binding) @CLICommand('nfs export update', perm='rw') + @CLICheckNonemptyFileInput(desc='CephFS Export configuration') def _cmd_nfs_export_update(self, inbuf: str) -> Tuple[int, str, str]: """Update an export of a NFS cluster by `-i `""" # The export is passed to -i and it's processing is handled by the Ceph CLI. @@ -94,6 +94,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): return self.nfs.show_nfs_cluster_info(cluster_id=clusterid) @CLICommand('nfs cluster config set', perm='rw') + @CLICheckNonemptyFileInput(desc='NFS-Ganesha Configuration') def _cmd_nfs_cluster_config_set(self, clusterid: str, inbuf: str) -> Tuple[int, str, str]: """Set NFS-Ganesha config by `-i `""" return self.nfs.set_nfs_cluster_config(cluster_id=clusterid, nfs_config=inbuf)