Added IP lookup functionality for /vm/hostname (#154)

This commit is contained in:
FOXX 2016-06-28 17:29:06 -05:00 committed by Rick Sherman
parent 19c4bfa34b
commit 4e2a1fb62c

View file

@ -459,6 +459,15 @@ module Vmpooler
result[params[:hostname]]['disk'] = rdata['disk'].split(':') result[params[:hostname]]['disk'] = rdata['disk'].split(':')
end end
# Look up IP address of the hostname
begin
ipAddress = TCPSocket.gethostbyname(params[:hostname])[3]
rescue
ipAddress = ""
end
result[params[:hostname]]['ip'] = ipAddress
if config['domain'] if config['domain']
result[params[:hostname]]['domain'] = config['domain'] result[params[:hostname]]['domain'] = config['domain']
end end