From e4c146fe7a5d3c0e69068c3e8eff2e1dbbcf57e1 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 21 Apr 2022 15:27:40 -0400 Subject: [PATCH] mgr/nfs: lift validate access type method to file level function More reusable across the entire file and made private, shrinking the public surface area of the type. Signed-off-by: John Mulligan (cherry picked from commit 3d17b9ee74b01a0dec3d4f2b50ab242a91259faf) --- src/pybind/mgr/nfs/ganesha_conf.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pybind/mgr/nfs/ganesha_conf.py b/src/pybind/mgr/nfs/ganesha_conf.py index a35441b4e9473..17d967e77e5cd 100644 --- a/src/pybind/mgr/nfs/ganesha_conf.py +++ b/src/pybind/mgr/nfs/ganesha_conf.py @@ -37,6 +37,15 @@ def _validate_squash(squash: str) -> None: ) +def _validate_access_type(access_type: str) -> None: + valid_access_types = ['rw', 'ro', 'none'] + if not isinstance(access_type, str) or access_type.lower() not in valid_access_types: + raise NFSInvalidOperation( + f'{access_type} is invalid, valid access type are' + f'{valid_access_types}' + ) + + class RawBlock(): def __init__(self, block_name: str, blocks: List['RawBlock'] = [], values: Dict[str, Any] = {}): if not values: # workaround mutable default argument @@ -440,15 +449,6 @@ class Export: 'clients': [client.to_dict() for client in self.clients] } - @staticmethod - def validate_access_type(access_type: str) -> None: - valid_access_types = ['rw', 'ro', 'none'] - if not isinstance(access_type, str) or access_type.lower() not in valid_access_types: - raise NFSInvalidOperation( - f'{access_type} is invalid, valid access type are' - f'{valid_access_types}' - ) - def validate(self, mgr: 'Module') -> None: if not isabs(self.pseudo) or self.pseudo == "/": raise NFSInvalidOperation( @@ -457,7 +457,7 @@ class Export: ) _validate_squash(self.squash) - self.validate_access_type(self.access_type) + _validate_access_type(self.access_type) if not isinstance(self.security_label, bool): raise NFSInvalidOperation('security_label must be a boolean value') @@ -475,7 +475,7 @@ class Export: if client.squash: _validate_squash(client.squash) if client.access_type: - self.validate_access_type(client.access_type) + _validate_access_type(client.access_type) if self.fsal.name == NFS_GANESHA_SUPPORTED_FSALS[0]: fs = cast(CephFSFSAL, self.fsal) -- 2.39.5