infoblox 0.2.19 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/README.md +32 -5
- data/lib/infoblox.rb +16 -3
- data/lib/infoblox/resource.rb +4 -3
- data/lib/infoblox/resource/aaaa_record.rb +18 -0
- data/lib/infoblox/resource/arecord.rb +6 -2
- data/lib/infoblox/resource/cname.rb +6 -2
- data/lib/infoblox/resource/fixedaddress.rb +5 -1
- data/lib/infoblox/resource/host.rb +7 -2
- data/lib/infoblox/resource/host_ipv4addr.rb +5 -1
- data/lib/infoblox/resource/ipv4address.rb +15 -4
- data/lib/infoblox/resource/mx.rb +6 -2
- data/lib/infoblox/resource/network.rb +5 -2
- data/lib/infoblox/resource/network_container.rb +5 -2
- data/lib/infoblox/resource/ptr.rb +6 -2
- data/lib/infoblox/resource/range.rb +7 -3
- data/lib/infoblox/resource/srv.rb +8 -2
- data/lib/infoblox/resource/txt.rb +5 -2
- data/lib/infoblox/resource/zone_auth.rb +13 -0
- data/lib/infoblox/version.rb +1 -1
- data/spec/host_ipv4addr_spec.rb +2 -2
- data/spec/host_spec.rb +4 -4
- data/spec/integration/host_ipv4addr_spec.rb +12 -0
- data/spec/integration/host_spec.rb +12 -0
- data/spec/range_spec.rb +3 -3
- data/spec/resource_spec.rb +30 -16
- data/spec/search_spec.rb +4 -4
- data/spec/spec_helper.rb +31 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d05d7b804e52ac3352fc3275a46cc6364c553ce
|
4
|
+
data.tar.gz: e60fce009ae4356309ed8602e85bbe247359688a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 769131525ea8cd3e1892b01caf65120a9bc90c075b270e4e4ae054c035a19c8254c24eb9285096dfe0e011fdd82f56697f0578489dff8aa1482d6d2578411d73
|
7
|
+
data.tar.gz: 41e111dc76565a112eb6d9954eeb24260854a59c3a48f0f9bca792ea0b3365d21130198d42f556518c89599c9580f25f6a38e694a55a7cf2f21f466c278dd461
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -66,6 +66,7 @@ The resource class instances implement `get`, `post`, `put`, and `delete` method
|
|
66
66
|
|
67
67
|
This pattern applies for interacting with every resource. Supported resources include:
|
68
68
|
|
69
|
+
Infoblox::AAAArecord
|
69
70
|
Infoblox::Arecord
|
70
71
|
Infoblox::Cname
|
71
72
|
Infoblox::FixedAddress
|
@@ -76,11 +77,13 @@ This pattern applies for interacting with every resource. Supported resources i
|
|
76
77
|
Infoblox::Network
|
77
78
|
Infoblox::NetworkContainer
|
78
79
|
Infoblox::Ptr
|
80
|
+
Infoblox::Range
|
79
81
|
Infoblox::Search
|
80
82
|
Infoblox::Srv
|
81
83
|
Infoblox::Txt
|
84
|
+
Infoblox::ZoneAuth
|
82
85
|
|
83
|
-
The specific attributes supported by each resource are listed in the source code.
|
86
|
+
The specific attributes supported by each resource are listed in the source code. Adding a new resource class is easy, and pull requests are encouraged.
|
84
87
|
|
85
88
|
## Changing IP on an existing host
|
86
89
|
To change the IP of an existing host, you have to poke around in the ipv4addrs collection to find the one you are looking for. The example below assumes that there is only one ipv4 address and just overwrites it.
|
@@ -144,15 +147,39 @@ Delete:
|
|
144
147
|
|
145
148
|
## Next Available IP
|
146
149
|
|
147
|
-
The `Infoblox::Network`
|
150
|
+
The `Infoblox::Network` and `Infoblox::Range` objects support the `next_available_ip` WAPI function:
|
148
151
|
|
149
|
-
network
|
150
|
-
|
152
|
+
network = Infoblox::Network.find(connection,
|
153
|
+
network: '10.21.0.0/24').first
|
151
154
|
puts network.next_available_ip.inspect
|
152
155
|
#=> ["10.21.0.22"]
|
153
156
|
|
154
|
-
Note that this function does not work on a
|
157
|
+
Note that this function does not work on a resource that has not been created. In other words, if you want to get the next available IP for a given network segment, you have to create that segment beforehand. See the CRUD examples above.
|
155
158
|
|
159
|
+
## Infoblox Version Compatibility
|
160
|
+
|
161
|
+
This gem is known to be compatible with Infoblox versions 1.0 through 2.0. While Infoblox claims that their API is backwards-compatible, one caveat remains with the Extensible Attributes (see elsewhere in this document). Some features are only available in newer versions (such as FixedAddress and AAAARecord). To set your version, use the `WAPI_VERSION` environment variable. For example:
|
162
|
+
|
163
|
+
WAPI_VERSION=2.0 ruby my_script.rb
|
164
|
+
|
165
|
+
## Extensible Attributes
|
166
|
+
|
167
|
+
Extensible attributes are supported in this client. It should be noted that in WAPI versions before 1.2, the field is named "extensible_attributes", whereas in version 1.2 and later, it is named "extattrs".
|
168
|
+
|
169
|
+
## Development / testing
|
170
|
+
|
171
|
+
First, clone and bundle:
|
172
|
+
|
173
|
+
bundle install
|
174
|
+
|
175
|
+
To run the tests:
|
176
|
+
|
177
|
+
rspec
|
178
|
+
|
179
|
+
To run the integration tests (you will be prompted for your Infoblox credentials):
|
180
|
+
|
181
|
+
INTEGRATION=true rspec
|
182
|
+
|
156
183
|
## Contributing
|
157
184
|
|
158
185
|
1. Fork it
|
data/lib/infoblox.rb
CHANGED
@@ -13,7 +13,20 @@ Dir[File.expand_path('../infoblox/resource/*.rb', __FILE__)].each do |f|
|
|
13
13
|
end
|
14
14
|
|
15
15
|
module Infoblox
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
DEBUG = ENV['DEBUG']
|
17
|
+
|
18
|
+
def wapi_version
|
19
|
+
@wapi_version ||= (ENV['WAPI_VERSION'] || '1.0')
|
20
|
+
end
|
21
|
+
module_function :wapi_version
|
22
|
+
|
23
|
+
def wapi_version=(v)
|
24
|
+
@wapi_version = v
|
25
|
+
end
|
26
|
+
module_function :wapi_version=
|
27
|
+
|
28
|
+
def base_path
|
29
|
+
'/wapi/v' + Infoblox.wapi_version + '/'
|
30
|
+
end
|
31
|
+
module_function :base_path
|
19
32
|
end
|
data/lib/infoblox/resource.rb
CHANGED
@@ -56,7 +56,8 @@ module Infoblox
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def self._return_fields
|
59
|
-
|
59
|
+
remove = Infoblox.wapi_version < '1.2' ? :extattrs : :extensible_attributes
|
60
|
+
(self.remote_attrs - [remove]).join(",")
|
60
61
|
end
|
61
62
|
|
62
63
|
def self.default_params
|
@@ -98,7 +99,7 @@ module Infoblox
|
|
98
99
|
end
|
99
100
|
|
100
101
|
def self.resource_uri
|
101
|
-
|
102
|
+
Infoblox.base_path + self.wapi_object
|
102
103
|
end
|
103
104
|
|
104
105
|
##
|
@@ -135,7 +136,7 @@ module Infoblox
|
|
135
136
|
end
|
136
137
|
|
137
138
|
def resource_uri
|
138
|
-
self._ref.nil? ? self.class.resource_uri : (
|
139
|
+
self._ref.nil? ? self.class.resource_uri : (Infoblox.base_path + self._ref)
|
139
140
|
end
|
140
141
|
|
141
142
|
def remote_attribute_hash(write=false, post=false)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# An AAAA (address) record maps a domain name to an IPv6 address.
|
2
|
+
module Infoblox
|
3
|
+
class AAAArecord < Resource
|
4
|
+
remote_attr_accessor :comment,
|
5
|
+
:disable,
|
6
|
+
:dns_name,
|
7
|
+
:extattrs,
|
8
|
+
:extensible_attributes,
|
9
|
+
:ipv6addr,
|
10
|
+
:name,
|
11
|
+
:ttl,
|
12
|
+
:use_ttl,
|
13
|
+
:view,
|
14
|
+
:zone
|
15
|
+
|
16
|
+
wapi_object "record:aaaa"
|
17
|
+
end
|
18
|
+
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class Cname < Resource
|
3
|
-
remote_attr_accessor :
|
4
|
-
:
|
3
|
+
remote_attr_accessor :canonical,
|
4
|
+
:comment,
|
5
|
+
:extattrs,
|
6
|
+
:extensible_attributes,
|
7
|
+
:name,
|
8
|
+
:view
|
5
9
|
|
6
10
|
wapi_object "record:cname"
|
7
11
|
end
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class Host < Resource
|
3
|
-
remote_attr_accessor :
|
4
|
-
:extensible_attributes,
|
3
|
+
remote_attr_accessor :extattrs,
|
4
|
+
:extensible_attributes,
|
5
|
+
:view,
|
6
|
+
:aliases,
|
7
|
+
:configure_for_dns,
|
8
|
+
:ipv4addrs,
|
9
|
+
:name
|
5
10
|
|
6
11
|
wapi_object "record:host"
|
7
12
|
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class HostIpv4addr < Resource
|
3
|
-
remote_attr_accessor :
|
3
|
+
remote_attr_accessor :configure_for_dhcp,
|
4
|
+
:ipv4addr,
|
5
|
+
:mac,
|
6
|
+
:network
|
7
|
+
|
4
8
|
remote_post_accessor :host
|
5
9
|
|
6
10
|
wapi_object "record:host_ipv4addr"
|
@@ -1,8 +1,17 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class Ipv4address < Resource
|
3
|
-
attr_accessor :dhcp_client_identifier,
|
4
|
-
:
|
5
|
-
:
|
3
|
+
attr_accessor :dhcp_client_identifier,
|
4
|
+
:ip_address,
|
5
|
+
:is_conflict,
|
6
|
+
:lease_state,
|
7
|
+
:mac_address,
|
8
|
+
:names,
|
9
|
+
:network,
|
10
|
+
:network_view,
|
11
|
+
:objects,
|
12
|
+
:status,
|
13
|
+
:types,
|
14
|
+
:usage,
|
6
15
|
:username
|
7
16
|
|
8
17
|
wapi_object "ipv4address"
|
@@ -10,11 +19,13 @@ module Infoblox
|
|
10
19
|
def delete
|
11
20
|
raise "Not supported"
|
12
21
|
end
|
22
|
+
|
13
23
|
def create
|
14
24
|
raise "Not supported"
|
15
25
|
end
|
26
|
+
|
16
27
|
def modify
|
17
|
-
|
28
|
+
raise "Not supported"
|
18
29
|
end
|
19
30
|
end
|
20
31
|
end
|
data/lib/infoblox/resource/mx.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class Mx < Resource
|
3
|
-
remote_attr_accessor :
|
4
|
-
:extensible_attributes,
|
3
|
+
remote_attr_accessor :extattrs,
|
4
|
+
:extensible_attributes,
|
5
|
+
:mail_exchanger,
|
6
|
+
:name,
|
7
|
+
:preference,
|
8
|
+
:view
|
5
9
|
|
6
10
|
wapi_object "record:mx"
|
7
11
|
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class Network < Resource
|
3
|
-
remote_attr_accessor :
|
3
|
+
remote_attr_accessor :extattrs,
|
4
|
+
:extensible_attributes,
|
5
|
+
:network
|
6
|
+
|
4
7
|
remote_post_accessor :auto_create_reversezone
|
5
8
|
|
6
9
|
attr_accessor :network_view, :network_container
|
@@ -11,7 +14,7 @@ module Infoblox
|
|
11
14
|
# Invoke the same-named function on the network resource in WAPI,
|
12
15
|
# returning an array of available IP addresses.
|
13
16
|
# You may optionally specify how many IPs you want (num) and which ones to
|
14
|
-
# exclude from consideration (array of IPv4
|
17
|
+
# exclude from consideration (array of IPv4 address strings).
|
15
18
|
#
|
16
19
|
def next_available_ip(num=1, exclude=[])
|
17
20
|
post_body = {
|
@@ -1,10 +1,13 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class NetworkContainer < Resource
|
3
|
-
remote_attr_accessor :
|
3
|
+
remote_attr_accessor :extattrs,
|
4
|
+
:extensible_attributes,
|
5
|
+
:network
|
6
|
+
|
4
7
|
remote_post_accessor :auto_create_reversezone
|
5
8
|
|
6
9
|
attr_accessor :network_view
|
7
10
|
|
8
11
|
wapi_object "networkcontainer"
|
9
12
|
end
|
10
|
-
end
|
13
|
+
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class Ptr < Resource
|
3
|
-
remote_attr_accessor :
|
4
|
-
:extensible_attributes,
|
3
|
+
remote_attr_accessor :extattrs,
|
4
|
+
:extensible_attributes,
|
5
|
+
:view,
|
6
|
+
:ipv4addr,
|
7
|
+
:name,
|
8
|
+
:ptrdname
|
5
9
|
|
6
10
|
wapi_object "record:ptr"
|
7
11
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class Range < Resource
|
3
|
-
remote_attr_accessor :
|
3
|
+
remote_attr_accessor :end_addr,
|
4
|
+
:extattrs,
|
5
|
+
:extensible_attributes,
|
6
|
+
:network_view,
|
7
|
+
:start_addr
|
4
8
|
|
5
9
|
wapi_object "range"
|
6
10
|
|
@@ -8,7 +12,7 @@ module Infoblox
|
|
8
12
|
# Invoke the same-named function on the range resource in WAPI,
|
9
13
|
# returning an array of available IP addresses.
|
10
14
|
# You may optionally specify how many IPs you want (num) and which ones to
|
11
|
-
# exclude from consideration (array of IPv4
|
15
|
+
# exclude from consideration (array of IPv4 address strings).
|
12
16
|
#
|
13
17
|
def next_available_ip(num=1, exclude=[])
|
14
18
|
post_body = {
|
@@ -19,4 +23,4 @@ module Infoblox
|
|
19
23
|
end
|
20
24
|
|
21
25
|
end
|
22
|
-
end
|
26
|
+
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
module Infoblox
|
2
2
|
class Srv < Resource
|
3
|
-
remote_attr_accessor :
|
4
|
-
:extensible_attributes,
|
3
|
+
remote_attr_accessor :extattrs,
|
4
|
+
:extensible_attributes,
|
5
|
+
:name,
|
6
|
+
:port,
|
7
|
+
:priority,
|
8
|
+
:target,
|
9
|
+
:view,
|
10
|
+
:weight
|
5
11
|
|
6
12
|
wapi_object "record:srv"
|
7
13
|
end
|
data/lib/infoblox/version.rb
CHANGED
data/spec/host_ipv4addr_spec.rb
CHANGED
@@ -5,8 +5,8 @@ describe Infoblox::HostIpv4addr do
|
|
5
5
|
expected = [:host]
|
6
6
|
expect(Infoblox::HostIpv4addr.remote_post_attrs).to eq(expected)
|
7
7
|
|
8
|
-
expected = [:network, :ipv4addr, :configure_for_dhcp, :mac]
|
9
|
-
expect(Infoblox::HostIpv4addr.remote_attrs).to eq(expected)
|
8
|
+
expected = [:network, :ipv4addr, :configure_for_dhcp, :mac].sort
|
9
|
+
expect(Infoblox::HostIpv4addr.remote_attrs.sort).to eq(expected)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
data/spec/host_spec.rb
CHANGED
@@ -5,13 +5,13 @@ 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].
|
9
|
-
host.ipv4addrs[0].ipv4addr.
|
8
|
+
expect(host.ipv4addrs[0]).to be_a(Infoblox::HostIpv4addr)
|
9
|
+
expect(host.ipv4addrs[0].ipv4addr).to eq("10.10.10.10")
|
10
10
|
end
|
11
11
|
|
12
12
|
it "posts correctly" do
|
13
13
|
conn = double
|
14
|
-
uri = Infoblox
|
14
|
+
uri = Infoblox.base_path + Infoblox::Host.wapi_object
|
15
15
|
|
16
16
|
allow(conn).to receive(:post).with(uri, {
|
17
17
|
:ipv4addrs => [{:ipv4addr => "10.10.10.10"},
|
@@ -25,7 +25,7 @@ describe Infoblox::Host, "#add_ipv4addr" do
|
|
25
25
|
h.ipv4addrs=([{:ipv4addr => "192.168.1.1", :mac => "109coic0932j3n0293urf"}])
|
26
26
|
h.name = "test-server.test.ing"
|
27
27
|
h.post
|
28
|
-
h._ref.
|
28
|
+
expect(h._ref).to eq("hey")
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
if ENV['INTEGRATION']
|
2
|
+
describe 'Infoblox::HostIpv4addr' do
|
3
|
+
describe '.find' do
|
4
|
+
it 'should work' do
|
5
|
+
each_version do
|
6
|
+
# the empty result will be [], so nil is bad.
|
7
|
+
expect(Infoblox::HostIpv4addr.find(connection, _max_results: 1)).to_not be_nil
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
if ENV['INTEGRATION']
|
2
|
+
describe 'Infoblox::Host' do
|
3
|
+
describe '.find' do
|
4
|
+
it 'should work' do
|
5
|
+
each_version do
|
6
|
+
# the empty result will be [], so nil is bad.
|
7
|
+
expect(Infoblox::Host.find(connection, _max_results: 1)).to_not be_nil
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/spec/range_spec.rb
CHANGED
@@ -5,7 +5,7 @@ RangeResponse = Struct.new(:body)
|
|
5
5
|
describe Infoblox::Host, "#next_available_ip" do
|
6
6
|
it "returns empty array when no IP is available." do
|
7
7
|
connection = double
|
8
|
-
uri = Infoblox
|
8
|
+
uri = Infoblox.base_path + Infoblox::Range.wapi_object
|
9
9
|
return_json = RangeResponse.new('{"ips": "[]"}')
|
10
10
|
allow(connection).to receive(:post).with(uri + "?_function=next_available_ip" , {:num=>1, :exclude=>[]}).and_return(return_json)
|
11
11
|
response = Infoblox::Range.new(:connection => connection)
|
@@ -14,7 +14,7 @@ describe Infoblox::Host, "#next_available_ip" do
|
|
14
14
|
|
15
15
|
it "gets next available ip from range" do
|
16
16
|
connection = double
|
17
|
-
uri = Infoblox
|
17
|
+
uri = Infoblox.base_path + Infoblox::Range.wapi_object
|
18
18
|
return_json = RangeResponse.new('
|
19
19
|
{
|
20
20
|
"ips": "[\"1.1.1.1\", \"1.1.1.2\"]"
|
@@ -24,4 +24,4 @@ describe Infoblox::Host, "#next_available_ip" do
|
|
24
24
|
expect(response.next_available_ip).to eq '["1.1.1.1", "1.1.1.2"]'
|
25
25
|
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
data/spec/resource_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
class FooResource < Infoblox::Resource
|
3
|
-
remote_attr_accessor :name, :junction
|
3
|
+
remote_attr_accessor :name, :junction, :extattrs, :extensible_attributes
|
4
4
|
remote_attr_writer :do_it
|
5
5
|
remote_post_accessor :sect
|
6
6
|
|
@@ -17,34 +17,48 @@ describe Infoblox::Resource, "#add_ipv4addr" do
|
|
17
17
|
host.animal = "mom"
|
18
18
|
host.name = "lol"
|
19
19
|
hsh = host.send(:remote_attribute_hash)
|
20
|
-
hsh.
|
20
|
+
expect(hsh).to eq({:name => 'lol'})
|
21
|
+
end
|
22
|
+
|
23
|
+
it "handles extattrs correctly in return fields" do
|
24
|
+
expect(Infoblox).to receive(:wapi_version).and_return("1.0")
|
25
|
+
hsh = FooResource._return_fields
|
26
|
+
expect(hsh).to eq('name,junction,extensible_attributes')
|
27
|
+
|
28
|
+
expect(Infoblox).to receive(:wapi_version).and_return("1.2")
|
29
|
+
hsh = FooResource._return_fields
|
30
|
+
expect(hsh).to eq('name,junction,extattrs')
|
31
|
+
|
32
|
+
expect(Infoblox).to receive(:wapi_version).and_return("2.0")
|
33
|
+
hsh = FooResource._return_fields
|
34
|
+
expect(hsh).to eq('name,junction,extattrs')
|
21
35
|
end
|
22
36
|
|
23
37
|
it "should have a correct resource_uri" do
|
24
|
-
FooResource.resource_uri.
|
38
|
+
expect(FooResource.resource_uri).to eq(Infoblox.base_path + "foo:animal")
|
25
39
|
f=FooResource.new
|
26
|
-
f.resource_uri.
|
40
|
+
expect(f.resource_uri).to eq(Infoblox.base_path + "foo:animal")
|
27
41
|
f._ref = "lkjlkj"
|
28
|
-
f.resource_uri.
|
42
|
+
expect(f.resource_uri).to eq(Infoblox.base_path + "lkjlkj")
|
29
43
|
end
|
30
44
|
|
31
45
|
it "should find with default attributes" do
|
32
46
|
conn = double
|
33
|
-
uri = Infoblox
|
34
|
-
allow(conn).to receive(:get).with(uri, {:_return_fields => "name,junction"}).and_return(FooResponse.new("[]"))
|
35
|
-
FooResource.all(conn).
|
47
|
+
uri = Infoblox.base_path + "foo:animal"
|
48
|
+
allow(conn).to receive(:get).with(uri, {:_return_fields => "name,junction,extensible_attributes"}).and_return(FooResponse.new("[]"))
|
49
|
+
expect(FooResource.all(conn)).to eq([])
|
36
50
|
end
|
37
51
|
|
38
52
|
it "should allow .all with return fields or max results" do
|
39
53
|
conn = double
|
40
|
-
uri = Infoblox
|
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).
|
54
|
+
uri = Infoblox.base_path + "foo:animal"
|
55
|
+
allow(conn).to receive(:get).with(uri, {:_return_fields => "name,junction,extensible_attributes", :_max_results => -70}).and_return(FooResponse.new("[]"))
|
56
|
+
expect(FooResource.all(conn, :_max_results => -70)).to eq([])
|
43
57
|
end
|
44
58
|
|
45
59
|
it "should put with the right attributes" do
|
46
60
|
conn = double
|
47
|
-
uri = Infoblox
|
61
|
+
uri = Infoblox.base_path + "abcd"
|
48
62
|
allow(conn).to receive(:put).with(uri, {:name => "jerry", :junction => "32", :do_it => false}).and_return(FooResponse.new("\"foobar\""))
|
49
63
|
f = FooResource.new(:connection => conn)
|
50
64
|
f._ref = "abcd"
|
@@ -53,12 +67,12 @@ describe Infoblox::Resource, "#add_ipv4addr" do
|
|
53
67
|
f.name = "jerry"
|
54
68
|
f.sect = :fulburns
|
55
69
|
f.put
|
56
|
-
f._ref.
|
70
|
+
expect(f._ref).to eq("foobar")
|
57
71
|
end
|
58
72
|
|
59
73
|
it "should post with the right attributes" do
|
60
74
|
conn = double
|
61
|
-
uri = Infoblox
|
75
|
+
uri = Infoblox.base_path + "foo:animal"
|
62
76
|
allow(conn).to receive(:post).with(uri, {:name => "jerry", :junction => "32", :do_it => false, :sect => :fulburns}).and_return(FooResponse.new("\"abcdefg\""))
|
63
77
|
f = FooResource.new(:connection => conn)
|
64
78
|
f.do_it = false
|
@@ -66,7 +80,7 @@ describe Infoblox::Resource, "#add_ipv4addr" do
|
|
66
80
|
f.name = "jerry"
|
67
81
|
f.sect = :fulburns
|
68
82
|
f.post
|
69
|
-
f._ref.
|
83
|
+
expect(f._ref).to eq('abcdefg')
|
70
84
|
end
|
71
85
|
|
72
86
|
it 'should map wapi objects to classes' do
|
@@ -76,7 +90,7 @@ describe Infoblox::Resource, "#add_ipv4addr" do
|
|
76
90
|
@expected[p.wapi_object] = p
|
77
91
|
end
|
78
92
|
end
|
79
|
-
Infoblox::Resource.resource_map.
|
93
|
+
expect(Infoblox::Resource.resource_map).to eq(@expected)
|
80
94
|
end
|
81
95
|
end
|
82
96
|
|
data/spec/search_spec.rb
CHANGED
@@ -7,9 +7,9 @@ describe Infoblox::Search, ".find" do
|
|
7
7
|
|
8
8
|
# empty response
|
9
9
|
return_json = SearchResponse.new("[]")
|
10
|
-
uri = Infoblox
|
10
|
+
uri = Infoblox.base_path + Infoblox::Search.wapi_object
|
11
11
|
allow(conn).to receive(:get).with(uri, {"search_string~" => "foo"}).and_return(return_json)
|
12
|
-
Infoblox::Search.find(conn, "search_string~" => "foo").
|
12
|
+
expect(Infoblox::Search.find(conn, "search_string~" => "foo")).to eq([])
|
13
13
|
|
14
14
|
# response with host
|
15
15
|
return_json = SearchResponse.new('[
|
@@ -29,9 +29,9 @@ describe Infoblox::Search, ".find" do
|
|
29
29
|
]')
|
30
30
|
allow(conn).to receive(:get).with(uri, {"search_string~" => "foo"}).and_return(return_json)
|
31
31
|
result = Infoblox::Search.find(conn, "search_string~" => "foo")
|
32
|
-
result[0].
|
32
|
+
expect(result[0]).to be_a(Infoblox::Host)
|
33
33
|
host = result[0]
|
34
|
-
host.name.
|
34
|
+
expect(host.name).to eq("foo-bar-baz.inner.domain")
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
data/spec/spec_helper.rb
CHANGED
@@ -5,8 +5,31 @@
|
|
5
5
|
#
|
6
6
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
7
|
require File.expand_path("../../lib/infoblox", __FILE__)
|
8
|
+
Bundler.setup(:test)
|
9
|
+
require 'highline/import'
|
10
|
+
|
11
|
+
module Helper
|
12
|
+
def each_version
|
13
|
+
['1.0', '1.2', '1.4', '2.0'].each do |v|
|
14
|
+
Infoblox.wapi_version = v
|
15
|
+
yield
|
16
|
+
end
|
17
|
+
ensure
|
18
|
+
Infoblox.wapi_version = '1.0'
|
19
|
+
end
|
20
|
+
|
21
|
+
def connection
|
22
|
+
Infoblox::Connection.new(
|
23
|
+
username: $username,
|
24
|
+
password: $password,
|
25
|
+
host: $host,
|
26
|
+
# logger: Logger.new(STDOUT)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
8
31
|
RSpec.configure do |config|
|
9
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
32
|
+
# config.treat_symbols_as_metadata_keys_with_true_values = true
|
10
33
|
config.run_all_when_everything_filtered = true
|
11
34
|
config.filter_run :focus
|
12
35
|
|
@@ -15,4 +38,11 @@ RSpec.configure do |config|
|
|
15
38
|
# the seed, which is printed after each run.
|
16
39
|
# --seed 1234
|
17
40
|
config.order = 'random'
|
41
|
+
config.include(Helper)
|
42
|
+
end
|
43
|
+
|
44
|
+
if ENV['INTEGRATION']
|
45
|
+
$host = ask("Infoblox host: ")
|
46
|
+
$username = ask("Infoblox username: ")
|
47
|
+
$password = ask("Infoblox password: ") {|q| q.echo = false }
|
18
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infoblox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Billy Reisinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/infoblox.rb
|
113
113
|
- lib/infoblox/connection.rb
|
114
114
|
- lib/infoblox/resource.rb
|
115
|
+
- lib/infoblox/resource/aaaa_record.rb
|
115
116
|
- lib/infoblox/resource/arecord.rb
|
116
117
|
- lib/infoblox/resource/cname.rb
|
117
118
|
- lib/infoblox/resource/fixedaddress.rb
|
@@ -126,10 +127,13 @@ files:
|
|
126
127
|
- lib/infoblox/resource/search.rb
|
127
128
|
- lib/infoblox/resource/srv.rb
|
128
129
|
- lib/infoblox/resource/txt.rb
|
130
|
+
- lib/infoblox/resource/zone_auth.rb
|
129
131
|
- lib/infoblox/version.rb
|
130
132
|
- spec/connection_spec.rb
|
131
133
|
- spec/host_ipv4addr_spec.rb
|
132
134
|
- spec/host_spec.rb
|
135
|
+
- spec/integration/host_ipv4addr_spec.rb
|
136
|
+
- spec/integration/host_spec.rb
|
133
137
|
- spec/range_spec.rb
|
134
138
|
- spec/resource_spec.rb
|
135
139
|
- spec/search_spec.rb
|
@@ -163,6 +167,8 @@ test_files:
|
|
163
167
|
- spec/connection_spec.rb
|
164
168
|
- spec/host_ipv4addr_spec.rb
|
165
169
|
- spec/host_spec.rb
|
170
|
+
- spec/integration/host_ipv4addr_spec.rb
|
171
|
+
- spec/integration/host_spec.rb
|
166
172
|
- spec/range_spec.rb
|
167
173
|
- spec/resource_spec.rb
|
168
174
|
- spec/search_spec.rb
|