[one-users] listing images and its vms
João Pagaime
joao.pagaime at gmail.com
Wed Feb 5 00:44:38 PST 2014
Hello all
I'm trying to put together a very simple ruby script that outputs
opennebula's images and its vms
as far as listing opennebula's images, everything is fine, but I get an
error when trying, for each image, to lists its vms
acording to the 4.2 API documentation the image class should have a
"vms" list/array member, but I get an error when I try to instantiate that
where's the script. The offending statement in red. Any help would be
appreciated
thanks
joão
-------------------------- (snatched from openneb examples and then
adapted...)
#!/usr/bin/env ruby
##############################################################################
# Environment Configuration
##############################################################################
ONE_LOCATION=ENV["ONE_LOCATION"]
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
end
$: << RUBY_LIB_LOCATION
##############################################################################
# Required libraries
##############################################################################
require 'opennebula'
include OpenNebula
# OpenNebula credentials
CREDENTIALS = "oneadmin:(REMOVED)"
# XML_RPC endpoint where OpenNebula is listening
ENDPOINT ="http://localhost:2633/RPC2"
client = Client.new(CREDENTIALS, ENDPOINT)
img_pool = ImagePool.new(client, -1)
rc2 = img_pool.info
if OpenNebula.is_error?(rc2)
puts rc2.message
exit -1
end
img_pool.each do|img|
puts "img id=#{img.id},#{img.name}"
img.vms.each do|vm|
end
end
---------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20140205/a7dcd5b2/attachment-0002.htm>
More information about the Users
mailing list