From: John Mulligan Date: Thu, 21 Apr 2022 19:17:40 +0000 (-0400) Subject: mgr/nfs: lift validate squash method to file level function X-Git-Tag: v18.0.0~948^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2587c29c8a8fe496b9b8fd705aeee6fb6333a71f;p=ceph.git mgr/nfs: lift validate squash 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 --- diff --git a/src/pybind/mgr/nfs/ganesha_conf.py b/src/pybind/mgr/nfs/ganesha_conf.py index 0db9559b5385..a35441b4e947 100644 --- a/src/pybind/mgr/nfs/ganesha_conf.py +++ b/src/pybind/mgr/nfs/ganesha_conf.py @@ -25,6 +25,18 @@ def _format_val(block_name: str, key: str, val: str) -> str: return '"{}"'.format(val) +def _validate_squash(squash: str) -> None: + valid_squash_ls = [ + "root", "root_squash", "rootsquash", "rootid", "root_id_squash", + "rootidsquash", "all", "all_squash", "allsquash", "all_anomnymous", + "allanonymous", "no_root_squash", "none", "noidsquash", + ] + if squash.lower() not in valid_squash_ls: + raise NFSInvalidOperation( + f"squash {squash} not in valid list {valid_squash_ls}" + ) + + class RawBlock(): def __init__(self, block_name: str, blocks: List['RawBlock'] = [], values: Dict[str, Any] = {}): if not values: # workaround mutable default argument @@ -437,18 +449,6 @@ class Export: f'{valid_access_types}' ) - @staticmethod - def validate_squash(squash: str) -> None: - valid_squash_ls = [ - "root", "root_squash", "rootsquash", "rootid", "root_id_squash", - "rootidsquash", "all", "all_squash", "allsquash", "all_anomnymous", - "allanonymous", "no_root_squash", "none", "noidsquash", - ] - if squash.lower() not in valid_squash_ls: - raise NFSInvalidOperation( - f"squash {squash} not in valid list {valid_squash_ls}" - ) - def validate(self, mgr: 'Module') -> None: if not isabs(self.pseudo) or self.pseudo == "/": raise NFSInvalidOperation( @@ -456,7 +456,7 @@ class Export: "path and it cannot be just '/'." ) - self.validate_squash(self.squash) + _validate_squash(self.squash) self.validate_access_type(self.access_type) if not isinstance(self.security_label, bool): @@ -473,7 +473,7 @@ class Export: for client in self.clients: if client.squash: - self.validate_squash(client.squash) + _validate_squash(client.squash) if client.access_type: self.validate_access_type(client.access_type)