Sha256: bfa317c33192c86eac67ede699d7e5c23189310f6154741b4ddbbe7682979595
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
#!/usr/bin/env ruby require 'rubygems' require 'esx' require 'terminal-table/import' host_addr = ARGV[0] if host_addr.nil? $stderr.puts 'Usage: esx HOST' exit 1 end print "Username: " user = $stdin.gets.strip.chomp system "stty -echo" print "Password: " pass = $stdin.gets.strip.chomp system "stty echo" puts begin host = ESX::Host.connect(host_addr, user, pass) puts name = host.name.upcase puts "*" * name.size puts name puts "*" * name.size puts "Memory Size: %s" % host.memory_size.bytes.to.megabytes.to_i puts "Memory Usage: %s" % host.memory_usage.bytes.to.megabytes.to_i puts "Cpu Cores: %s" % host.cpu_cores puts "Power State: %s" % host.power_state puts "\nVirtual Machines:" user_table = table do |t| t.headings = "NAME","MEMORY","CPUS","NICS","DISKS" host.virtual_machines.each do |vm| t << [vm.name,vm.memory_size.bytes.to.megabytes.to_i, vm.cpus, vm.ethernet_cards_number, vm.virtual_disks_number] end end puts user_table puts "\nDatastores:" user_table = table do |t| t.headings = "NAME","CAPACITY","FREESPACE","ACCESIBLE","TYPE","URL" host.datastores.each do |ds| dsname = ds.name if dsname.size > 20 dsname = dsname[0..19] + '...' end t << [dsname,ds.capacity, ds.free_space, ds.datastore_type, ds.accessible, ds.url] end end puts user_table puts rescue Exception => e puts "Error connecting to the ESX host" puts "\n#{e.message}" puts e.backtrace end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
esx-0.1.1 | bin/esx |
esx-0.1 | bin/esx |