From: Rishabh Dave Date: Wed, 6 Nov 2019 06:05:02 +0000 (+0530) Subject: qa/tasks: add methods to get monitor's sockets X-Git-Tag: v15.1.0~639^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2130785f2c8d541a41d16da1f526ed69c1aa6376;p=ceph.git qa/tasks: add methods to get monitor's sockets Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index a8f9ed064aa0..da4ad75b8da3 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -1190,13 +1190,19 @@ class ObjectStoreTool: self.manager.wait_till_osd_is_up(self.osd, 300) +# XXX: this class has nothing to do with the Ceph daemon (ceph-mgr) of +# the same name. class CephManager: """ Ceph manager object. Contains several local functions that form a bulk of this module. - Note: this class has nothing to do with the Ceph daemon (ceph-mgr) of - the same name. + :param controller: the remote machine where the Ceph commands should be + executed + :param ctx: the cluster context + :param config: path to Ceph config file + :param logger: for logging messages + :param cluster: name of the Ceph cluster """ def __init__(self, controller, ctx=None, config=None, logger=None, @@ -1293,6 +1299,53 @@ class CephManager: args.append(watch_channel) return self.controller.run(args=args, wait=False, stdout=StringIO(), stdin=run.PIPE) + def get_mon_socks(self): + """ + Get monitor sockets. + + :return socks: tuple of strings; strings are individual sockets. + """ + from json import loads + + output = loads(self.raw_cluster_cmd(['--format=json', 'mon', 'dump'])) + socks = [] + for mon in output['mons']: + for addrvec_mem in mon['public_addrs']['addrvec']: + socks.append(addrvec_mem['addr']) + return tuple(socks) + + def get_msgrv1_mon_socks(self): + """ + Get monitor sockets that use msgrv1 to operate. + + :return socks: tuple of strings; strings are individual sockets. + """ + from json import loads + + output = loads(self.raw_cluster_cmd('--format=json', 'mon', 'dump')) + socks = [] + for mon in output['mons']: + for addrvec_mem in mon['public_addrs']['addrvec']: + if addrvec_mem['type'] == 'v1': + socks.append(addrvec_mem['addr']) + return tuple(socks) + + def get_msgrv2_mon_socks(self): + """ + Get monitor sockets that use msgrv2 to operate. + + :return socks: tuple of strings; strings are individual sockets. + """ + from json import loads + + output = loads(self.raw_cluster_cmd('--format=json', 'mon', 'dump')) + socks = [] + for mon in output['mons']: + for addrvec_mem in mon['public_addrs']['addrvec']: + if addrvec_mem['type'] == 'v2': + socks.append(addrvec_mem['addr']) + return tuple(socks) + def flush_pg_stats(self, osds, no_wait=None, wait_for_mon=300): """ Flush pg stats from a list of OSD ids, ensuring they are reflected diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index f35fb8a4a414..ef0ff340d8e7 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -880,6 +880,8 @@ class LocalFuseMount(FuseMount): return self.client_remote.run(args=[py_version, '-c', pyscript], wait=False) +# XXX: this class has nothing to do with the Ceph daemon (ceph-mgr) of +# the same name. class LocalCephManager(CephManager): def __init__(self): # Deliberately skip parent init, only inheriting from it to get @@ -941,6 +943,53 @@ class LocalCephManager(CephManager): timeout=timeout ) + def get_mon_socks(self): + """ + Get monitor sockets. + + :return socks: tuple of strings; strings are individual sockets. + """ + from json import loads + + output = loads(self.raw_cluster_cmd('--format=json', 'mon', 'dump')) + socks = [] + for mon in output['mons']: + for addrvec_mem in mon['public_addrs']['addrvec']: + socks.append(addrvec_mem['addr']) + return tuple(socks) + + def get_msgrv1_mon_socks(self): + """ + Get monitor sockets that use msgrv2 to operate. + + :return socks: tuple of strings; strings are individual sockets. + """ + from json import loads + + output = loads(self.raw_cluster_cmd('--format=json', 'mon', 'dump')) + socks = [] + for mon in output['mons']: + for addrvec_mem in mon['public_addrs']['addrvec']: + if addrvec_mem['type'] == 'v1': + socks.append(addrvec_mem['addr']) + return tuple(socks) + + def get_msgrv2_mon_socks(self): + """ + Get monitor sockets that use msgrv2 to operate. + + :return socks: tuple of strings; strings are individual sockets. + """ + from json import loads + + output = loads(self.raw_cluster_cmd('--format=json', 'mon', 'dump')) + socks = [] + for mon in output['mons']: + for addrvec_mem in mon['public_addrs']['addrvec']: + if addrvec_mem['type'] == 'v2': + socks.append(addrvec_mem['addr']) + return tuple(socks) + class LocalCephCluster(CephCluster): def __init__(self, ctx):