infoblox 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -1
- data/infoblox.gemspec +1 -1
- data/lib/infoblox/resource.rb +15 -6
- data/lib/infoblox/resource/host.rb +2 -2
- data/lib/infoblox/resource/host_ipv4addr.rb +1 -9
- data/lib/infoblox/version.rb +1 -1
- data/spec/host_spec.rb +1 -1
- data/spec/resource_spec.rb +7 -0
- metadata +6 -7
- data/lib/infoblox/resource/ipv4addr.rb +0 -8
data/README.md
CHANGED
@@ -24,11 +24,17 @@ An instance of the `Infoblox::Connection` class is necessary:
|
|
24
24
|
connection = Infoblox::Connection.new(:username => '', :password => '', :host => '')
|
25
25
|
|
26
26
|
## Querying
|
27
|
-
Once a connection is made, one can use the resource class methods to query records
|
27
|
+
Once a connection is made, one can use the resource class methods to query records. You can use the `_max_results` and `_return_fields` parameters for both `find` and `all`. See the Infoblox WAPI documentation on how to use these parameters.
|
28
28
|
|
29
|
+
# Find all networks. Note that this is limited to 1000 objects, as per the
|
30
|
+
# Infoblox WAPI documentation.
|
29
31
|
Infoblox::Network.all(connection)
|
30
32
|
# => [...]
|
33
|
+
|
34
|
+
# Find the first 7890 hosts
|
35
|
+
Infoblox::Network.all(connection, :_max_results => 7890)
|
31
36
|
|
37
|
+
# Find hosts that match a regular expression
|
32
38
|
Infoblox::Host.find(connection, {"name~" => "demo[0-9]{1,}-web.domain"})
|
33
39
|
# => [...]
|
34
40
|
|
data/infoblox.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Billy Reisinger"]
|
10
10
|
spec.email = ["billy.reisinger@govdelivery.com"]
|
11
11
|
spec.description = %q{A Ruby wrapper to the Infoblox WAPI}
|
12
|
-
spec.summary = %q{This gem is a Ruby interface to the Infoblox WAPI.
|
12
|
+
spec.summary = %q{This gem is a Ruby interface to the Infoblox WAPI. Using the gem, you can query, create, update, and delete DNS records in your Infoblox instance.}
|
13
13
|
spec.homepage = "https://github.com/govdelivery/infoblox"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/lib/infoblox/resource.rb
CHANGED
@@ -64,22 +64,31 @@ module Infoblox
|
|
64
64
|
end
|
65
65
|
|
66
66
|
##
|
67
|
-
# Return an array of all records for this resource.
|
67
|
+
# Return an array of all records for this resource. You can use the default parameters
|
68
|
+
# _max_results an/or _return_fields as documented by Infoblox.
|
69
|
+
#
|
70
|
+
# Example: return only 70 results
|
71
|
+
# {"_max_results" => 70}
|
72
|
+
#
|
73
|
+
# Example: return only 100 results, throw an error if there are more
|
74
|
+
# {"_max_results" => -100}
|
68
75
|
#
|
69
|
-
def self.all(connection)
|
70
|
-
|
76
|
+
def self.all(connection, params = {})
|
77
|
+
params = default_params.merge(params)
|
78
|
+
JSON.parse(connection.get(resource_uri, params).body).map do |item|
|
71
79
|
new(item.merge({:connection => connection}))
|
72
80
|
end
|
73
81
|
end
|
74
82
|
|
75
83
|
##
|
76
|
-
# Find resources with query parameters.
|
84
|
+
# Find resources with query parameters. You can use the default parameters
|
85
|
+
# _max_results an/or _return_fields as documented by Infoblox.
|
77
86
|
#
|
78
87
|
# Example: return extensible attributes for every resource.
|
79
88
|
# {"_return_fields" => "extensible_attributes"}
|
80
89
|
#
|
81
|
-
# Example: filter resources by name
|
82
|
-
# {"name~" => "foo.*bar"}
|
90
|
+
# Example: filter resources by name, return 692 results or less
|
91
|
+
# {"name~" => "foo.*bar", "_max_results" => 692}
|
83
92
|
#
|
84
93
|
def self.find(connection, params)
|
85
94
|
params = default_params.merge(params)
|
@@ -7,12 +7,12 @@ module Infoblox
|
|
7
7
|
|
8
8
|
def ipv4addrs=(attrs=[])
|
9
9
|
attrs.each do |att|
|
10
|
-
ipv4addrs <<
|
10
|
+
ipv4addrs << HostIpv4addr.new(att)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def add_ipv4addr(address)
|
15
|
-
ipv4addrs <<
|
15
|
+
ipv4addrs << HostIpv4addr.new(:ipv4addr => address)
|
16
16
|
end
|
17
17
|
|
18
18
|
def ipv4addrs
|
@@ -1,17 +1,9 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class HostIpv4addr < Resource
|
3
|
-
remote_attr_accessor :network, :host, :ipv4addr
|
3
|
+
remote_attr_accessor :network, :host, :ipv4addr, :configure_for_dhcp
|
4
4
|
|
5
5
|
wapi_object "record:host_ipv4addr"
|
6
6
|
|
7
|
-
def post
|
8
|
-
raise "Not supported"
|
9
|
-
end
|
10
|
-
|
11
|
-
def put
|
12
|
-
raise "Not supported"
|
13
|
-
end
|
14
|
-
|
15
7
|
def delete
|
16
8
|
raise "Not supported"
|
17
9
|
end
|
data/lib/infoblox/version.rb
CHANGED
data/spec/host_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe Infoblox::Host, "#add_ipv4addr" do
|
|
5
5
|
host = Infoblox::Host.new
|
6
6
|
host.add_ipv4addr("10.10.10.10")
|
7
7
|
host.add_ipv4addr("10.10.10.12")
|
8
|
-
host.ipv4addrs[0].should be_a(Infoblox::
|
8
|
+
host.ipv4addrs[0].should be_a(Infoblox::HostIpv4addr)
|
9
9
|
host.ipv4addrs[0].ipv4addr.should eq("10.10.10.10")
|
10
10
|
end
|
11
11
|
|
data/spec/resource_spec.rb
CHANGED
@@ -35,6 +35,13 @@ describe Infoblox::Resource, "#add_ipv4addr" do
|
|
35
35
|
FooResource.all(conn).should eq([])
|
36
36
|
end
|
37
37
|
|
38
|
+
it "should allow .all with return fields or max results" do
|
39
|
+
conn = double
|
40
|
+
uri = Infoblox::BASE_PATH + "foo:animal"
|
41
|
+
allow(conn).to receive(:get).with(uri, {:_return_fields => "name,junction", :_max_results => -70}).and_return(FooResponse.new("[]"))
|
42
|
+
FooResource.all(conn, :_max_results => -70).should eq([])
|
43
|
+
end
|
44
|
+
|
38
45
|
it "should put with the right attributes" do
|
39
46
|
conn = double
|
40
47
|
uri = Infoblox::BASE_PATH + "abcd"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infoblox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -128,7 +128,6 @@ files:
|
|
128
128
|
- lib/infoblox/resource/cname.rb
|
129
129
|
- lib/infoblox/resource/host.rb
|
130
130
|
- lib/infoblox/resource/host_ipv4addr.rb
|
131
|
-
- lib/infoblox/resource/ipv4addr.rb
|
132
131
|
- lib/infoblox/resource/mx.rb
|
133
132
|
- lib/infoblox/resource/network.rb
|
134
133
|
- lib/infoblox/resource/network_container.rb
|
@@ -157,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
156
|
version: '0'
|
158
157
|
segments:
|
159
158
|
- 0
|
160
|
-
hash:
|
159
|
+
hash: 3893532931780741839
|
161
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
161
|
none: false
|
163
162
|
requirements:
|
@@ -166,14 +165,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
165
|
version: '0'
|
167
166
|
segments:
|
168
167
|
- 0
|
169
|
-
hash:
|
168
|
+
hash: 3893532931780741839
|
170
169
|
requirements: []
|
171
170
|
rubyforge_project:
|
172
171
|
rubygems_version: 1.8.24
|
173
172
|
signing_key:
|
174
173
|
specification_version: 3
|
175
|
-
summary: This gem is a Ruby interface to the Infoblox WAPI.
|
176
|
-
|
174
|
+
summary: This gem is a Ruby interface to the Infoblox WAPI. Using the gem, you can
|
175
|
+
query, create, update, and delete DNS records in your Infoblox instance.
|
177
176
|
test_files:
|
178
177
|
- spec/connection_spec.rb
|
179
178
|
- spec/host_spec.rb
|