Closed jbpadgett closed 10 years ago
Hi, What you are seeing is an instance of an Infoblox::Host object:
#<Infoblox::Host:0x007fdff2898e18>
The hexadecimal number is the object_id of the object. Every object in Ruby has a unique object_id (see this documentation). During an interactive (IRB) session, you will see this as a return value in the console (but generally you won't work with these in a script directly).
This library is designed to consume JSON from the Infoblox API and hide it from you by presenting you with a clean Ruby interface. For example, with the response from your search above, you can call methods on each instance in the collection:
require 'yaml'
require 'infoblox'
connection = Infoblox::Connection.new(YAML.load_file("./config.yml"))
hsearch = Infoblox::Host.find(connection, {"name~" => "stg-"})
hsearch.each do |host|
ips = host.ipv4addrs.map(&:ipv4addr).join(",")
puts "#{host.name} => #{ips}"
end
This will print something like:
stg-server1.net => 192.168.1.2
stg-server2.net => 192.168.1.3
There are several methods on the host object, including name
and an array of host_ipv4addr
objects
Thanks for the friendly response to my now in retrospect noob-ish question :)
No problem!
Hi there. First off thanks for writing this gem. I'm trying to use it and am able to successfully search for host records, but I need a little help on returned data. Every time I execute something like this: hsearch = Infoblox::Host.find(IpamConnection.myconnection, {"name~" => @find_object}) puts hsearch I only get responses like this:
Infoblox::Host:0x007f996395b290
The value changes each time I execute it too. Is this the infoblox object reference? or am I just getting back a random value for my connection? Ultimately what I was hoping for was a pretty json style response data like if I did the find in a curl operation, but I'm not sure if the gem does that as best I can tell. Any guidance from your experience? Thanks so much.