]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: use CLICheckNonemptyFileInput decorator
authorVarsha Rao <varao@redhat.com>
Tue, 18 May 2021 09:16:32 +0000 (14:46 +0530)
committerVarsha Rao <varao@redhat.com>
Wed, 26 May 2021 06:10:02 +0000 (11:40 +0530)
Fixes: https://tracker.ceph.com/issues/50858
Signed-off-by: Varsha Rao <varao@redhat.com>
src/pybind/mgr/nfs/cluster.py
src/pybind/mgr/nfs/export.py
src/pybind/mgr/nfs/module.py

index aac469412b2f55adc1f93754fc65e40dd0900b9c..884dd3be7b72e1c15f097ed2523f66dee7365d47 100644 (file)
@@ -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():
index d7f4f7b29f023178e377bfc2c86f78875274f7f0..6db66ed798b9ed96ea6d96bdc993821e8fd6378c 100644 (file)
@@ -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)
index 5bd1e9260e88140a7123dbe5199b1c827513efe4..e32c7d30b1b55c35b5feeefbc822a1b40c05cecf 100644 (file)
@@ -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 <json_file>`"""
         # The export <json_file> 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 <config_file>`"""
         return self.nfs.set_nfs_cluster_config(cluster_id=clusterid, nfs_config=inbuf)