From: Rishabh Dave Date: Tue, 8 Dec 2020 05:10:35 +0000 (+0530) Subject: qa/ceph_manager: make it possible to reuse few methods X-Git-Tag: v17.1.0~995^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=93677576c1fd6d0e4e2991a9ba6be6d222ea98ea;p=ceph.git qa/ceph_manager: make it possible to reuse few methods Make minor adjustments to ceph_manager.CephManager so that methods run_ceph_w(), run_cluster_cmd() raw_cluster_cmd() and raw_cluster_cmd_result() can be reused, instead of duplicating, in subclasses. The adjustments are - * Having variables contain arguments that'll be prepended to every command received by the methods above. * Grouping variables that needs to be overridden together so that it is easy to spot and override them for users. Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index 3dca41832ed4..331ee52db2fc 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -1515,8 +1515,7 @@ class CephManager: self.controller = controller self.next_pool_id = 0 self.cluster = cluster - self.cephadm = cephadm - self.rook = rook + if (logger): self.log = lambda x: logger.info(x) else: @@ -1526,9 +1525,21 @@ class CephManager: """ print(x) self.log = tmp + if self.config is None: self.config = dict() + + # NOTE: These variables are meant to be overriden by vstart_runner.py. + self.rook = rook + self.cephadm = cephadm self.testdir = teuthology.get_testdir(self.ctx) + self.run_cluster_cmd_prefix = [ + 'sudo', 'adjust-ulimits', 'ceph-coverage', + f'{self.testdir}/archive/coverage', 'timeout', '120', 'ceph', + '--cluster', self.cluster] + self.run_ceph_w_prefix = ['sudo', 'daemon-helper', 'kill', 'ceph', + '--cluster', self.cluster] + pools = self.list_pools() self.pools = {} for pool in pools: @@ -1558,6 +1569,8 @@ class CephManager: """ if isinstance(kwargs['args'], str): kwargs['args'] = shlex.split(kwargs['args']) + elif isinstance(kwargs['args'], tuple): + kwargs['args'] = list(kwargs['args']) if self.cephadm: return shell(self.ctx, self.cluster, self.controller, @@ -1570,10 +1583,7 @@ class CephManager: stdout=StringIO(), check_status=kwargs.get('check_status', True)) - prefix = ['sudo', 'adjust-ulimits', 'ceph-coverage', - f'{self.testdir}/archive/coverage', 'timeout', '120', 'ceph', - '--cluster', self.cluster] - kwargs['args'] = prefix + list(kwargs['args']) + kwargs['args'] = self.run_cluster_cmd_prefix + kwargs['args'] return self.controller.run(**kwargs) def raw_cluster_cmd(self, *args, **kwargs) -> str: @@ -1603,13 +1613,7 @@ class CephManager: 'cluster', 'audit', ... :type watch_channel: str """ - args = ["sudo", - "daemon-helper", - "kill", - "ceph", - '--cluster', - self.cluster, - "-w"] + args = self.run_ceph_w_prefix + ['-w'] if watch_channel is not None: args.append("--watch-channel") args.append(watch_channel)