#!/bin/bash
# Default Values
source /usr/share/ceph-tools/_ct-common

help_msg () {
    printf """
usage: $0 [-h] $CT_HELP_DESCR OSDID OSDID ...

Description         Set a list of OSDs Down

Optional
$CT_HELP_MSG

Positional
  OSDID             List of OSDs

Example
  $0 $CT_HELP_EXAMPLE {1..10}
"""
}

ct_help_min $# 2
shift $(ct_help $@)
while [ $# -gt 4 ] ; do
    key="$1"
    case $key in
        *)
            echo "Arg not found : '$key'"
            ct_on_exit 1
    esac
done

echo "Set balancer Off"
ceph balancer off

$OSDLIST=$(systemctl list-units | grep ceph-osd |grep -e ".service    "| awk '{print $1}')
for i in $OSDLIST
do
  _ct_healthy_wait
  echo "Set osd.${i} IN"
  systemctl stop $i
  sleep 10
done

_ct_healthy_wait 0
echo "Set balancer On"
ceph balancer on

ct_on_exit 0