2020from mgr_module import NFS_POOL_NAME as POOL_NAME , NFS_GANESHA_SUPPORTED_FSALS
2121
2222from .export_utils import GaneshaConfParser , Export , RawBlock , CephFSFSAL , RGWFSAL
23- from .exception import NFSException , NFSInvalidOperation , FSNotFound , \
24- ClusterNotFound
23+ from .exception import NFSException , NFSInvalidOperation , FSNotFound
2524from .utils import (
2625 CONF_PREFIX ,
2726 EXPORT_PREFIX ,
4039log = logging .getLogger (__name__ )
4140
4241
42+ def known_cluster_ids (mgr : 'Module' ) -> Set [str ]:
43+ """Return the set of known cluster IDs."""
44+ try :
45+ clusters = set (available_clusters (mgr ))
46+ except NoOrchestrator :
47+ clusters = nfs_rados_configs (mgr .rados )
48+ return clusters
49+
50+
4351def export_cluster_checker (func : FuncT ) -> FuncT :
4452 def cluster_check (
4553 export : 'ExportMgr' ,
@@ -49,10 +57,7 @@ def cluster_check(
4957 """
5058 This method checks if cluster exists
5159 """
52- try :
53- clusters = set (available_clusters (export .mgr ))
54- except NoOrchestrator :
55- clusters = nfs_rados_configs (export .mgr .rados )
60+ clusters = known_cluster_ids (export .mgr )
5661 cluster_id : str = kwargs ['cluster_id' ]
5762 log .debug ("checking for %r in known nfs clusters: %r" ,
5863 cluster_id , clusters )
@@ -187,10 +192,10 @@ def exports(self) -> Dict[str, List[Export]]:
187192 if self ._exports is None :
188193 self ._exports = {}
189194 log .info ("Begin export parsing" )
190- for cluster_id in available_clusters (self .mgr ):
195+ for cluster_id in known_cluster_ids (self .mgr ):
191196 self .export_conf_objs = [] # type: List[Export]
192197 self ._read_raw_config (cluster_id )
193- self .exports [cluster_id ] = self .export_conf_objs
198+ self ._exports [cluster_id ] = self .export_conf_objs
194199 log .info ("Exports parsed successfully %s" , self .exports .items ())
195200 return self ._exports
196201
@@ -710,8 +715,6 @@ def _apply_export(
710715 for k in ['path' , 'pseudo' ]:
711716 if k not in new_export_dict :
712717 raise NFSInvalidOperation (f'Export missing required field { k } ' )
713- if cluster_id not in available_clusters (self .mgr ):
714- raise ClusterNotFound ()
715718 if cluster_id not in self .exports :
716719 self .exports [cluster_id ] = []
717720
0 commit comments