Reputation: 11
I'm using this code repo for registering newly provisioned vm's with infoblox providing the next available ip address.
What i want to achieve now, is to get also dynamically the domain-name of the used infoblox network.
I tried to copy list_infoblox_networks.rb into a modified "list_infoblox_domain.rb" with the following code below:
if networks_array.blank?
# get an array of networks from infoblox
network_search_filter = "network?network_view=#{network_view}"
# specify fields to return in payload
return_fields = "&_return_fields=network_view,network,netmask,ipv4addr,extattrs,comment,options"
networks_array = call_infoblox(:get, "#{network_search_filter}" + "#{return_fields}")
$evm.log(:info, "Inspecting networks_array: #{networks_array.inspect}")
networks_array.each do |net|
comment = "#{net['comment']}@" if net['comment']
display_string = "#{comment}#{net['options'][0]},#{net['network_view']}"
dialog_hash[net['options'][0]] = display_string
end
end
The expected result should return:
testlab.local from network 192.168.254.0/24, actual result displays the whole hash with all options. dropdown of available infoblox domains
A call to infoblox gives me the following hash back:
<AEMethod list_infoblox_domain> Inspecting networks_array: [{"_ref"=>"network/ZG5zLm5ldHdvcmskMTAuMC4yMC4wLzI0LzA:10.0.20.0/24/default", "comment"=>"test-netz", "extattrs"=>{}, "ipv4addr"=>"10.0.20.0", "netmask"=>24, "network"=>"10.0.20.0/24", "network_view"=>"default", "options"=>[{"name"=>"dhcp-lease-time", "num"=>51, "use_option"=>false, "value"=>"43200", "vendor_class"=>"DHCP"}]}, {"_ref"=>"network/ZG5zLm5ldHdvcmskMTAuMC4zMC4wLzI0LzA:10.0.30.0/24/default", "comment"=>"zweites test-netz", "extattrs"=>{}, "ipv4addr"=>"10.0.30.0", "netmask"=>24, "network"=>"10.0.30.0/24", "network_view"=>"default", "options"=>[{"name"=>"dhcp-lease-time", "num"=>51, "use_option"=>false, "value"=>"43200", "vendor_class"=>"DHCP"}]}, {"_ref"=>"network/ZG5zLm5ldHdvcmskMTkyLjE2OC4yNTQuMC8yNC8w:192.168.254.0/24/default", "comment"=>"prod netz", "extattrs"=>{}, "ipv4addr"=>"192.168.254.0", "netmask"=>24, "network"=>"192.168.254.0/24", "network_view"=>"default", "options"=>[{"name"=>"broadcast-address", "num"=>28, "use_option"=>true, "value"=>"192.168.254.255", "vendor_class"=>"DHCP"}, {"name"=>"dhcp-lease-time", "num"=>51, "use_option"=>false, "value"=>"43200", "vendor_class"=>"DHCP"}, {"name"=>"domain-name-servers", "num"=>6, "use_option"=>true, "value"=>"192.168.254.10", "vendor_class"=>"DHCP"}, {"name"=>"domain-name", "num"=>15, "use_option"=>true, "value"=>"testlab.local", "vendor_class"=>"DHCP"}, {"name"=>"routers", "num"=>3, "use_option"=>true, "value"=>"192.168.254.1", "vendor_class"=>"DHCP"}]}]
it would be great, if somebody could help me to get this flying!
Upvotes: 1
Views: 39