#!/bin/bash

### TODO: implement a proper function in ymclibnettools instead of using 'gethostip'
#### Include ymclibnettools
#. /usr/lib/lib-fliwi/ymc-networktools.bash
#

host_to_look_up=$1
if [ $(echo $host_to_look_up | grep -c -E -e "\.") -eq 0 ]; then
  host_to_look_up=$host_to_look_up".cluster"
fi

found_ip=$(gethostip -d $host_to_look_up)
if [ $? -eq 0 ] && [ "$found_ip" != '' ]; then
  echo $found_ip
else
  exit 1
fi

exit 0
