#!/bin/sh

# This reset the IPMI password age of Lenovo servers
# avoiding that IPMI fails because password is expired.

set -e

if ! [ -x /usr/bin/ocicli ] ; then
	exit 0
fi

if ! [ -x /usr/bin/q ] ; then
	exit 0
fi

for i in $(ocicli -csv machine-list -h | q -H -d, "SELECT hostname FROM - WHERE system_manufacturer='Lenovo'") ; do
	ssh -x -o ConnectTimeout=5 -i /etc/openstack-cluster-installer/id_rsa root@$i 'onecli config set IMM.PasswordAge 365 >/dev/null 2>/dev/null'
done

exit 0
