Skip to content

Commit

Permalink
qa: simplify update_attrs and only update relevant keys
Browse files Browse the repository at this point in the history
So we can just pass the caller's kwargs to update_attrs.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
  • Loading branch information
batrick committed May 7, 2024
1 parent d9239f9 commit 597ff3c
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions qa/tasks/cephfs/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,30 +544,21 @@ def _verify_attrs(self, **kwargs):
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):
"""
Expand Down

0 comments on commit 597ff3c

Please sign in to comment.