smart_proxy_dhcp_infoblox 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +50 -0
- data/lib/smart_proxy_dhcp_infoblox/common_crud.rb +2 -2
- data/lib/smart_proxy_dhcp_infoblox/dhcp_infoblox_main.rb +1 -1
- data/lib/smart_proxy_dhcp_infoblox/dhcp_infoblox_plugin.rb +1 -1
- data/lib/smart_proxy_dhcp_infoblox/dhcp_infoblox_version.rb +1 -1
- data/lib/smart_proxy_dhcp_infoblox/fixed_address_crud.rb +3 -3
- data/lib/smart_proxy_dhcp_infoblox/host_ipv4_address_crud.rb +7 -7
- data/lib/smart_proxy_dhcp_infoblox/ip_address_arithmetic.rb +5 -5
- data/lib/smart_proxy_dhcp_infoblox/network_address_range_regex_generator.rb +11 -12
- data/lib/smart_proxy_dhcp_infoblox/plugin_configuration.rb +21 -24
- data/test/host_and_fixedaddress_crud_test.rb +19 -19
- data/test/infoblox_provider_test.rb +0 -1
- data/test/integration_test.rb +3 -4
- data/test/plugin_configuration_test.rb +5 -5
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ed4af7f2889b7259c13b0ed75d551ae139812fd086e56c40b724bddfaa46cf78
|
4
|
+
data.tar.gz: 7b1716d0ac19d220f26389221fe04793d14a34b4002a1a2c8e531a18e6b0d6a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82d8cb3847b9cd9b801a3ce16cee9fb113122fba6e662a10da0f576a7ad6951b6b09d5b1a73a5cb5eedec60f722ecaa7a7089f4e2e2247fbbcbe4b3e525f4352
|
7
|
+
data.tar.gz: e56a98657864b67315907210d27b8c286386ce1dd62bdb78d3a4b0d8595cafb61fc534d7f4083322b530d129aad42b5e8f4cdd5ffc22758bbe3a9838fe14bde6
|
data/README.md
CHANGED
@@ -11,6 +11,19 @@ for how to install Smart Proxy plugins
|
|
11
11
|
|
12
12
|
This plugin is compatible with Smart Proxy 1.11 or higher.
|
13
13
|
|
14
|
+
Example installation command via foreman-installer:
|
15
|
+
|
16
|
+
```
|
17
|
+
# foreman-installer --enable-foreman-proxy-plugin-dhcp-infoblox \
|
18
|
+
--foreman-proxy-dhcp-provider infoblox \
|
19
|
+
--foreman-proxy-plugin-dhcp-infoblox-record-type host \
|
20
|
+
--foreman-proxy-dhcp-server 192.168.201.2 \
|
21
|
+
--foreman-proxy-plugin-dhcp-infoblox-username admin \
|
22
|
+
--foreman-proxy-plugin-dhcp-infoblox-password infoblox \
|
23
|
+
--foreman-proxy-plugin-dhcp-infoblox-network-view default \
|
24
|
+
--foreman-proxy-plugin-dhcp-infoblox-dns-view default
|
25
|
+
```
|
26
|
+
|
14
27
|
When installing using "gem", make sure to install the bundle file:
|
15
28
|
|
16
29
|
echo "gem 'smart_proxy_dhcp_infoblox'" > /usr/share/foreman-proxy/bundler.d/dhcp_infoblox.rb
|
@@ -34,6 +47,43 @@ The main difference between host and fixedaddress is that a host record already
|
|
34
47
|
|
35
48
|
If you chose to use fixedaddress you'll need to use the infoblox dns smart proxy (https://github.com/theforeman/smart_proxy_dns_infoblox) if you want to manage dns records.
|
36
49
|
|
50
|
+
## SSL
|
51
|
+
|
52
|
+
The plugin enforces HTTPS server certificate verification. Follow a standard CA cert installation procedure for your operating system. It's possible to either download the server certificate from Infoblox web UI or use openssl command to extract it from server response. Here are example steps for Red Hat compatible systems:
|
53
|
+
|
54
|
+
```
|
55
|
+
# update-ca-trust enable
|
56
|
+
# openssl s_client -showcerts -connect 192.168.201.2:443 </dev/null | openssl x509 -text >/etc/pki/ca-trust/source/anchors/infoblox.crt
|
57
|
+
# update-ca-trust extract
|
58
|
+
```
|
59
|
+
|
60
|
+
For Debian-compatible systems:
|
61
|
+
|
62
|
+
```
|
63
|
+
# openssl s_client -showcerts -connect 192.168.201.2:443 </dev/null | openssl x509 -text >/usr/local/share/ca-certificates/infoblox.crt
|
64
|
+
# update-ca-certificates
|
65
|
+
```
|
66
|
+
|
67
|
+
To test the CA certificate, a simple curl query can be used. This is a positive test:
|
68
|
+
|
69
|
+
```
|
70
|
+
# curl -u admin:infoblox https://192.168.201.2/wapi/v2.0/network
|
71
|
+
[
|
72
|
+
{
|
73
|
+
"_ref": "network/ZG5zLm5ldHdvcmskMTkyLjE2OC4yMDIuMC8yNC8w:192.168.202.0/24/default",
|
74
|
+
"network": "192.168.202.0/24",
|
75
|
+
"network_view": "default"
|
76
|
+
}
|
77
|
+
]
|
78
|
+
```
|
79
|
+
|
80
|
+
And a negative one:
|
81
|
+
|
82
|
+
```
|
83
|
+
# curl -u admin:infoblox https://192.168.201.2/wapi/v2.0/network
|
84
|
+
curl: (60) SSL certificate problem: self signed certificate
|
85
|
+
```
|
86
|
+
|
37
87
|
## Contributing
|
38
88
|
|
39
89
|
Fork and send a Pull Request. Thanks!
|
@@ -54,9 +54,9 @@ module ::Proxy::DHCP::Infoblox
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def del_records_by_ip(ip_address)
|
57
|
-
found = find_hosts({'ipv4addr' => ip_address}, 2147483646)
|
57
|
+
found = find_hosts({ 'ipv4addr' => ip_address }, 2147483646)
|
58
58
|
return if found.empty?
|
59
|
-
found.each {|record| record.delete}
|
59
|
+
found.each { |record| record.delete }
|
60
60
|
nil
|
61
61
|
end
|
62
62
|
|
@@ -17,7 +17,7 @@ module Proxy::DHCP::Infoblox
|
|
17
17
|
super('infoblox', managed_subnets, nil, unused_ips)
|
18
18
|
end
|
19
19
|
|
20
|
-
def find_subnet(address)
|
20
|
+
def find_subnet(address); ::Proxy::DHCP::Subnet.new(address, '255.255.255.0'); end
|
21
21
|
|
22
22
|
def subnets
|
23
23
|
::Infoblox::Network.all(connection).map do |network|
|
@@ -2,7 +2,7 @@ module Proxy::DHCP::Infoblox
|
|
2
2
|
class Plugin < ::Proxy::Provider
|
3
3
|
plugin :dhcp_infoblox, ::Proxy::DHCP::Infoblox::VERSION
|
4
4
|
|
5
|
-
default_settings :record_type => 'host', :dns_view => "default", :network_view => "default", :blacklist_duration_minutes => 30*60
|
5
|
+
default_settings :record_type => 'host', :dns_view => "default", :network_view => "default", :blacklist_duration_minutes => 30 * 60
|
6
6
|
validate_presence :username, :password
|
7
7
|
|
8
8
|
requires :dhcp, '>= 1.13'
|
@@ -14,7 +14,7 @@ module ::Proxy::DHCP::Infoblox
|
|
14
14
|
def all_hosts(subnet_address)
|
15
15
|
network = ::Infoblox::Fixedaddress.find(@connection, 'network' => subnet_address, 'network_view' => network_view,
|
16
16
|
'_max_results' => 2147483646) #2**(32-cidr_to_i(subnet_address)))
|
17
|
-
network.map {|h| build_reservation(h.name, h, subnet_address)}.compact
|
17
|
+
network.map { |h| build_reservation(h.name, h, subnet_address) }.compact
|
18
18
|
end
|
19
19
|
|
20
20
|
def find_record_by_ip(subnet_address, ip_address)
|
@@ -24,9 +24,9 @@ module ::Proxy::DHCP::Infoblox
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def find_records_by_ip(subnet_address, ip_address)
|
27
|
-
found = find_hosts({'ipv4addr' => ip_address}, 2147483646)
|
27
|
+
found = find_hosts({ 'ipv4addr' => ip_address }, 2147483646)
|
28
28
|
return [] if found.empty?
|
29
|
-
to_return = found.map {|record| build_reservation(record.name, record, subnet_address)}
|
29
|
+
to_return = found.map { |record| build_reservation(record.name, record, subnet_address) }
|
30
30
|
to_return.compact
|
31
31
|
end
|
32
32
|
|
@@ -16,37 +16,37 @@ module ::Proxy::DHCP::Infoblox
|
|
16
16
|
address_range_regex = NetworkAddressesRegularExpressionGenerator.new.generate_regex(subnet_address)
|
17
17
|
|
18
18
|
hosts = ::Infoblox::Host.find(
|
19
|
-
|
19
|
+
@connection,
|
20
20
|
'ipv4addr~' => address_range_regex,
|
21
21
|
'view' => dns_view,
|
22
22
|
'_max_results' => 2147483646)
|
23
23
|
|
24
24
|
ip_addr_matcher = Regexp.new(address_range_regex) # pre-compile the regex
|
25
|
-
hosts.map {|host| build_reservation(host.name, host.ipv4addrs.find {|ip| ip_addr_matcher =~ ip.ipv4addr}, subnet_address)}.compact
|
25
|
+
hosts.map { |host| build_reservation(host.name, host.ipv4addrs.find { |ip| ip_addr_matcher =~ ip.ipv4addr }, subnet_address) }.compact
|
26
26
|
end
|
27
27
|
|
28
28
|
def find_record_by_ip(subnet_address, ip_address)
|
29
29
|
found = find_hosts('ipv4addr' => ip_address).first
|
30
30
|
return nil if found.nil?
|
31
|
-
build_reservation(found.name, found.ipv4addrs.find {|ip| ip.ipv4addr == ip_address}, subnet_address)
|
31
|
+
build_reservation(found.name, found.ipv4addrs.find { |ip| ip.ipv4addr == ip_address }, subnet_address)
|
32
32
|
end
|
33
33
|
|
34
34
|
def find_records_by_ip(subnet_address, ip_address)
|
35
|
-
found = find_hosts({'ipv4addr' => ip_address}, 2147483646)
|
35
|
+
found = find_hosts({ 'ipv4addr' => ip_address }, 2147483646)
|
36
36
|
return [] if found.empty?
|
37
|
-
to_return = found.map {|record| build_reservation(record.name, record.ipv4addrs.find {|ip| ip.ipv4addr == ip_address}, subnet_address)}
|
37
|
+
to_return = found.map { |record| build_reservation(record.name, record.ipv4addrs.find { |ip| ip.ipv4addr == ip_address }, subnet_address) }
|
38
38
|
to_return.compact
|
39
39
|
end
|
40
40
|
|
41
41
|
def find_record_by_mac(subnet_address, mac_address)
|
42
42
|
found = find_hosts('mac' => mac_address).first
|
43
43
|
return nil if found.nil?
|
44
|
-
build_reservation(found.name, found.ipv4addrs.find {|ip| ip.mac == mac_address}, subnet_address)
|
44
|
+
build_reservation(found.name, found.ipv4addrs.find { |ip| ip.mac == mac_address }, subnet_address)
|
45
45
|
end
|
46
46
|
|
47
47
|
def find_host_and_name_by_ip(ip_address)
|
48
48
|
h = find_hosts('ipv4addr' => ip_address).first
|
49
|
-
h.nil? ? [nil, nil] : [h.name, h.ipv4addrs.find {|ip| ip.ipv4addr == ip_address}]
|
49
|
+
h.nil? ? [nil, nil] : [h.name, h.ipv4addrs.find { |ip| ip.ipv4addr == ip_address }]
|
50
50
|
end
|
51
51
|
|
52
52
|
def find_hosts(condition, max_results = 1)
|
@@ -1,20 +1,20 @@
|
|
1
1
|
module ::Proxy::DHCP::Infoblox
|
2
2
|
module IpAddressArithmetic
|
3
3
|
def cidr_to_ip_mask(prefix_length)
|
4
|
-
bitmask = 0xFFFFFFFF ^ (2
|
5
|
-
(0..3).map {|i| (bitmask >> i*8) & 0xFF}.reverse.join('.')
|
4
|
+
bitmask = 0xFFFFFFFF ^ (2**(32 - prefix_length) - 1)
|
5
|
+
(0..3).map { |i| (bitmask >> i * 8) & 0xFF }.reverse.join('.')
|
6
6
|
end
|
7
7
|
|
8
8
|
def ipv4_to_i(an_address)
|
9
|
-
an_address.split('.').inject(0) {|a, c| (a << 8) + c.to_i}
|
9
|
+
an_address.split('.').inject(0) { |a, c| (a << 8) + c.to_i }
|
10
10
|
end
|
11
11
|
|
12
12
|
def i_to_ipv4(i)
|
13
|
-
(0..3).inject([]) {|a, c| a.push((i >> (c * 8)) & 0xFF)}.reverse.join('.')
|
13
|
+
(0..3).inject([]) { |a, c| a.push((i >> (c * 8)) & 0xFF) }.reverse.join('.')
|
14
14
|
end
|
15
15
|
|
16
16
|
def cidr_to_bitmask(prefix_length)
|
17
|
-
0xFFFFFFFF ^ (2
|
17
|
+
0xFFFFFFFF ^ (2**(32 - prefix_length) - 1)
|
18
18
|
end
|
19
19
|
|
20
20
|
def cidr_to_i(an_address_with_cidr)
|
@@ -12,7 +12,7 @@ module ::Proxy::DHCP::Infoblox
|
|
12
12
|
|
13
13
|
def add_children(values)
|
14
14
|
return if values.empty?
|
15
|
-
node = (found = children.find {|n| n.value == values.first}).nil? ? add_child(Node.new(values.first)) : found
|
15
|
+
node = (found = children.find { |n| n.value == values.first }).nil? ? add_child(Node.new(values.first)) : found
|
16
16
|
node.add_children(values[1..-1])
|
17
17
|
end
|
18
18
|
|
@@ -31,18 +31,17 @@ module ::Proxy::DHCP::Infoblox
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def group_children
|
34
|
-
children.each {|n| n.group_children}
|
34
|
+
children.each { |n| n.group_children }
|
35
35
|
return if children.size < 2
|
36
|
-
@children = children[1..-1].
|
36
|
+
@children = children[1..-1].each_with_object([MergedNode.new(children.first)]) do |to_group, grouped|
|
37
37
|
current = MergedNode.new(to_group)
|
38
|
-
found = grouped.find {|g| ((g.value != ['0?'] && current.value != ['0?']) || (current.value == ['0?'] && g.value == ['0?'])) && (g.children == current.children)}
|
38
|
+
found = grouped.find { |g| ((g.value != ['0?'] && current.value != ['0?']) || (current.value == ['0?'] && g.value == ['0?'])) && (g.children == current.children) }
|
39
39
|
found.nil? ? grouped.push(current) : found.merge(current)
|
40
|
-
grouped
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
44
43
|
def as_regex
|
45
|
-
children.empty? ? [value.to_s] : children.map {|c| c.as_regex.map {|r| value.to_s + r}}.flatten
|
44
|
+
children.empty? ? [value.to_s] : children.map { |c| c.as_regex.map { |r| value.to_s + r } }.flatten
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
@@ -59,11 +58,11 @@ module ::Proxy::DHCP::Infoblox
|
|
59
58
|
end
|
60
59
|
|
61
60
|
def as_regex
|
62
|
-
children.empty? ? [value_as_regex] : children.map {|c| c.as_regex.map {|r| value_as_regex + r}}.flatten
|
61
|
+
children.empty? ? [value_as_regex] : children.map { |c| c.as_regex.map { |r| value_as_regex + r } }.flatten
|
63
62
|
end
|
64
63
|
|
65
64
|
def value_as_regex
|
66
|
-
value.size < 2 ? value.first.to_s : "[#{value.join('')}]"
|
65
|
+
(value.size < 2) ? value.first.to_s : "[#{value.join('')}]"
|
67
66
|
end
|
68
67
|
|
69
68
|
def ==(other)
|
@@ -79,14 +78,14 @@ module ::Proxy::DHCP::Infoblox
|
|
79
78
|
|
80
79
|
def as_regex
|
81
80
|
group_children
|
82
|
-
"(%s)" % children.map {|c| c.as_regex}.join('|')
|
81
|
+
"(%s)" % children.map { |c| c.as_regex }.join('|')
|
83
82
|
end
|
84
83
|
|
85
84
|
def digits(a_number)
|
86
85
|
to_return = []
|
87
86
|
begin
|
88
87
|
to_return.push(a_number % 10)
|
89
|
-
a_number
|
88
|
+
a_number /= 10
|
90
89
|
end while a_number != 0
|
91
90
|
to_return.reverse
|
92
91
|
end
|
@@ -94,7 +93,7 @@ module ::Proxy::DHCP::Infoblox
|
|
94
93
|
|
95
94
|
def range_regex(range_start, range_end)
|
96
95
|
root = Root.new(nil)
|
97
|
-
(range_start..range_end).to_a.each {|i| root.add_number(i)}
|
96
|
+
(range_start..range_end).to_a.each { |i| root.add_number(i) }
|
98
97
|
root.as_regex
|
99
98
|
end
|
100
99
|
end
|
@@ -111,7 +110,7 @@ module ::Proxy::DHCP::Infoblox
|
|
111
110
|
range_start_octets = range.first.split('.').map(&:to_i)
|
112
111
|
range_end_octets = range.last.split('.').map(&:to_i)
|
113
112
|
|
114
|
-
(0..3).map {|i| [range_start_octets[i], range_end_octets[i]]}
|
113
|
+
(0..3).map { |i| [range_start_octets[i], range_end_octets[i]] }
|
115
114
|
end
|
116
115
|
|
117
116
|
def range_to_regex(range)
|
@@ -11,34 +11,31 @@ module Proxy::DHCP::Infoblox
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def load_dependency_injection_wirings(c, settings)
|
14
|
+
c.dependency :connection, (lambda {
|
15
|
+
::Infoblox.wapi_version = '2.0'
|
16
|
+
::Infoblox::Connection.new(:username => settings[:username], :password => settings[:password],
|
17
|
+
:host => settings[:server], :ssl_opts => { :verify => true },
|
18
|
+
:logger => ::Proxy::LogBuffer::Decorator.instance)
|
19
|
+
})
|
14
20
|
|
21
|
+
c.singleton_dependency :unused_ips, lambda { ::Proxy::DHCP::FreeIps.new(settings[:blacklist_duration_minutes]) }
|
15
22
|
|
16
|
-
c.dependency :
|
17
|
-
::Infoblox.wapi_version = '2.0'
|
18
|
-
::Infoblox::Connection.new(:username => settings[:username] ,:password => settings[:password],
|
19
|
-
:host => settings[:server], :ssl_opts => {:verify => false})
|
20
|
-
end)
|
21
|
-
|
22
|
-
|
23
|
-
c.singleton_dependency :unused_ips, lambda {::Proxy::DHCP::FreeIps.new(settings[:blacklist_duration_minutes]) }
|
24
|
-
|
25
|
-
c.dependency :host_ipv4_crud, (lambda do
|
23
|
+
c.dependency :host_ipv4_crud, (lambda {
|
26
24
|
::Proxy::DHCP::Infoblox::HostIpv4AddressCRUD.new(c.get_dependency(:connection), settings[:dns_view])
|
27
|
-
|
28
|
-
c.dependency :fixed_address_crud, (lambda
|
25
|
+
})
|
26
|
+
c.dependency :fixed_address_crud, (lambda {
|
29
27
|
::Proxy::DHCP::Infoblox::FixedAddressCRUD.new(c.get_dependency(:connection), settings[:network_view])
|
30
|
-
|
31
|
-
c.dependency :grid_restart, lambda { ::Proxy::DHCP::Infoblox::GridRestart.new(c.get_dependency(:connection))}
|
32
|
-
c.dependency :dhcp_provider, (lambda
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
28
|
+
})
|
29
|
+
c.dependency :grid_restart, lambda { ::Proxy::DHCP::Infoblox::GridRestart.new(c.get_dependency(:connection)) }
|
30
|
+
c.dependency :dhcp_provider, (lambda {
|
31
|
+
::Proxy::DHCP::Infoblox::Provider.new(
|
32
|
+
c.get_dependency(:connection),
|
33
|
+
(settings[:record_type] == 'host') ? c.get_dependency(:host_ipv4_crud) : c.get_dependency(:fixed_address_crud),
|
34
|
+
c.get_dependency(:grid_restart),
|
35
|
+
c.get_dependency(:unused_ips),
|
36
|
+
settings[:subnets],
|
37
|
+
settings[:network_view])
|
38
|
+
})
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|
44
|
-
|
@@ -28,7 +28,7 @@ module CommoncrudTests
|
|
28
28
|
:mac => '00:01:02:03:04:05',
|
29
29
|
:configure_for_dhcp => false)])
|
30
30
|
@entity.expects(:find).
|
31
|
-
|
31
|
+
with(@connection, search_condition('ipv4addr' => '192.168.42.1', '_max_results' => 2147483646)).returns([found_record])
|
32
32
|
assert @crud.find_records_by_ip('192.168.42.0/24', '192.168.42.1').empty?
|
33
33
|
end
|
34
34
|
|
@@ -74,7 +74,7 @@ module CommoncrudTests
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def test_del_records_by_ip
|
77
|
-
@crud.expects(:find_hosts).with({'ipv4addr' => @ip}, 2147483646).returns([@host, @host1])
|
77
|
+
@crud.expects(:find_hosts).with({ 'ipv4addr' => @ip }, 2147483646).returns([@host, @host1])
|
78
78
|
@host.expects(:delete)
|
79
79
|
@host1.expects(:delete)
|
80
80
|
@crud.del_records_by_ip(@ip)
|
@@ -105,15 +105,15 @@ class HostCrudTest < Test::Unit::TestCase
|
|
105
105
|
@subnet_ip = '192.168.42.0'
|
106
106
|
|
107
107
|
@host = ::Infoblox::Host.new(
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
108
|
+
:name => @hostname,
|
109
|
+
:view => @view,
|
110
|
+
:ipv4addrs => [{ :ipv4addr => @ip, :mac => @mac, :nextserver => @nextserver, :use_nextserver => true,
|
111
|
+
:bootfile => @filename, :use_bootfile => true, :configure_for_dhcp => true }])
|
112
112
|
@host1 = ::Infoblox::Host.new(
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
113
|
+
:name => 'another.test.com',
|
114
|
+
:view => @view,
|
115
|
+
:ipv4addrs => [{ :ipv4addr => @ip, :mac => '00:01:02:03:05:07', :nextserver => @nextserver, :use_nextserver => true,
|
116
|
+
:bootfile => @filename, :use_bootfile => true, :configure_for_dhcp => true }])
|
117
117
|
|
118
118
|
@reservation = ::Proxy::DHCP::Reservation.new(@hostname, @ip, @mac, ::Proxy::DHCP::Subnet.new(@subnet_ip, '255.255.255.0'),
|
119
119
|
:hostname => @hostname, :nextServer => @nextserver, :filename => @filename,
|
@@ -150,13 +150,13 @@ class HostCrudTest < Test::Unit::TestCase
|
|
150
150
|
@crud.expects(:build_host).with(:ip => @ip, :mac => @mac, :hostname => @hostname).returns(@host)
|
151
151
|
@host.expects(:post).raises(Infoblox::Error.new("IB.Data.Conflict"))
|
152
152
|
@crud.expects(:find_hosts).with('ipv4addr' => @ip).returns(
|
153
|
-
|
153
|
+
[::Infoblox::Host.new(:name => @hostname, :ipv4addrs => [{ :ipv4addr => @ip, :mac => '11:22:33:44:55:66"', :configure_for_dhcp => true }])])
|
154
154
|
|
155
155
|
assert_raises(Proxy::DHCP::Collision) { @crud.add_record(:ip => @ip, :mac => @mac, :hostname => @hostname) }
|
156
156
|
end
|
157
157
|
|
158
158
|
def search_condition(a_hash)
|
159
|
-
{'view' => @view}.merge(a_hash)
|
159
|
+
{ 'view' => @view }.merge(a_hash)
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
@@ -178,11 +178,11 @@ class FixedaddressCrudTest < Test::Unit::TestCase
|
|
178
178
|
@subnet_ip = '192.168.42.0'
|
179
179
|
|
180
180
|
@host = ::Infoblox::Fixedaddress.new(
|
181
|
-
|
182
|
-
|
181
|
+
:name => @hostname,
|
182
|
+
:ipv4addr => @ip, :mac => @mac, :network_view => @network_view)
|
183
183
|
@host1 = ::Infoblox::Fixedaddress.new(
|
184
|
-
|
185
|
-
|
184
|
+
:name => 'another.test.com',
|
185
|
+
:ipv4addr => @ip, :mac => '00:01:02:03:05:07', :network_view => @network_view)
|
186
186
|
|
187
187
|
@reservation = ::Proxy::DHCP::Reservation.new(@hostname, @ip, @mac, ::Proxy::DHCP::Subnet.new(@subnet_ip, '255.255.255.0'),
|
188
188
|
:deleteable => true, :hostname => @hostname)
|
@@ -212,13 +212,13 @@ class FixedaddressCrudTest < Test::Unit::TestCase
|
|
212
212
|
@crud.expects(:build_host).with(:ip => @ip, :mac => @mac, :hostname => @hostname).returns(@host)
|
213
213
|
@host.expects(:post).raises(Infoblox::Error.new("IB.Data.Conflict"))
|
214
214
|
@crud.expects(:find_hosts).with('ipv4addr' => @ip).returns(
|
215
|
-
|
216
|
-
|
215
|
+
[::Infoblox::Fixedaddress.new(:name => @hostname, :ipv4addr => @ip, :mac => '11:22:33:44:55:66',
|
216
|
+
:network_view => @network_view)])
|
217
217
|
|
218
218
|
assert_raises(Proxy::DHCP::Collision) { @crud.add_record(:ip => @ip, :mac => @mac, :hostname => @hostname) }
|
219
219
|
end
|
220
220
|
|
221
221
|
def search_condition(a_hash)
|
222
|
-
{'network_view' => @network_view}.merge(a_hash)
|
222
|
+
{ 'network_view' => @network_view }.merge(a_hash)
|
223
223
|
end
|
224
224
|
end
|
@@ -16,7 +16,6 @@ class InfobloxProviderTest < Test::Unit::TestCase
|
|
16
16
|
@network = Infoblox::Network.new(:network => '192.168.42.0/24')
|
17
17
|
@subnet = ::Proxy::DHCP::Subnet.new('192.168.42.0', '255.255.255.0')
|
18
18
|
|
19
|
-
|
20
19
|
@network_2 = Infoblox::Network.new(:network => '192.168.43.0/24')
|
21
20
|
@provider = Proxy::DHCP::Infoblox::Provider.new(@connection, @crud, @restart_grid,
|
22
21
|
@unused_ips, @managed_subnets, @network_view)
|
data/test/integration_test.rb
CHANGED
@@ -22,11 +22,10 @@ class IntegrationTest < ::Test::Unit::TestCase
|
|
22
22
|
@server = ::Proxy::DHCP::Infoblox::Provider.new(nil, Object.new, Object.new, @free_ips, [],
|
23
23
|
"default")
|
24
24
|
|
25
|
-
@expected_reservation = {"name" => "testing-01", "ip" => "10.0.0.200", "mac" => "11:22:33:a9:61:09",
|
26
|
-
"subnet" => "10.0.0.0/255.255.255.0", "hostname" => "testing-01"}
|
25
|
+
@expected_reservation = { "name" => "testing-01", "ip" => "10.0.0.200", "mac" => "11:22:33:a9:61:09",
|
26
|
+
"subnet" => "10.0.0.0/255.255.255.0", "hostname" => "testing-01" }
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
29
|
def test_get_subnets
|
31
30
|
@server.expects(:subnets).returns([])
|
32
31
|
get "/"
|
@@ -73,7 +72,7 @@ class IntegrationTest < ::Test::Unit::TestCase
|
|
73
72
|
|
74
73
|
def test_create_record
|
75
74
|
record = {
|
76
|
-
|
75
|
+
"hostname" => "test-02",
|
77
76
|
"ip" => "10.0.0.250",
|
78
77
|
"mac" => "10:10:10:10:10:10",
|
79
78
|
"network" => "10.0.0.0",
|
@@ -12,7 +12,7 @@ require 'smart_proxy_dhcp_infoblox/dhcp_infoblox_main'
|
|
12
12
|
|
13
13
|
class PluginDefaultConfigurationTest < Test::Unit::TestCase
|
14
14
|
def test_default_settings
|
15
|
-
assert_equal({:record_type => 'host', :blacklist_duration_minutes => 30*60, :dns_view => "default", :network_view => "default"},
|
15
|
+
assert_equal({ :record_type => 'host', :blacklist_duration_minutes => 30 * 60, :dns_view => "default", :network_view => "default" },
|
16
16
|
Proxy::DHCP::Infoblox::Plugin.default_settings)
|
17
17
|
end
|
18
18
|
end
|
@@ -21,9 +21,9 @@ class InfobloxDhcpProductionWiringTest < Test::Unit::TestCase
|
|
21
21
|
def setup
|
22
22
|
@network_view = "network_view"
|
23
23
|
@dns_view = "dns_view"
|
24
|
-
@settings = {:username => 'user', :password => 'password', :server => '127.0.0.1', :record_type => 'host',
|
24
|
+
@settings = { :username => 'user', :password => 'password', :server => '127.0.0.1', :record_type => 'host',
|
25
25
|
:subnets => ['1.1.1.0/255.255.255.0'], :blacklist_duration_minutes => 300,
|
26
|
-
:dns_view => @dns_view, :network_view => @network_view}
|
26
|
+
:dns_view => @dns_view, :network_view => @network_view }
|
27
27
|
@container = ::Proxy::DependencyInjection::Container.new
|
28
28
|
Proxy::DHCP::Infoblox::PluginConfiguration.new.load_dependency_injection_wirings(@container, @settings)
|
29
29
|
end
|
@@ -33,7 +33,7 @@ class InfobloxDhcpProductionWiringTest < Test::Unit::TestCase
|
|
33
33
|
assert_equal 'https://127.0.0.1', connection.host
|
34
34
|
assert_equal 'user', connection.username
|
35
35
|
assert_equal 'password', connection.password
|
36
|
-
assert_equal({:verify =>
|
36
|
+
assert_equal({ :verify => true }, connection.ssl_opts)
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_unused_ips_configuration
|
@@ -71,7 +71,7 @@ class InfobloxDhcpProductionWiringTest < Test::Unit::TestCase
|
|
71
71
|
|
72
72
|
def test_provider_configuration_with_fixedaddress_crud
|
73
73
|
Proxy::DHCP::Infoblox::PluginConfiguration.new.
|
74
|
-
|
74
|
+
load_dependency_injection_wirings(@container, :username => 'user', :password => 'password',
|
75
75
|
:server => '127.0.0.1', :record_type => 'fixed_address')
|
76
76
|
|
77
77
|
provider = @container.get_dependency(:dhcp_provider)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dhcp_infoblox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Klaas Demter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: infoblox
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.0.4
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rubocop
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.50.0
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.50.0
|
33
47
|
description: Infoblox DHCP provider plugin for Foreman's smart proxy
|
34
48
|
email:
|
35
49
|
- demter@atix.de
|
@@ -81,16 +95,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
95
|
version: '0'
|
82
96
|
requirements: []
|
83
97
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.6
|
98
|
+
rubygems_version: 2.7.6
|
85
99
|
signing_key:
|
86
100
|
specification_version: 4
|
87
101
|
summary: Infoblox DHCP provider plugin for Foreman's smart proxy
|
88
102
|
test_files:
|
89
|
-
- test/integration_test.rb
|
90
|
-
- test/infoblox_provider_test.rb
|
91
|
-
- test/plugin_configuration_test.rb
|
92
|
-
- test/regex_generator_test.rb
|
93
103
|
- test/record_type_validator_test.rb
|
104
|
+
- test/regex_generator_test.rb
|
94
105
|
- test/test_helper.rb
|
95
106
|
- test/unused_ip_test.rb
|
96
107
|
- test/host_and_fixedaddress_crud_test.rb
|
108
|
+
- test/integration_test.rb
|
109
|
+
- test/plugin_configuration_test.rb
|
110
|
+
- test/infoblox_provider_test.rb
|