From 92dfac645a564f46fe6c74a3c706a3598a758b8a Mon Sep 17 00:00:00 2001 From: "Taylor, Stephen (st053q)" Date: Mon, 3 Feb 2020 13:02:33 -0700 Subject: [PATCH] [Ceph Nautilus] Fix _checkPGs.py.tpl for Nautilus compatibility The output of 'ceph pg ls-by-pool' changed format in Nautilus, which caused the checkPGs.py script to fail in some scenarios. This change addresses that format change and fixes Nautilus compatibility in the script. Mimic compatibility is maintained. Change-Id: I11d8337b548f959d0a4b58b7e8f76720a0371e73 --- ceph-client/templates/bin/utils/_checkPGs.py.tpl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ceph-client/templates/bin/utils/_checkPGs.py.tpl b/ceph-client/templates/bin/utils/_checkPGs.py.tpl index f98cdb2e8..d6f4c1fee 100755 --- a/ceph-client/templates/bin/utils/_checkPGs.py.tpl +++ b/ceph-client/templates/bin/utils/_checkPGs.py.tpl @@ -106,6 +106,10 @@ class cephCRUSH(): """Replica of the pool. Initialize to 0.""" self.poolSize = 0 + def isNautilus(self): + grepResult = int(subprocess.check_output('ceph mon versions | egrep -q "nautilus" | echo $?', shell=True)) + return True if grepResult == 0 else False + def getPoolSize(self, poolName): """ size (number of replica) is an attribute of a pool @@ -125,11 +129,12 @@ class cephCRUSH(): return def checkPGs(self, poolName): - if not len(self.poolPGs) > 0: + poolPGs = self.poolPGs['pg_stats'] if self.isNautilus() else self.poolPGs + if len(poolPGs) == 0: return print('Checking PGs in pool {} ...'.format(poolName)), badPGs = False - for pg in self.poolPGs: + for pg in poolPGs: osdUp = pg['up'] """ Construct the OSD path from the leaf to the root. If the