#!/bin/bash
# 从集群中踢出一个节点

# usage:
#       HOST=HOSTNAME setsid ./kick

if [ -z "$SSH" ];then
    source /unas/sbin/dualcontroller/config/prepare
fi

if [ -z "$PCS" ];then
    PCS=pcs
fi

if [ -z "$HOST" ]; then
    exit 1
fi

# 不能删掉UNAS_Node_IP，解绑就行
if location_id=`$PCS constraint location show nodes "$HOST" --full | grep -Eo 'location-.*[^)]'`; then
    $PCS constraint location remove "$location_id"
fi

# 删掉IPMI
if $PCS stonith config "stonith-$HOST";then
    $PCS stonith delete "stonith-$HOST"
fi

# 踢掉node
/unas/sbin/dualcontroller/config/host rm
