smart_proxy_dns_infoblox 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/lib/smart_proxy_dns_infoblox/dns_infoblox_main.rb +37 -12
- data/lib/smart_proxy_dns_infoblox/dns_infoblox_plugin.rb +2 -1
- data/lib/smart_proxy_dns_infoblox/dns_infoblox_version.rb +1 -1
- data/lib/smart_proxy_dns_infoblox/infoblox_member_dns.rb +1 -1
- data/test/infoblox_test.rb +48 -8
- data/test/integration_test.rb +13 -2
- data/test/test_helper.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3a0500e2d29b0e17690364666974cec3258457b8806c4ff743fc85179e9c67b
|
4
|
+
data.tar.gz: df9c2f18edb7a29ce56090ef1ca03f34e6454ec88d9c492c1e23d274e03717bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb8d100b528571220d9f08cda5d9772819114a2712bc2cfff82f5352d92bdeacd5163bad9465c51d6497aff9c346343d66207c7b2f579ce4c4eeee478af137bd
|
7
|
+
data.tar.gz: 916a54d5a0aa1610a4a9d034c27c913f922ad29172a10bf503f3403db182c91d2b20cbc3d250dc04a084ab8936d0f91f07cbdc454047d31fcfcde54f1b14adef
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# SmartProxyDnsInfoblox
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/theforeman/smart_proxy_dns_infoblox.svg?branch=master)](https://travis-ci.org/theforeman/smart_proxy_dns_infoblox)
|
4
|
-
|
5
3
|
This plugin adds a new DNS provider for managing records in MyService.
|
6
4
|
|
7
5
|
## Installation
|
@@ -11,12 +11,14 @@ module Proxy::Dns::Infoblox
|
|
11
11
|
def do_create(name, value, type)
|
12
12
|
method = "ib_create_#{type.downcase}_record".to_sym
|
13
13
|
raise(Proxy::Dns::Error, "Creation of #{type} records not implemented") unless respond_to?(method, true)
|
14
|
+
|
14
15
|
send(method, name, value)
|
15
16
|
end
|
16
17
|
|
17
18
|
def do_remove(name, type)
|
18
19
|
method = "ib_remove_#{type.downcase}_record".to_sym
|
19
20
|
raise(Proxy::Dns::Error, "Deletion of #{type} records not implemented") unless respond_to?(method, true)
|
21
|
+
|
20
22
|
send(method, name)
|
21
23
|
end
|
22
24
|
|
@@ -24,11 +26,17 @@ module Proxy::Dns::Infoblox
|
|
24
26
|
# 0 = already exists and do nothing
|
25
27
|
# 1 = conflict and error out
|
26
28
|
def record_conflicts_ip(fqdn, type, address)
|
27
|
-
|
29
|
+
if type == Resolv::DNS::Resource::IN::PTR
|
30
|
+
ip = IPAddr.new(ptr_to_ip(address))
|
31
|
+
method = "ib_find_#{type.name.split('::').last.downcase}#{ip.ipv4? ? 4 : 6}_record".to_sym
|
32
|
+
else
|
33
|
+
method = "ib_find_#{type.name.split('::').last.downcase}_record".to_sym
|
34
|
+
end
|
28
35
|
raise(Proxy::Dns::Error, "Finding of #{type} records not implemented") unless respond_to?(method, true)
|
29
36
|
|
30
37
|
return -1 if send(method, fqdn).empty?
|
31
38
|
return 0 if send(method, fqdn, address).any?
|
39
|
+
|
32
40
|
1
|
33
41
|
end
|
34
42
|
|
@@ -62,15 +70,31 @@ module Proxy::Dns::Infoblox
|
|
62
70
|
Infoblox::AAAArecord.find(connection, params)
|
63
71
|
end
|
64
72
|
|
65
|
-
def
|
73
|
+
def ib_find_ptr4_record(fqdn, ptr = nil)
|
66
74
|
params = {
|
67
75
|
:_max_results => 1,
|
68
76
|
:view => dns_view,
|
69
|
-
:ptrdname => fqdn
|
77
|
+
:ptrdname => fqdn,
|
78
|
+
:'name~' => 'in-addr\.arpa$'
|
70
79
|
}
|
71
80
|
if ptr
|
72
81
|
ip = IPAddr.new(ptr_to_ip(ptr))
|
73
|
-
params[
|
82
|
+
params[:ipv4addr] = ip.to_s
|
83
|
+
params[:name] = ptr
|
84
|
+
end
|
85
|
+
Infoblox::Ptr.find(connection, params)
|
86
|
+
end
|
87
|
+
|
88
|
+
def ib_find_ptr6_record(fqdn, ptr = nil)
|
89
|
+
params = {
|
90
|
+
:_max_results => 1,
|
91
|
+
:view => dns_view,
|
92
|
+
:ptrdname => fqdn,
|
93
|
+
:'name~' => 'ip6\.arpa$'
|
94
|
+
}
|
95
|
+
if ptr
|
96
|
+
ip = IPAddr.new(ptr_to_ip(ptr))
|
97
|
+
params[:ipv6addr] = ip.to_s
|
74
98
|
params[:name] = ptr
|
75
99
|
end
|
76
100
|
Infoblox::Ptr.find(connection, params)
|
@@ -136,14 +160,15 @@ module Proxy::Dns::Infoblox
|
|
136
160
|
end
|
137
161
|
|
138
162
|
def ib_delete(clazz, params)
|
139
|
-
|
163
|
+
records = clazz.find(connection, params.merge(view: dns_view))
|
164
|
+
raise Proxy::Dns::NotFound, "Cannot find #{clazz.class.name} entry for #{params}" if records.empty?
|
140
165
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
166
|
+
records.each do |record|
|
167
|
+
record.delete
|
168
|
+
ib_clear_dns_cache(record)
|
169
|
+
end
|
145
170
|
|
146
|
-
|
171
|
+
true
|
147
172
|
end
|
148
173
|
|
149
174
|
def ib_clear_dns_cache(record)
|
@@ -153,9 +178,9 @@ module Proxy::Dns::Infoblox
|
|
153
178
|
MemberDns.all(connection).each do |member|
|
154
179
|
member.clear_dns_cache(view: record.view, domain: record.name)
|
155
180
|
end
|
156
|
-
rescue StandardError =>
|
181
|
+
rescue StandardError => e
|
157
182
|
# Failing to clear the DNS cache should never be an error
|
158
|
-
logger.warn("Exception #{
|
183
|
+
logger.warn("Exception #{e} was raised when clearing DNS cache")
|
159
184
|
end
|
160
185
|
end
|
161
186
|
end
|
@@ -2,7 +2,8 @@ module Proxy::Dns::Infoblox
|
|
2
2
|
class Plugin < ::Proxy::Provider
|
3
3
|
plugin :dns_infoblox, ::Proxy::Dns::Infoblox::VERSION
|
4
4
|
|
5
|
-
default_settings :username => 'infoblox', :password => 'infoblox', :dns_server => 'localhost',
|
5
|
+
default_settings :username => 'infoblox', :password => 'infoblox', :dns_server => 'localhost',
|
6
|
+
:dns_view => 'default', :timeout => 60
|
6
7
|
|
7
8
|
requires :dns, '>= 1.12'
|
8
9
|
|
@@ -13,7 +13,7 @@ module Proxy::Dns::Infoblox
|
|
13
13
|
post_body[:domain] = domain unless domain.nil?
|
14
14
|
post_body[:view] = view unless view.nil?
|
15
15
|
|
16
|
-
JSON.parse(connection.post(resource_uri
|
16
|
+
JSON.parse(connection.post("#{resource_uri}?_function=clear_dns_cache", post_body).body)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/test/infoblox_test.rb
CHANGED
@@ -48,20 +48,31 @@ class InfobloxTest < Test::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_conflict_ptr_ok
|
51
|
-
@provider.expects(:
|
52
|
-
assert_equal(-1, @provider.
|
51
|
+
@provider.expects(:ib_find_ptr4_record).with("test.example.com").returns([])
|
52
|
+
assert_equal(-1, @provider.record_conflicts_name("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
53
|
+
|
54
|
+
@provider.expects(:ib_find_ptr6_record).with("test.example.com").returns([])
|
55
|
+
assert_equal(-1, @provider.record_conflicts_name("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
53
56
|
end
|
54
57
|
|
55
58
|
def test_conflict_ptr_already_exists
|
56
|
-
@provider.expects(:
|
57
|
-
@provider.expects(:
|
58
|
-
assert_equal(0, @provider.
|
59
|
+
@provider.expects(:ib_find_ptr4_record).with("test.example.com").returns([true])
|
60
|
+
@provider.expects(:ib_find_ptr4_record).with("test.example.com", "13.202.168.192.in-addr.arpa").returns([true])
|
61
|
+
assert_equal(0, @provider.record_conflicts_name("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
62
|
+
|
63
|
+
@provider.expects(:ib_find_ptr6_record).with("test.example.com").returns([true])
|
64
|
+
@provider.expects(:ib_find_ptr6_record).with("test.example.com", "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa").returns([true])
|
65
|
+
assert_equal(0, @provider.record_conflicts_name("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
59
66
|
end
|
60
67
|
|
61
68
|
def test_conflict_ptr_conflict
|
62
|
-
@provider.expects(:
|
63
|
-
@provider.expects(:
|
64
|
-
assert_equal(1, @provider.
|
69
|
+
@provider.expects(:ib_find_ptr4_record).with("test.example.com").returns([false])
|
70
|
+
@provider.expects(:ib_find_ptr4_record).with("test.example.com", "13.202.168.192.in-addr.arpa").returns([false])
|
71
|
+
assert_equal(1, @provider.record_conflicts_name("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
72
|
+
|
73
|
+
@provider.expects(:ib_find_ptr6_record).with("test.example.com").returns([false])
|
74
|
+
@provider.expects(:ib_find_ptr6_record).with("test.example.com", "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa").returns([false])
|
75
|
+
assert_equal(1, @provider.record_conflicts_name("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
65
76
|
end
|
66
77
|
|
67
78
|
def test_conflict_cname_ok
|
@@ -160,6 +171,35 @@ class InfobloxTest < Test::Unit::TestCase
|
|
160
171
|
@provider.do_remove(ptr, 'PTR')
|
161
172
|
end
|
162
173
|
|
174
|
+
def test_wapi_remove_multi_a_records
|
175
|
+
address1 = '192.168.1.11'
|
176
|
+
address2 = '192.168.2.22'
|
177
|
+
fqdn = 'test.example.com'
|
178
|
+
|
179
|
+
record1 = Infoblox::Arecord.new name: fqdn, :ipv4addr => address1
|
180
|
+
record1.expects(:delete).returns(record1)
|
181
|
+
record2 = Infoblox::Arecord.new name: fqdn, :ipv4addr => address2
|
182
|
+
record2.expects(:delete).returns(record2)
|
183
|
+
|
184
|
+
Infoblox::Arecord.expects(:find).returns([record1, record2])
|
185
|
+
@provider.do_remove(fqdn, 'A')
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_wapi_remove_multi_ptr_records
|
189
|
+
ptr = '1.1.1.10.in-addr.arpa'
|
190
|
+
ip = '10.1.1.1'
|
191
|
+
fqdn1 = 'test1.example.com'
|
192
|
+
fqdn2 = 'test2.example.com'
|
193
|
+
|
194
|
+
record1 = Infoblox::Ptr.new name: ptr, :ptrdname => fqdn1, :ipv4addr => ip
|
195
|
+
record1.expects(:delete).returns(record1)
|
196
|
+
record2 = Infoblox::Ptr.new name: ptr, :ptrdname => fqdn2, :ipv4addr => ip
|
197
|
+
record2.expects(:delete).returns(record2)
|
198
|
+
|
199
|
+
Infoblox::Ptr.expects(:find).returns([record1, record2])
|
200
|
+
@provider.do_remove(ptr, 'PTR')
|
201
|
+
end
|
202
|
+
|
163
203
|
def test_wapi_old
|
164
204
|
fqdn = 'test.example.com'
|
165
205
|
record = Infoblox::Arecord.new name: fqdn
|
data/test/integration_test.rb
CHANGED
@@ -21,8 +21,11 @@ class IntegrationTest < ::Test::Unit::TestCase
|
|
21
21
|
include Rack::Test::Methods
|
22
22
|
|
23
23
|
class DnsProviderForTesting < Proxy::Dns::Infoblox::Record
|
24
|
+
# This explicitly doesn't want to do anything
|
25
|
+
# rubocop:disable Lint/MissingSuper Style/RedundantInitialize
|
24
26
|
def initialize
|
25
27
|
end
|
28
|
+
# rubocop:enable Lint/MissingSuper Style/RedundantInitialize
|
26
29
|
end
|
27
30
|
|
28
31
|
def app
|
@@ -41,12 +44,20 @@ class IntegrationTest < ::Test::Unit::TestCase
|
|
41
44
|
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
42
45
|
end
|
43
46
|
|
44
|
-
def
|
45
|
-
@server.expects(:
|
47
|
+
def test_create_ptr4_record
|
48
|
+
@server.expects(:ib_find_ptr4_record).with('test.com').returns([])
|
49
|
+
@server.expects(:ib_create_ptr_record).with('33.33.168.192.in-addr.arpa', 'test.com')
|
46
50
|
post '/', :fqdn => 'test.com', :value => '33.33.168.192.in-addr.arpa', :type => 'PTR'
|
47
51
|
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
48
52
|
end
|
49
53
|
|
54
|
+
def test_create_ptr6_record
|
55
|
+
@server.expects(:ib_find_ptr6_record).with('test.com').returns([])
|
56
|
+
@server.expects(:ib_create_ptr_record).with('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa', 'test.com')
|
57
|
+
post '/', :fqdn => 'test.com', :value => '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa', :type => 'PTR'
|
58
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
59
|
+
end
|
60
|
+
|
50
61
|
def test_delete_a_record
|
51
62
|
@server.expects(:remove_a_record).with("test.com")
|
52
63
|
delete '/test.com'
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dns_infoblox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Nicholson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: infoblox
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '3.0'
|
27
27
|
description: Infoblox DNS provider plugin for Foreman's smart proxy
|
28
28
|
email:
|
29
29
|
- matthew.a.nicholson@gmail.com
|
@@ -57,19 +57,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '2.5'
|
61
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
63
|
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
|
-
rubygems_version: 3.
|
67
|
+
rubygems_version: 3.3.27
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Infoblox DNS provider plugin for Foreman's smart proxy
|
71
71
|
test_files:
|
72
|
-
- test/test_helper.rb
|
73
72
|
- test/configuration_test.rb
|
74
73
|
- test/infoblox_test.rb
|
75
74
|
- test/integration_test.rb
|
75
|
+
- test/test_helper.rb
|