From fe666302366c0af4da843b04c2f8b62b29c2129a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 11 Sep 2012 11:15:54 -0400 Subject: Get all IP infor from /etc/hosts --- make-ad-vm.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/make-ad-vm.sh b/make-ad-vm.sh index 015b192..921d3b0 100755 --- a/make-ad-vm.sh +++ b/make-ad-vm.sh @@ -51,14 +51,8 @@ fi if [ -z "$VM_FQDN" ] ; then # try to get the ip addr from virsh - VM_IP=`$SUDOCMD virsh net-dumpxml default | grep "'"$VM_NAME"'"|sed "s/^.*ip='\([^']*\)'.*$/\1/"` - if [ -z "$VM_IP" ] ; then - echo Error: your machine $VM_NAME has no IP address in virsh net-dumpxml default - echo Please use virsh net-edit default to specify the IP address for $VM_NAME - echo or set VM_FQDN=full.host.domain in the environment - exit 1 - fi - VM_FQDN=`getent hosts $VM_IP|awk '{print $2}'` + VM_IP=`getent hosts $VM_NAME|awk '{print $1}'` + VM_FQDN=`getent hosts $VM_NAME|awk '{print $2}'` echo using hostname $VM_FQDN for $VM_NAME with IP address $VM_IP fi -- cgit