def get_uuid():
(rc,uid,e) = run_command(['ceph', 'config-key', 'get', CLUSTER_UUID_NAME])
- if rc is not 0:
+ if rc:
#uuid is not yet set.
uid = str(uuid.uuid4())
(rc, o, e) = run_command(['ceph', 'config-key', 'put',
CLUSTER_UUID_NAME, uid])
- if rc is not 0:
+ if rc:
raise RuntimeError("\'ceph config-key put\' failed -" + e)
return uid
def get_nums():
(rc, o, e) = run_command(['ceph', '-s', '-f', 'json'])
- if rc is not 0:
+ if rc:
raise RuntimeError("\'ceph -s\' failed - " + e)
oj = json.loads(o)
num_bytes_total = pgmap['bytes_total']
(rc, o, e) = run_command(['ceph', 'pg', 'dump', 'pools', '-f', 'json-pretty'])
- if rc is not 0:
+ if rc:
raise RuntimeError("\'ceph pg dump pools\' failed - " + e)
pools = json.loads(o)
def get_crush_types():
(rc, o, e) = run_command(['ceph', 'osd', 'crush', 'dump'])
- if rc is not 0:
+ if rc:
raise RuntimeError("\'ceph osd crush dump\' failed - " + e)
crush_dump = json.loads(o)
def get_osd_dump_info():
(rc, o, e) = run_command(['ceph', 'osd', 'dump', '-f', 'json'])
- if rc is not 0:
+ if rc:
raise RuntimeError("\'ceph osd dump\' failed - " + e)
pool_meta = []
incr = lambda a,k: 1 if k not in a else a[k]+1
while count < max_osds:
(rc, o, e) = run_command(['ceph', 'osd', 'metadata', str(count)])
- if rc is 0:
- if osd_metadata_available is False:
+ if rc == 0:
+ if not osd_metadata_available:
osd_metadata_available = True
jmeta = json.loads(o)
count = count + 1
sysinfo = {}
- if osd_metadata_available is False:
+ if not osd_metadata_available:
print >> sys.stderr, "'ceph osd metadata' is not available at all"
return sysinfo
def get_ownership_info():
(rc, o, e) = run_command(['ceph', 'config-key', 'get',
CLUSTER_OWNERSHIP_NAME])
- if rc is not 0:
+ if rc:
return {}
return ast.literal_eval(o)
if verbose:
print "PUT " + str(url) + " : " + str(data)
req = requests.put(url, data=data)
- if req.status_code is not 201:
+ if req.status_code != 201:
print >> sys.stderr, "Failed to publish, server responded with code " + str(req.status_code)
print >> sys.stderr, req.text
return 1
params = {'uuid':uuid}
req = requests.delete(url, params=params)
- if req.status_code is not 200:
+ if req.status_code != 200:
print >> sys.stderr, "Failed to unpublish, server responsed with code " + str(req.status_code)
return 1
global verbose
verbose = True
sys.argv.pop(1)
- if len(sys.argv) is 1:
+ if len(sys.argv) == 1:
print output_json()[0]
return 0
if sys.argv[1] == 'update-metadata':
@expose('json')
def get(self, *args, **kwargs):
- if len(args) is 0:
+ if len(args) == 0:
#return the list of uuids
try:
result = db.get_uuids()
except Exception as e:
return self.fail(500, msg="Internal Server Error")
- elif len(args) is 1 or len(args) is 2 and args[1] == '':
+ elif len(args) == 1 or len(args) == 2 and args[1] == '':
#/uuid
try:
result = db.get_versions(args[0])
if result is None:
return self.fail(400, msg="Invalid UUID")
- elif len(args) is 2 or len(args) is 3 and args[2] == '':
+ elif len(args) == 2 or len(args) == 3 and args[2] == '':
#/uuid/version_number
try:
result = db.get_brag(args[0], args[1])