smart_proxy_dhcp_infoblox 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6a4ca3969027de5275b0b1bceb2a61900d33286
|
4
|
+
data.tar.gz: dea402d92c6936893c77c25a80e11591ea2d3aa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b0c9339057157d473c3db84aefa42565a14f3a1dd050653fae39d93ce9d8a10684adb813d311ec4046f3b9e81f8b6a731f6cb1d75b38693f328f16f8fbff349
|
7
|
+
data.tar.gz: 140aed657e449dc0104586d4d3f1084aea9bbbf06d6c731c42720af190b152b07f9ba177c8fb13c4e8eee28aa89a102969449dcf1edc4a68b52f6edf1dd845dc
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'dhcp_common/server'
|
2
2
|
require 'infoblox'
|
3
|
+
require 'ipaddr'
|
3
4
|
|
4
5
|
module Proxy::DHCP::Infoblox
|
5
6
|
class Provider < ::Proxy::DHCP::Server
|
@@ -100,10 +101,29 @@ module Proxy::DHCP::Infoblox
|
|
100
101
|
# returns first available ip address in a subnet with network_address, for a host with mac_address, in the range of ip addresses: from_ip_address, to_ip_address
|
101
102
|
# Deliberatly ignoring everything but first argument
|
102
103
|
logger.debug "Infoblox unused_ip Network_address: #{network_address} #{mac_address}, #{from_ip_address}, #{to_ip_address}"
|
103
|
-
|
104
|
-
|
104
|
+
#next_available_ip can take a number to return (1), and an array of ips to exclude. So, we need to:
|
105
|
+
#build a list of all ips in the network (all_addresses)
|
106
|
+
#build a list of all ips in between from_ip_address and to_ip_address (include_addresses)
|
107
|
+
#remove all of the from_ip_address and to_ip_address from the all_address (exclude_addresses)
|
108
|
+
#and call next_available_ip with exclude_addresses passed
|
109
|
+
all_addresses = Array.new
|
110
|
+
net=IPAddr.new("#{network_address.network}/#{network_address.cidr}")
|
111
|
+
net.to_range.each do |ip|
|
112
|
+
all_addresses.push(ip.to_s)
|
113
|
+
end
|
114
|
+
range_start=IPAddr.new(from_ip_address)
|
115
|
+
range_stop=IPAddr.new(to_ip_address)
|
116
|
+
included_addresses=Array.new
|
117
|
+
(range_start..range_stop).each do |ip|
|
118
|
+
included_addresses.push(ip.to_s)
|
119
|
+
end
|
120
|
+
excluded_addresses=all_addresses-included_addresses
|
121
|
+
#excluded_addresses is now an array of ips containing all the ips from the network not between from, and to_ip_address
|
122
|
+
|
123
|
+
if @range
|
124
|
+
::Infoblox::Range.find(@connection, network: "#{network_address.network}/#{network_address.cidr}").first.next_available_ip(1,excluded_addresses)
|
105
125
|
else
|
106
|
-
::Infoblox::Network.find(@connection, network: "#{network_address.network}/#{network_address.cidr}").first.next_available_ip
|
126
|
+
::Infoblox::Network.find(@connection, network: "#{network_address.network}/#{network_address.cidr}").first.next_available_ip(1,excluded_addresses)
|
107
127
|
end
|
108
128
|
# Idea for randomisation in case of concurrent installs:
|
109
129
|
#::Infoblox::Network.find(@connection, network: "#{network_address.network}/#{network_address.cidr}").first.next_available_ip(15).sample
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Klaas Demter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.5.1
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Infoblox DHCP provider plugin for Foreman's smart proxy
|