Giter Club home page Giter Club logo

infoblox's People

Contributors

ananace avatar ekohl avatar epssy avatar hedgesky avatar jerryu avatar kmullin avatar lzap avatar mjsommer avatar mkpullin avatar prabhu-das avatar rhysrhaven avatar sandlerr avatar sencha7 avatar sjoeboo avatar substars avatar tonynotto avatar unclebilly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

infoblox's Issues

NoMethodError: undefined method `post' for nil:NilClass

[20] pry(main)> h = Infoblox::Host.new(name: 'david.test.com', ipv4addrs: [{ ipv4addr: Infoblox::Network.find(c, 'network~' => ENV['IPAM_NETWORK']).first.next_available_ip}])
=> #<Infoblox::Host:0x007febcaa7e1e0
 @ipv4addrs=[#<Infoblox::HostIpv4addr:0x007febcaa7df88 @ipv4addr=["172.23.1.1"]>],
 @name="david.test.com">

[21] pry(main)> h.post
NoMethodError: undefined method `post' for nil:NilClass
from /Users/david/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/infoblox-2.0.0/lib/infoblox/resource.rb:132:in `post'

Not sure why I'm seeing this error, wonder if it's related to #31 ?

Data differences between Infoblox::Host.ipv4addrs and Infoblox::HostIpv4addr

Hi,
I'm trying to use the gem to integrate infoblox support into the foreman smart-proxy and I'm running into issues :)

irb(main):024:0> host1 = Infoblox::Host.find(connection, {"ipv4addr" => "192.168.1.105"} )
[#<Infoblox::Host:0x000000011374b8 @_ref="record:host/...:opsd005a.local.domain/default", @configure_for_dns=true, @extensible_attributes={}, @ipv4addrs=[#<Infoblox::HostIpv4addr:0x00000001137238 @_ref="record:host_ipv4addr/...:192.168.1.105/opsd005a.local.domain/default", @configure_for_dhcp=true, @host="opsd005a.local.domain", @ipv4addr="192.168.1.105", @mac="00:50:56:ad:39:2f">], @name="opsd005a.local.domain", @view="default", @connection=#<Infoblox::Connection:0x00000000845f58 @username="admin", @password="password", @host="https://infoblox.server", @logger=nil, @ssl_opts=nil, @adapter=:net_http, @connection=#<Faraday::Connection:0x00000000a07d78 @parallel_manager=nil, @headers={"Authorization"=>"Basic id", "User-Agent"=>"Faraday v0.9.1"}, @params={}, @options=#<Faraday::RequestOptions (empty)>, @ssl=#<Faraday::SSLOptions (empty)>, @default_parallel_manager=nil, @builder=#<Faraday::RackBuilder:0x00000000a073a0 @handlers=[FaradayMiddleware::EncodeJson, Faraday::Adapter::NetHttp], @app=#<FaradayMiddleware::EncodeJson:0x00000001068820 @app=#<Faraday::Adapter::NetHttp:0x00000001068898 @app=#<Proc:0x00000001068938@/opt/rh/ruby193/root/usr/local/share/gems/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:152 (lambda)>>>>, @url_prefix=#<URI::HTTPS:0x0000000116d1d0 URL:https://infoblox.server/>, @proxy=nil>>>]
irb(main):025:0> host1.first.ipv4addrs.inspect
=> "[#<Infoblox::HostIpv4addr:0x00000001137238 @_ref=\"record:host_ipv4addr/...:192.168.1.105/opsd005a.local.domain/default\", @configure_for_dhcp=true, @host=\"opsd005a.local.domain\", @ipv4addr=\"192.168.1.105\", @mac=\"00:50:56:ad:39:2f\">]"
irb(main):026:0> host2 = Infoblox::HostIpv4addr.find(connection, { "ipv4addr" => "192.168.1.105" })
=> [#<Infoblox::HostIpv4addr:0x00000001152d58 @_ref="record:host_ipv4addr/...:192.168.1.105/opsd005a.local.domain/default", @configure_for_dhcp=true, @ipv4addr="192.168.1.105", @mac="00:50:56:ad:39:2f", @network="192.168.1.0/21", @nextserver="10.160.14.83", @use_nextserver=true, @connection=#<Infoblox::Connection:0x00000000845f58 @username="admin", @password="password", @host="https://infoblox.server", @logger=nil, @ssl_opts=nil, @adapter=:net_http, @connection=#<Faraday::Connection:0x00000000a07d78 @parallel_manager=nil, @headers={"Authorization"=>"Basic id", "User-Agent"=>"Faraday v0.9.1"}, @params={}, @options=#<Faraday::RequestOptions (empty)>, @ssl=#<Faraday::SSLOptions (empty)>, @default_parallel_manager=nil, @builder=#<Faraday::RackBuilder:0x00000000a073a0 @handlers=[FaradayMiddleware::EncodeJson, Faraday::Adapter::NetHttp], @app=#<FaradayMiddleware::EncodeJson:0x00000001068820 @app=#<Faraday::Adapter::NetHttp:0x00000001068898 @app=#<Proc:0x00000001068938@/opt/rh/ruby193/root/usr/local/share/gems/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:152 (lambda)>>>>, @url_prefix=#<URI::HTTPS:0x0000000116d1d0 URL:https://infoblox.server/>, @proxy=nil>>>]
irb(main):027:0> host2.first.inspect
=> "#<Infoblox::HostIpv4addr:0x00000001152d58 @_ref=\"record:host_ipv4addr/...:192.168.1.105/opsd005a.local.domain/default\", @configure_for_dhcp=true, @ipv4addr=\"192.168.1.105\", @mac=\"00:50:56:ad:39:2f\", @network=\"192.168.1.0/21\", @nextserver=\"10.160.14.83\", @use_nextserver=true, @connection=#<Infoblox::Connection:0x00000000845f58 @username=\"admin\", @password=\"password\", @host=\"https://infoblox.server\", @logger=nil, @ssl_opts=nil, @adapter=:net_http, @connection=#<Faraday::Connection:0x00000000a07d78 @parallel_manager=nil, @headers={\"Authorization\"=>\"Basic id\", \"User-Agent\"=>\"Faraday v0.9.1\"}, @params={}, @options=#<Faraday::RequestOptions (empty)>, @ssl=#<Faraday::SSLOptions (empty)>, @default_parallel_manager=nil, @builder=#<Faraday::RackBuilder:0x00000000a073a0 @handlers=[FaradayMiddleware::EncodeJson, Faraday::Adapter::NetHttp], @app=#<FaradayMiddleware::EncodeJson:0x00000001068820 @app=#<Faraday::Adapter::NetHttp:0x00000001068898 @app=#<Proc:0x00000001068938@/opt/rh/ruby193/root/usr/local/share/gems/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:152 (lambda)>>>>, @url_prefix=#<URI::HTTPS:0x0000000116d1d0 URL:https://infoblox.server/>, @proxy=nil>>>"
irb(main):028:0> host1.first.ipv4addrs[0].nextserver
=> nil
irb(main):029:0> host2.first.nextserver
=> "192.168.1.83"

shouldn't those put out the same information? They are accessing the same wapi object if I understand it correctly:
record:host_ipv4addr/...:192.168.1.105/opsd005a.local.domain/default
record:host_ipv4addr/...:192.168.1.105/opsd005a.local.domain/default

and as a bonus question - I'm trying to access all objects that belong to a network.
Infoblox::HostIpv4addr.find(connection, { "network" => "10.160.152.0/21" }) is not working because network is not a searchable field, any suggestions for that? As a workaround I iterate over all ips in the network but thats taking way too long for my purposes :)

Any help would be appreciated.

Thanks for the gem :D

Greetings
Klaas

Relative URI problem

I get this error when trying to do the sample. Possibly having to do with moving this forward slash from here to here? Not really good at ruby so I don't know.

https://github.com/govdelivery/infoblox/blob/master/lib/infoblox.rb#L19
https://github.com/govdelivery/infoblox/blob/master/lib/infoblox/resource/network.rb#L8

[1] pry(main)> require 'infoblox'
=> true
[2] pry(main)> connection = Infoblox::Connection.new(:username => 'admin', :password => 'infoblox', :host => '172.12.34.56')
=> #<Infoblox::Connection:0x000000010ace30
 @host="172.12.34.56",
 @logger=nil,
 @password="infoblox",
 @ssl_opts=nil,
 @username="admin">
[3] pry(main)> network = Infoblox::Network.new(:connection => connection)
=> #<Infoblox::Network:0x00000000f3fde0
 @connection=
  #<Infoblox::Connection:0x000000010ace30
   @host="172.12.34.56",
   @logger=nil,
   @password="infoblox",
   @ssl_opts=nil,
   @username="admin">>
[4] pry(main)> network.network = "10.20.30.0/24"
=> "10.20.30.0/24"
[5] pry(main)> network.extensible_attributes = {"VLAN" => "my_vlan"}
=> {"VLAN"=>"my_vlan"}
[6] pry(main)> network.auto_create_reversezone = true
=> true
[7] pry(main)> network.post # true
URI::BadURIError: both URI are relative
from /usr/lib/ruby/1.9.1/uri/generic.rb:1202:in `rescue in merge'
[8] pry(main)> network.network = "10.20.31.0/24"
=> "10.20.31.0/24"
[9] pry(main)> network.put  # true
URI::BadURIError: both URI are relative
from /usr/lib/ruby/1.9.1/uri/generic.rb:1202:in `rescue in merge'
[10] pry(main)> quit

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

local gems

bundler (1.3.5)
coderay (1.1.0)
faraday (0.8.8)
faraday_middleware (0.9.0)
infoblox (0.2.1)
json (1.8.1)
method_source (0.8.2)
multipart-post (1.2.0)
net-http-persistent (2.8)
pry (0.9.12.4)
rdoc (4.1.0, 3.9.4)
slop (3.4.7)
thor (0.18.1)

Infoblox::Connection.new broken?

I'm having an issue where I try to list all networks and I get a 401. Here's a basic version:

connection = Infoblox::Connection.new(host: 'https://myhost.local', username: 'nope', password: 'nope', ssl_opts: {verify: false})
# this seems wrong, shouldn't the username and password be in here?
=> <Infoblox::Connection:70103408887440 @host="https://myhost.local">

network = Infoblox::Network.all(connection)

If I do that, I get:

content-length: "401"
content-type: "text/html; charset=iso-8859-1"
connection: "close"
Infoblox::Error: Error: 401 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorization Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
</body></html>

The part that seems off to me is that the connection object only returns the host, shouldn't it have the username and password as well?

Ruby 1.8.7 compatiblity

Hi :)
with the changes to get the gem compatible with ruby 1.8.7 I get the following error (both 1.9.3 and 1.8.7) when trying to use a connection

Faraday::ConnectionFailed: 403 "Forbidden"
        from /opt/rh/ruby193/root/usr/share/ruby/net/http.rb:2633:in `error!'
        from /opt/rh/ruby193/root/usr/share/ruby/net/http.rb:2642:in `value'
        from /opt/rh/ruby193/root/usr/share/ruby/net/http.rb:796:in `connect'
        from /opt/rh/ruby193/root/usr/share/ruby/net/http.rb:756:in `do_start'
        from /opt/rh/ruby193/root/usr/share/ruby/net/http.rb:745:in `start'
        from /opt/rh/ruby193/root/usr/share/ruby/net/http.rb:1285:in `request'
        from /opt/rh/ruby193/root/usr/share/ruby/net/http.rb:1027:in `get'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:80:in `perform_request'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:40:in `block in call'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:87:in `with_net_http_connection'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:32:in `call'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/faraday_middleware-0.9.1/lib/faraday_middleware/request/encode_json.rb:23:in `call'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:139:in `build_response'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/faraday-0.9.1/lib/faraday/connection.rb:377:in `run_request'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/faraday-0.9.1/lib/faraday/connection.rb:140:in `get'
        from /app/app/home/gemtest/.gem/ruby/1.9.1/gems/infoblox-0.4.0/lib/infoblox/connection.rb:17:in `block in get'
        from /app/app/home/gemtest/.gem/ruby/1.9.1/gems/infoblox-0.4.0/lib/infoblox/connection.rb:80:in `wrap'
        from /app/app/home/gemtest/.gem/ruby/1.9.1/gems/infoblox-0.4.0/lib/infoblox/connection.rb:16:in `get'
        from /app/app/home/gemtest/.gem/ruby/1.9.1/gems/infoblox-0.4.0/lib/infoblox/resource.rb:106:in `find'
        from (irb):5
        from /opt/rh/ruby193/root/usr/bin/irb:12:in `<main>'
Faraday::ConnectionFailed: 403 "Forbidden"
        from /usr/lib/ruby/1.8/net/http.rb:2105:in `error!'
        from /usr/lib/ruby/1.8/net/http.rb:2114:in `value'
        from /usr/lib/ruby/1.8/net/http.rb:584:in `connect'
        from /usr/lib/ruby/1.8/net/http.rb:553:in `do_start'
        from /usr/lib/ruby/1.8/net/http.rb:542:in `start'
        from /usr/lib/ruby/1.8/net/http.rb:1035:in `request'
        from /usr/lib/ruby/1.8/net/http.rb:772:in `get'
        from /usr/lib/ruby/gems/1.8/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:80:in `perform_request'
        from /usr/lib/ruby/gems/1.8/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:40:in `call'
        from /usr/lib/ruby/gems/1.8/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:87:in `with_net_http_connection'
        from /usr/lib/ruby/gems/1.8/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:32:in `call'
        from /usr/lib/ruby/gems/1.8/gems/faraday_middleware-0.9.1/lib/faraday_middleware/request/encode_json.rb:23:in `call'
        from /usr/lib/ruby/gems/1.8/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:139:in `build_response'
        from /usr/lib/ruby/gems/1.8/gems/faraday-0.9.1/lib/faraday/connection.rb:377:in `run_request'
        from /usr/lib/ruby/gems/1.8/gems/faraday-0.9.1/lib/faraday/connection.rb:140:in `get'
        from /usr/lib/ruby/gems/1.8/gems/infoblox-0.4.0/lib/infoblox/connection.rb:17:in `get'
        from /usr/lib/ruby/gems/1.8/gems/infoblox-0.4.0/lib/infoblox/connection.rb:80:in `wrap'
        from /usr/lib/ruby/gems/1.8/gems/infoblox-0.4.0/lib/infoblox/connection.rb:16:in `get'
        from /usr/lib/ruby/gems/1.8/gems/infoblox-0.4.0/lib/infoblox/resource.rb:106:in `find'
        from (irb):8
        from :0

It works with the old version :)

Subclass Exception rather than Exception.new?

Hi,

Thanks for writing this, it's way more pleasant to use than the perl wrapper I was using earlier. I had a specific question about the way you're using the Exception class as a wrapper inside connection.rb. Specifically, you're looking for "unless response.status < 300" or calling Exception.new("stuff"). The issue I'm having is that to catch the event "I asked for a new IP and there's none left in that subnet" I have to rescue Exception => e, which seems to be strongly discouraged.

What I think should be happening is a custom class that extends Exception, such that I can then rescue just the case of "response.status < 300" or whatever the actual rest raised issue was.

Does that seem reasonable? I can make an attempt at writing it if you think I'm not talking nonsense.

Thanks again.

Unknown argument/field: 'ipv6addr'

When doing a ptr find request, infoblox seems to think that ipv6addr is not a proper return field. Doing a plain GET request from a browser and searching by ipv6addr (https://infoblox.domain.com/wapi/v2.2/record:ptr?ipv6addr) returns "Invalid value" but doing any find request with this gem returns an invalid field.

irb(main):004:0> Infoblox::Ptr.find(connection, {ipv4addr: "10.228.88.114"}).first
{:_return_fields=>"comment,disable,ipv4addr,ipv6addr,name,ptrdname,extensible_attributes,view,zone", :ipv4addr=>"10.228.88.114"}
Infoblox::Error: Error: 400 { "Error": "AdmConProtoError: Unknown argument/field: 'ipv6addr'",
  "code": "Client.Ibap.Proto",
  "text": "Unknown argument/field: 'ipv6addr'"
}
        from /var/lib/gems/1.9.1/gems/infoblox-0.5.0/lib/infoblox/connection.rb:92:in `block in wrap'
        from /var/lib/gems/1.9.1/gems/infoblox-0.5.0/lib/infoblox/connection.rb:90:in `tap'
        from /var/lib/gems/1.9.1/gems/infoblox-0.5.0/lib/infoblox/connection.rb:90:in `wrap'
        from /var/lib/gems/1.9.1/gems/infoblox-0.5.0/lib/infoblox/connection.rb:16:in `get'
        from /var/lib/gems/1.9.1/gems/infoblox-0.5.0/lib/infoblox/resource.rb:110:in `find'
        from (irb):4
        from /usr/bin/irb:12:in `<main>'

When changing the resource/ptr.rb to not request ipv6addr the problem doesn't occur and the request returns properly.

Infoblox documentation states that this field does indeed exist

edit: Putting more debugging output, I see that I'm using version 1.0 of the api with this gem (hadn't found how to change the version on demand until I read the lib/infoblox.rb source). The point of this issue would be that this gem is requesting ipv6addr in ptr requests for api levels under 1.2 which is not supported as per the documentation.

Problems posting A record with view

This is what we did to fix the problem on our end. Otherwise we hit errors.

On some record types, the Infoblox API documentation says that view
can not be updated, but the Infoblox gem defines them as remote_attr_accessor
attributes, which are sent in both POST and PUT requests. Shuffle
that around.

https://ipam.illinois.edu/wapidoc/objects/record.a.html
Infoblox::Arecord.remote_attrs.delete(:view)
Infoblox::Arecord.remote_post_attrs.push(:view)

SSL verification is hard-coded to false

In line 54 of connection.rb, SSL verification is permanently disabled:

    def connection
      @connection ||= Faraday.new(:url => self.host, :ssl => {:verify => false}) do |faraday|
        faraday.use Faraday::Response::Logger, logger if logger
        faraday.request :json
        faraday.basic_auth(self.username, self.password)
        faraday.adapter(self.adapter, &self.adapter_block)
      end
    end

SSL should be verified unless the user explicitly disables it. There's an ssl_opts variable that's set during initialization, but it appears to never be used anywhere in this gem. This would be a good place to store the user's SSL verification setting to later be read in the connection method.

Error 400 "Invalid value for ipv6addr" received from Infoblox when updating ipv4 ptr record

Great gem, I have tried several features and they are working fine, but I have found one that is not working as expected.
It is the update for a PTR record:

connection = Infoblox::Connection.new(username: 'user', password: 'password1', host: '10.1.1.1', ssl_opts: {verify: false}, timeout: 7)
ptr_record = Infoblox::Ptr.find(connection, {ptrdname:"fqdn_host_name.com", ipv4addr: "10.97.161.5"}).first
=> #<Infoblox::Ptr:0x000055b582cefe40
@_ref="record:ptr/ZG5zLmJpbmRfcHRyJC5fZGVmYXVsdC5hcnBhLmluLWFkZHIuMTAuOTcuMTYxLjUuZGUxYXN3OTg3MDJzLTUubmV0LnZvZGFmb25lLmNvbQ:5.161.97.10.in-addr.arpa/default",
@connection=#<Infoblox::Connection:23480 @host="https://10.1.1.1">,
@disable=false,
@extattrs={},
@ipv4addr="10.97.161.5",
@ipv6addr="",
@name="5.161.97.10.in-addr.arpa",
@ptrdname="fqdn_host_name.com",
@view="default",
@zone="161.97.10.in-addr.arpa">

ptr_record.ipv4addr = "10.97.161.6"

Error received:

pry(main)> ptr_record.put
Infoblox::Error: Error: 400 { "Error": "AdmConProtoError: Invalid value for ipv6addr: "": Invalid IPv6 address",
"code": "Client.Ibap.Proto",
"text": "Invalid value for ipv6addr: "": Invalid IPv6 address"
}

I do not understand why is showing error "Invalid value for ipv6addr" when I am actually updating an ipv4 address.

Fixedaddress name

Hey, I would've just submitted a PR for this but I'm not sure if I should fix the README or the classname

In the readme, the class for a fixed address is FixedAddress however the class name is actually Fixedaddress

From this repo's history it looks like that has always been the case, but every other class name is CamelCase.

Docs do not address how to close connection

Hello,

This gem is super. I'm able to easily create a-records, get ip addresses etc. Thank you!

One question not addressed by the docs is how to close the connection created when finished performing operations. Do I just use timeout?

returned data question

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.

Infoblox::Host put not working anymore

Hi :)
I'm going through the process of rechecking everything I need and I discoverd that putting a host object is not working anymore.

at HEAD
irb(main):003:0> Infoblox::VERSION
=> "0.4.0"
irb(main):004:0> connection = Infoblox::Connection.new(:username => 'admin', :password => 'password', :host => 'https://url')
irb(main):005:0> host = Infoblox::Host.find(connection, {"ipv4addr" => "192.168.0.1"}).first
irb(main):006:0> host.configure_for_dns = false
irb(main):007:0> host.put
NoMethodError: undefined method `remote_attribute_hash' for #<Hash:0x00000000ed50d0>
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/resource/host.rb:46:in `block (2 levels) in remote_attribute_hash'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/resource/host.rb:45:in `map'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/resource/host.rb:45:in `block in remote_attribute_hash'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/resource/host.rb:44:in `tap'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/resource/host.rb:44:in `remote_attribute_hash'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/resource.rb:146:in `put'
        from (irb):7
        from /opt/rh/ruby193/root/usr/bin/irb:12:in `<main>'

at 9e7dc1e90e2585ebccf3c44c7911cff76e354f6d
irb(main):003:0> Infoblox::VERSION
=> "0.3.2"
irb(main):004:0> connection = Infoblox::Connection.new(:username => 'admin', :password => 'password', :host => 'https://url')
irb(main):005:0> host = Infoblox::Host.find(connection, {"ipv4addr" => "192.168.0.1"}).first
irb(main):006:0> host.configure_for_dns = false
irb(main):007:0> host.put
Infoblox::Error: Error: 400 { "Error": "AdmConProtoError: Field is not writable: zone",
  "code": "Client.Ibap.Proto",
  "text": "Field is not writable: zone"
}
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/connection.rb:82:in `block in wrap'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/connection.rb:80:in `tap'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/connection.rb:80:in `wrap'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/connection.rb:31:in `put'
        from /opt/rh/ruby193/root/usr/local/share/gems/gems/infoblox-0.3.1/lib/infoblox/resource.rb:144:in `put'
        from (irb):7
        from /opt/rh/ruby193/root/usr/bin/irb:12:in `<main>'
irb(main):008:0>

before a6cce7cf8142ac9925b71c6a1a0c7027d7a5b72d
working

Thanks for all your work :)

PTR handling when ipv6addr field present is broken

I guess our Infoblox has ipv6 enabled and the Gem throws errors when looking for PTR records using ipv4 (which is used primarily).

test = Infoblox::Ptr.find(connection, {"ipv4addr" => "10.10.10.10"}).first
Infoblox::Error: Error: 400 { "Error": "AdmConProtoError: Unknown argument/field: 'ipv6addr'",
  "code": "Client.Ibap.Proto",
  "text": "Unknown argument/field: 'ipv6addr'"
}
    from /gems/infoblox-0.5.3/lib/infoblox/connection.rb:89:in `block in wrap'
    from /gems/infoblox-0.5.3/lib/infoblox/connection.rb:87:in `tap'
    from /gems/infoblox-0.5.3/lib/infoblox/connection.rb:87:in `wrap'
    from /gems/infoblox-0.5.3/lib/infoblox/connection.rb:16:in `get'
    from /gems/infoblox-0.5.3/lib/infoblox/resource.rb:110:in `find'
    from (irb):15
    from /ruby-2.3.1/bin/irb:11:in `<main>'

Not able to create ZoneAuth

When I tried to create ZoneAuth, it seems that the fqdn set for the ZoneAuth instance is not being passed into the post request:

1.9.3-p448 :001 > require 'infoblox'
 => true
1.9.3-p448 :002 > ENV["WAPI_VERSION"]='1.2'
 => "1.2"
1.9.3-p448 :003 > connection = Infoblox::Connection.new(username: 'username', password: 'password', host: 'host')
 => #<Infoblox::Connection:70211723145900 @host="host">
1.9.3-p448 :004 > zone_auth = Infoblox::ZoneAuth.new(:connection => connection)
 => #<Infoblox::ZoneAuth:0x007fb6e1a1c558 @connection=#<Infoblox::Connection:70211723145900 @host="host">>
1.9.3-p448 :005 > zone_auth.fqdn = 'zone1.com'
 => "zone1.com"
1.9.3-p448 :006 > zone_auth.post
Infoblox::Error: Error: 400 { "Error": "AdmConProtoError: field for create missing: fqdn",
  "code": "Client.Ibap.Proto",
  "text": "field for create missing: fqdn"
}

It would be greatly appreciated if you could take a look. Thank you for all the great work.

Help with next IP

Hi, I am trying to use this gem for some trivial integration and cannot get the next_available_ip to work. Here is my sample script;

require 'rubygems'
require 'infoblox'

info = Infoblox::Connection.new(:username => 'admin', :password => 'password', :host => 'https://10.10.1.72/wapi/v1.2.1')
netty = Infoblox::Network.find(info, {"network" => "192.168.0.0/24" })
puts netty.next_available_ip

this code fails with now method available.

I can add new hosts ok, I presume the way to add a host with next available address is to go and find out what the address is first then add that in on the v4ipaddr attribute for the new host, that you cannot specify on the adding of the new host to issue the next available IP during the add?

thanks

get on a resource doesn't populate all fields

Invoking .get on a resource that has been "instantiated" by it's _ref doesn't then populate all of the fields on that resource, for example:

host = Infoblox::Host.new(connection: conn, _ref: my_ref)
host.get
puts host.inspect

only gives you:

#<Infoblox::Host:0x007fa1943d7e70 @connection=#<Infoblox::Connection:70165976540980 @host="https://infoblox.corp.com">, @_ref="record:host/ZG5zLmhvc3QkLjEuY29tLmJsYWNrYm9hcmQuY2F0LWNvbmR1Y3Rvci10ZXN0LWhvc3Q:myhostname.exampke.com/my_view">

I would have expected to see name, ipv4addrs, etc, etc.

I have a need to store the _ref's in an external state tracking system and it would be preferable to retrieve existing records by their _ref rather than having to use find which could lead to duplicate or orphaned records in either system?

Latest changes after 0.3.2 breaking code while running a post request.

After creating a record object
record = Infoblox::Host.new(connection: connection, ipv4addrs: params[:ipv4addrs], name: params[:name])

It throws the below error when I do
record.post
ERROR: undefined method `remote_attribute_hash' for
{:ipv4addr=>"10.10.70.12", :mac=>nil}:Hash

It works if I revert to version 0.3.2. I guess something is breaking when the attr_readers/accessors are changed. Becoz I don't see any other major changes.
@unclebilly Can you please have a look at it.

Ptr class should have :ttl as an attribute

When I use this gem to reduce TTL for both A & PTR records in preparation for a pending change, I was surprised that :ttl is not listed as an attribute for Ptr class.

Since Infoblox is new to me, I am not sure whether this omission is by design. For my purpose, I added :ttl as a new attribute for Ptr class in my local clone and it worked fine.

I'll be more than happy to submit a pull request, if this omission was not by design.

not able to write on DDI

Hello folks,

trying to modify a current IP from a host record, but not able too: can you help me clarify ?
already checked permissions.. the user querying API is a super user with full access to API and RW.

code i'm using:

!/usr/bin/env ruby

require 'infoblox'
connection = Infoblox::Connection.new(:username => 'xxxx', :password => 'xxxxx', :host => 'ddi.XXXX.com')
host = Infoblox::Host.find(connection, {"name" => "lab1.YYY.XXX"}).first
print "Current IP: " + host.ipv4addrs[0].ipv4addr + "\n"
host.ipv4addrs[0].ipv4addr = "10.120.10.207"
print "New IP: " + host.ipv4addrs[0].ipv4addr + "\n"
host.post

debug output

$ ruby ddi.rb
Current IP: 10.120.10.203
New IP: 10.120.10.207
/usr/local/lib/ruby/gems/2.1.0/gems/infoblox-0.2.14/lib/infoblox/connection.rb:79:in block in wrap': Error: 400 { "Error": "AdmConProtoError: Field is not writable: host", (Exception) "code": "Client.Ibap.Proto", "text": "Field is not writable: host" } from /usr/local/lib/ruby/gems/2.1.0/gems/infoblox-0.2.14/lib/infoblox/connection.rb:77:intap'
from /usr/local/lib/ruby/gems/2.1.0/gems/infoblox-0.2.14/lib/infoblox/connection.rb:77:in wrap' from /usr/local/lib/ruby/gems/2.1.0/gems/infoblox-0.2.14/lib/infoblox/connection.rb:19:inpost'
from /usr/local/lib/ruby/gems/2.1.0/gems/infoblox-0.2.14/lib/infoblox/resource.rb:119:in post' from ddi.rb:9:in

'

Rails 5.1 compatibility

lib/infoblox/resource.rb line 110

connection.get(resource_uri, params) returns:

*** Faraday::SSLError Exception: SSL_connect returned=1 errno=0 state=error: certificate verify failed

with Rails 5.1 where previously this gem worked fine on Rails 5.0.1 . I'm still digging into whether or not it's actually a cert SSL issue on our end but nothing seems to be working with valid certs.

I'll also submit this to an issue on Rails since I'm not exactly sure where/why this is failing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.