]> 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)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 14 May 2024 15:50:05 +0000 (17:50 +0200)
So we can just pass the caller's kwargs to update_attrs.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 597ff3cb15e7a7ce527b35eb01d9958b755bbf01)
(cherry picked from commit ed939ee6743025c4d88704de7351fad2b62cffb8)

qa/tasks/cephfs/mount.py

index bd92cadaa64674fc27e35d63a53382d030ad9829..1cb8c6f910181f4d1238948af54f92b36a6aa522 100644 (file)
@@ -551,30 +551,21 @@ class CephFSMount(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):
         """