smart_proxy_dns_infoblox 0.0.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/dns_infoblox.yml.example +6 -2
- data/lib/smart_proxy_dns_infoblox/dns_infoblox_main.rb +64 -0
- data/lib/smart_proxy_dns_infoblox/dns_infoblox_plugin.rb +1 -1
- data/lib/smart_proxy_dns_infoblox/dns_infoblox_version.rb +1 -1
- data/lib/smart_proxy_dns_infoblox/plugin_configuration.rb +1 -0
- data/test/infoblox_test.rb +68 -0
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0cd133f133a42e4d8bb583d7566d3ef78caaf9f088a95f589c950f5abc73d99
|
4
|
+
data.tar.gz: b6a90cd39ac38ff25d40c557a4f615b6d4339a3841015157dfb99525890d7973
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de50121fbebd43ca08d483bd1332988e7c2ab6b4659d7605b16de613ac6cbbd6b1190c680b449cc4c11073187d148c4cfe32818a9a2b2a1fa7d48a0137a574a8
|
7
|
+
data.tar.gz: 63865b57418f08551a82af80ff526c62b3c78ba364bfe9136d9f0dc8bea8e7489aa23fc3d6af80c596940609ac09ec25f58e66a3a2b75352e771e5854f170a12
|
@@ -5,8 +5,12 @@
|
|
5
5
|
:username: "admin"
|
6
6
|
:password: "infoblox"
|
7
7
|
|
8
|
-
#
|
9
|
-
:
|
8
|
+
# Connection, read and write HTTP timeout
|
9
|
+
#:timeout: 60
|
10
|
+
|
11
|
+
# IP address of the Infoblox appliance (without https:// or port). If set
|
12
|
+
# to hostname, make sure it resolves correctly.
|
13
|
+
:dns_server: "1.2.3.4"
|
10
14
|
|
11
15
|
# View used for records, usually 'default.myview' for custom names.
|
12
16
|
#:dns_view: 'default'
|
@@ -20,8 +20,72 @@ module Proxy::Dns::Infoblox
|
|
20
20
|
send(method, name)
|
21
21
|
end
|
22
22
|
|
23
|
+
# -1 = no conflict and create the record
|
24
|
+
# 0 = already exists and do nothing
|
25
|
+
# 1 = conflict and error out
|
26
|
+
def record_conflicts_ip(fqdn, type, address)
|
27
|
+
method = "ib_find_#{type.name.split('::').last.downcase}_record".to_sym
|
28
|
+
raise(Proxy::Dns::Error, "Finding of #{type} records not implemented") unless respond_to?(method, true)
|
29
|
+
|
30
|
+
return -1 if send(method, fqdn).empty?
|
31
|
+
return 0 if send(method, fqdn, address).any?
|
32
|
+
1
|
33
|
+
end
|
34
|
+
|
35
|
+
def record_conflicts_name(fqdn, type, content)
|
36
|
+
if type == Resolv::DNS::Resource::IN::PTR
|
37
|
+
record_conflicts_ip(content, type, fqdn)
|
38
|
+
else
|
39
|
+
record_conflicts_ip(fqdn, type, content)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
23
43
|
private
|
24
44
|
|
45
|
+
def ib_find_a_record(fqdn, address = nil)
|
46
|
+
params = {
|
47
|
+
:_max_results => 1,
|
48
|
+
:view => dns_view,
|
49
|
+
:name => fqdn
|
50
|
+
}
|
51
|
+
params[:ipv4addr] = address if address
|
52
|
+
Infoblox::Arecord.find(connection, params)
|
53
|
+
end
|
54
|
+
|
55
|
+
def ib_find_aaaa_record(fqdn, address = nil)
|
56
|
+
params = {
|
57
|
+
:_max_results => 1,
|
58
|
+
:view => dns_view,
|
59
|
+
:name => fqdn
|
60
|
+
}
|
61
|
+
params[:ipv6addr] = address if address
|
62
|
+
Infoblox::AAAArecord.find(connection, params)
|
63
|
+
end
|
64
|
+
|
65
|
+
def ib_find_ptr_record(fqdn, ptr = nil)
|
66
|
+
params = {
|
67
|
+
:_max_results => 1,
|
68
|
+
:view => dns_view,
|
69
|
+
:ptrdname => fqdn
|
70
|
+
}
|
71
|
+
if ptr
|
72
|
+
ip = IPAddr.new(ptr_to_ip(ptr))
|
73
|
+
params["ipv#{ip.ipv4? ? 4 : 6}addr".to_sym] = ip.to_s
|
74
|
+
params[:name] = ptr
|
75
|
+
end
|
76
|
+
Infoblox::Ptr.find(connection, params)
|
77
|
+
end
|
78
|
+
|
79
|
+
def ib_find_cname_record(fqdn, address = nil)
|
80
|
+
params = {
|
81
|
+
:_max_results => 1,
|
82
|
+
:view => dns_view,
|
83
|
+
:name => fqdn
|
84
|
+
}
|
85
|
+
params[:canonical] = address if address
|
86
|
+
Infoblox::Cname.find(connection, params)
|
87
|
+
end
|
88
|
+
|
25
89
|
def ib_create_a_record(fqdn, address)
|
26
90
|
ib_create(Infoblox::Arecord, :name => fqdn, :ipv4addr => address)
|
27
91
|
end
|
@@ -2,7 +2,7 @@ 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', :dns_view => 'default'
|
5
|
+
default_settings :username => 'infoblox', :password => 'infoblox', :dns_server => 'localhost', :dns_view => 'default', :timeout => 60
|
6
6
|
|
7
7
|
requires :dns, '>= 1.12'
|
8
8
|
|
@@ -15,6 +15,7 @@ module Proxy::Dns::Infoblox
|
|
15
15
|
:password => settings[:password],
|
16
16
|
:host => settings[:dns_server],
|
17
17
|
:ssl_opts => { :verify => true },
|
18
|
+
:timeout => settings[:timeout],
|
18
19
|
:logger => ::Proxy::LogBuffer::Decorator.instance)
|
19
20
|
end)
|
20
21
|
container_instance.dependency :dns_provider,
|
data/test/infoblox_test.rb
CHANGED
@@ -13,6 +13,74 @@ class InfobloxTest < Test::Unit::TestCase
|
|
13
13
|
@provider = Proxy::Dns::Infoblox::Record.new('a_host', nil, 999, 'default.test')
|
14
14
|
end
|
15
15
|
|
16
|
+
def test_conflict_a_ok
|
17
|
+
@provider.expects(:ib_find_a_record).with("test.example.com").returns([])
|
18
|
+
assert_equal(-1, @provider.record_conflicts_ip("test.example.com", Resolv::DNS::Resource::IN::A, "1.2.3.4"))
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_conflict_a_already_exists
|
22
|
+
@provider.expects(:ib_find_a_record).with("test.example.com").returns([true])
|
23
|
+
@provider.expects(:ib_find_a_record).with("test.example.com", "1.2.3.4").returns([true])
|
24
|
+
assert_equal(0, @provider.record_conflicts_ip("test.example.com", Resolv::DNS::Resource::IN::A, "1.2.3.4"))
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_conflict_a_conflict
|
28
|
+
@provider.expects(:ib_find_a_record).with("test.example.com").returns([false])
|
29
|
+
@provider.expects(:ib_find_a_record).with("test.example.com", "1.2.3.4").returns([false])
|
30
|
+
assert_equal(1, @provider.record_conflicts_ip("test.example.com", Resolv::DNS::Resource::IN::A, "1.2.3.4"))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_conflict_aaaa_ok
|
34
|
+
@provider.expects(:ib_find_aaaa_record).with("test.example.com").returns([])
|
35
|
+
assert_equal(-1, @provider.record_conflicts_ip("test.example.com", Resolv::DNS::Resource::IN::AAAA, "1.2.3.4"))
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_conflict_aaaa_already_exists
|
39
|
+
@provider.expects(:ib_find_aaaa_record).with("test.example.com").returns([true])
|
40
|
+
@provider.expects(:ib_find_aaaa_record).with("test.example.com", "1.2.3.4").returns([true])
|
41
|
+
assert_equal(0, @provider.record_conflicts_ip("test.example.com", Resolv::DNS::Resource::IN::AAAA, "1.2.3.4"))
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_conflict_aaaa_conflict
|
45
|
+
@provider.expects(:ib_find_aaaa_record).with("test.example.com").returns([false])
|
46
|
+
@provider.expects(:ib_find_aaaa_record).with("test.example.com", "1.2.3.4").returns([false])
|
47
|
+
assert_equal(1, @provider.record_conflicts_ip("test.example.com", Resolv::DNS::Resource::IN::AAAA, "1.2.3.4"))
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_conflict_ptr_ok
|
51
|
+
@provider.expects(:ib_find_ptr_record).with("13.202.168.192.in-addr.arpa").returns([])
|
52
|
+
assert_equal(-1, @provider.record_conflicts_ip("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_conflict_ptr_already_exists
|
56
|
+
@provider.expects(:ib_find_ptr_record).with("13.202.168.192.in-addr.arpa").returns([true])
|
57
|
+
@provider.expects(:ib_find_ptr_record).with("13.202.168.192.in-addr.arpa", "test.example.com").returns([true])
|
58
|
+
assert_equal(0, @provider.record_conflicts_ip("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_conflict_ptr_conflict
|
62
|
+
@provider.expects(:ib_find_ptr_record).with("13.202.168.192.in-addr.arpa").returns([false])
|
63
|
+
@provider.expects(:ib_find_ptr_record).with("13.202.168.192.in-addr.arpa", "test.example.com").returns([false])
|
64
|
+
assert_equal(1, @provider.record_conflicts_ip("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_conflict_cname_ok
|
68
|
+
@provider.expects(:ib_find_cname_record).with("test.example.com").returns([])
|
69
|
+
assert_equal(-1, @provider.record_conflicts_ip("test.example.com", Resolv::DNS::Resource::IN::CNAME, "alias.example.com"))
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_conflict_cname_already_exists
|
73
|
+
@provider.expects(:ib_find_cname_record).with("test.example.com").returns([true])
|
74
|
+
@provider.expects(:ib_find_cname_record).with("test.example.com", "alias.example.com").returns([true])
|
75
|
+
assert_equal(0, @provider.record_conflicts_ip("test.example.com", Resolv::DNS::Resource::IN::CNAME, "alias.example.com"))
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_conflict_cname_conflict
|
79
|
+
@provider.expects(:ib_find_cname_record).with("test.example.com").returns([false])
|
80
|
+
@provider.expects(:ib_find_cname_record).with("test.example.com", "alias.example.com").returns([false])
|
81
|
+
assert_equal(1, @provider.record_conflicts_ip("test.example.com", Resolv::DNS::Resource::IN::CNAME, "alias.example.com"))
|
82
|
+
end
|
83
|
+
|
16
84
|
def test_create_a
|
17
85
|
fqdn = 'test.example.com'
|
18
86
|
ip = '10.1.1.1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dns_infoblox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.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: 2019-
|
11
|
+
date: 2019-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -64,13 +64,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
|
-
|
68
|
-
rubygems_version: 2.7.6
|
67
|
+
rubygems_version: 3.0.3
|
69
68
|
signing_key:
|
70
69
|
specification_version: 4
|
71
70
|
summary: Infoblox DNS provider plugin for Foreman's smart proxy
|
72
71
|
test_files:
|
73
72
|
- test/test_helper.rb
|
74
73
|
- test/configuration_test.rb
|
75
|
-
- test/integration_test.rb
|
76
74
|
- test/infoblox_test.rb
|
75
|
+
- test/integration_test.rb
|