#!/usr/bin/ruby

$: << '/usr/share/ovirt-server'
$: << '/usr/share/ovirt-server/dutils'

require 'dutils'

########################## retreive host from vm w/ specified name
$stdin.each{ |vmname| # get vm name from stdin
  begin
    vmname.chomp!  # remove the newline
    puts Vm.find(:first, :conditions => ['description = ?', vmname]).host.hostname
  rescue Exception => ex
    puts "Error looking node with VM: #{ex.class}: #{ex.message}"
    puts ex.backtrace
  end

  $stdout.flush
}
