# Path: cephinfo/cephinfo.py
# def jsoncmd(command):
# def init_df():
# def init_mon():
# def init_osd():
# def init_pg():
# def init_auth():
# def init_stat():
# def init_crush():
# def get_json():
# def get_pools_data():
# def get_n_pools():
# def get_osds_data():
# def get_n_osds():
# def get_osd_states():
# def get_pg_data():
# def get_pg_stats():
# def get_pg_stats_sum():
# def get_osd_stats_sum():
# def get_pg_stats_delta():
# def get_n_pgs():
# def get_pg_states():
# def get_n_mons():
# def get_n_mons_quorum():
# def get_write_latency():
# def get_read_latency():
# def rados_cleanup(prefix):
# def get_n_openstack_volumes():
# def get_n_openstack_images():
# def get_smooth_activity(n):


import commands
from cephinfo import cephinfo
#!/usr/bin/env python


cephinfo.init_auth()
cephinfo.init_osd()

yesno = 'n'

for entry in cephinfo.auth_data['auth_dump']:
  entity = entry['entity']
  if not entity.startswith('osd'):
    continue

  for osd in cephinfo.osd_data['osds']:
    if "osd.%d" % osd['osd'] == entity:
      print "auth'd osd %s is in state %s" % (entity, osd['state'])
      break
  else:
    print "auth'd osd %s doesn't exist" % entity
    if yesno == 'all':
      cmd = "echo ceph auth del %s" % entity
      print cmd

# Path: cephinfo/cephinfo.py
# def jsoncmd(command):
# def init_df():
# def init_mon():
# def init_osd():
# def init_pg():
# def init_auth():
# def init_stat():
# def init_crush():
# def get_json():
# def get_pools_data():
# def get_n_pools():
# def get_osds_data():
# def get_n_osds():
# def get_osd_states():
# def get_pg_data():
# def get_pg_stats():
# def get_pg_stats_sum():
# def get_osd_stats_sum():
# def get_pg_stats_delta():
# def get_n_pgs():
# def get_pg_states():
# def get_n_mons():
# def get_n_mons_quorum():
# def get_write_latency():
# def get_read_latency():
# def rados_cleanup(prefix):
# def get_n_openstack_volumes():
# def get_n_openstack_images():
# def get_smooth_activity(n):


# Path: tools/find-orphan-osd-auths.py
import commands
from cephinfo import cephinfo

#!/usr/bin/env python


cephinfo.init_auth()
cephinfo.init_osd()

yesno = 'n'

for entry in cephinfo.auth_data['auth_dump']:
  entity = entry['entity']
  if not entity.startswith('osd'):
    continue

  for osd in cephinfo.osd_data['osds']:
    if "osd.%d" % osd['osd'] == entity:
      print "auth'd osd %s is in state %s" % (entity, osd['state'])
      break
  else:
    print "auth'd osd %s doesn't exist" % entity
    if yesno == 'all':
      cmd = "echo ceph auth del %s" % entity
      print cmd

      print commands.getoutput(cmd)