]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: simplify update_attrs and only update relevant keys
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 2 May 2024 02:04:57 +0000 (22:04 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 7 May 2024 12:19:27 +0000 (08:19 -0400)
So we can just pass the caller's kwargs to update_attrs.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
qa/tasks/cephfs/mount.py

index 8757539ad15137cb0fd33ac1d80d4affb29ae87a..2711f6376d30d6edc3ea993beb0f5ffe007f02d7 100644 (file)
@@ -544,30 +544,21 @@ class CephFSMountBase(object):
                 raise RuntimeError('value of attributes should be either str '
                                    f'or None. {k} - {v}')
 
-    def update_attrs(self, client_id=None, client_keyring_path=None,
-                     client_remote=None, hostfs_mntpt=None, cephfs_name=None,
-                     cephfs_mntpt=None):
-        if not (client_id or client_keyring_path or client_remote or
-                cephfs_name or cephfs_mntpt or hostfs_mntpt):
-            return
-
-        self._verify_attrs(client_id=client_id,
-                           client_keyring_path=client_keyring_path,
-                           hostfs_mntpt=hostfs_mntpt, cephfs_name=cephfs_name,
-                           cephfs_mntpt=cephfs_mntpt)
-
-        if client_id:
-            self.client_id = client_id
-        if client_keyring_path:
-            self.client_keyring_path = client_keyring_path
-        if client_remote:
-            self.client_remote = client_remote
-        if hostfs_mntpt:
-            self.hostfs_mntpt = hostfs_mntpt
-        if cephfs_name:
-            self.cephfs_name = cephfs_name
-        if cephfs_mntpt:
-            self.cephfs_mntpt = cephfs_mntpt
+    def update_attrs(self, **kwargs):
+        verify_keys = [
+          'client_id',
+          'client_keyring_path',
+          'hostfs_mntpt',
+          'cephfs_name',
+          'cephfs_mntpt',
+        ]
+
+        self._verify_attrs(**{key: kwargs[key] for key in verify_keys if key in kwargs})
+
+        for k in verify_keys:
+            v = kwargs.get(k)
+            if v is not None:
+                setattr(self, k, v)
 
     def remount(self, **kwargs):
         """