openstack-helm-infra/ceph-mon/templates/bin/utils/_checkObjectReplication.py.tpl
Chinasubbareddy M 26991ad182 Ceph: A script to check object replication across the hosts
this script will  create  an object and see if the object is
getting replicated across diffrent hosts  or not.

Change-Id: Ic5056c1a07dc5d5b6a5d6fc24e3d9a75fa46458f
2018-10-21 15:38:26 +00:00

31 lines
1.1 KiB
Smarty
Executable File

#!/usr/bin/python2
import subprocess
import json
import sys
import collections
if (int(len(sys.argv)) == 1):
print "Please provide pool name to test , example: checkObjectReplication.py <pool name>"
sys.exit(1)
else:
poolName = sys.argv[1]
cmdRep = 'ceph osd map' + ' ' + str(poolName) + ' ' + 'testreplication -f json-pretty'
objectRep = subprocess.check_output(cmdRep, shell=True)
repOut = json.loads(objectRep)
osdNumbers = repOut['up']
print "Test object got replicated on these osds:" + " " + str(osdNumbers)
osdHosts= []
for osd in osdNumbers:
cmdFind = 'ceph osd find' + ' ' + str(osd)
osdFind = subprocess.check_output(cmdFind , shell=True)
osdHost = json.loads(osdFind)
osdHostLocation = osdHost['crush_location']
osdHosts.append(osdHostLocation['host'])
print "Test object got replicated on these hosts:" + " " + str(osdHosts)
print "Hosts hosting multiple copies of a placement groups are:" + str([item for item, count in collections.Counter(osdHosts).items() if count > 1])
sys.exit(0)