# 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):


from cephinfo import cephinfo
from optparse import OptionParser
from collections import defaultdict
import ceph_osds_in_bucket
import os
  import sys

# don't reweight if there is less than 100GB per OSD total capacity
mon_reweight_min_bytes_per_osd = 10*1024*1024*1024

# don't reweight if there is less than 1GB used capacity per OSD
mon_reweight_min_bytes_used_per_osd = 1024*1024*1024

# don't reweight if there are less than 10 PGs per OSD
mon_reweight_min_pgs_per_osd = 10

VERBOSE = False

def get_weight(osd, type='reweight'):
  try:
    return osd_weights[osd][type]
  except KeyError:
    return 0.0

def change_weight(osd, new_weight, really):
  cmd = "ceph osd reweight %d %5f &" % (osd, new_weight)
  if VERBOSE: print cmd
  if really:
    os.system(cmd)
  else:
    print "add --really to run '%s'" % cmd

def reweight_by_utilization(options):
  if options.oload <= 100:
    raise Exception("You must give a percentage higher than 100.")


# 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/crush-reweight-by-utilization.py
from cephinfo import cephinfo
from optparse import OptionParser
from collections import defaultdict
import ceph_osds_in_bucket
import os
  import sys


# don't reweight if there is less than 100GB per OSD total capacity
mon_reweight_min_bytes_per_osd = 10*1024*1024*1024

# don't reweight if there is less than 1GB used capacity per OSD
mon_reweight_min_bytes_used_per_osd = 1024*1024*1024

# don't reweight if there are less than 10 PGs per OSD
mon_reweight_min_pgs_per_osd = 10

VERBOSE = False

def get_weight(osd, type='reweight'):
  try:
    return osd_weights[osd][type]
  except KeyError:
    return 0.0

def change_weight(osd, new_weight, really):
  cmd = "ceph osd reweight %d %5f &" % (osd, new_weight)
  if VERBOSE: print cmd
  if really:
    os.system(cmd)
  else:
    print "add --really to run '%s'" % cmd

def reweight_by_utilization(options):
  if options.oload <= 100:
    raise Exception("You must give a percentage higher than 100.")


  cephinfo.init_pg()