[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
This commit is contained in:
Taylor, Stephen (st053q) 2020-02-03 13:02:33 -07:00
parent 3dd0eb0cdf
commit 92dfac645a
1 changed files with 7 additions and 2 deletions

View File

@ -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