smart_proxy_ipam 0.0.10 → 0.0.11
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/README.md +5 -5
- data/lib/smart_proxy_ipam/phpipam/phpipam_client.rb +8 -7
- data/lib/smart_proxy_ipam/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42b9945498eacd5e884248edc7770ac14fbda2b7315fd8f6997aa2fda7738323
|
4
|
+
data.tar.gz: 737a679b29622a526211670cbff2cf5e2a6e0b386f3ace537ce4ebc0a12b7e5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09f728a68de1da60906199cba9dada6d120ea31657f2369ba616b92c9a10dec3d3feba4e15051266af03e13e8d4be2d231841f17094b674d50fa5e2f630e0dfb'
|
7
|
+
data.tar.gz: bb3c04b61e6776dabda6c2e752b7376013045b247560887481bde4701bb4d2fbbaee8bc973e49b393b695ee16f72d17c8e297219b545609e8b07ea970c847bb4
|
data/README.md
CHANGED
@@ -15,10 +15,10 @@ for how to install Foreman plugins
|
|
15
15
|
|
16
16
|
## Usage
|
17
17
|
|
18
|
-
Once plugin is installed, you can
|
18
|
+
Once plugin is installed, you can use phpIPAM to get the next available IP address for a subnet:
|
19
19
|
|
20
|
-
1. Create a subnet in Foreman of IPAM type "
|
21
|
-
2. Create a host in Foreman. When adding/editing interfaces, select the above subnet, and the next available IP(pulled from phpIPAM) for the selected subnet will be displayed in the IPv4 address field. _NOTE: This is not supported for IPv6._
|
20
|
+
1. Create a subnet in Foreman of IPAM type "External IPAM". Click on the `Proxy` tab and associate the subnet with the External IPAM proxy. _NOTE: This subnet must actually exist in phpIPAM. There is no phpIPAM integration on the subnet creation at this time._
|
21
|
+
2. Create a host in Foreman. When adding/editing interfaces, select the above created subnet, and the next available IP(pulled from phpIPAM) for the selected subnet will be displayed in the IPv4 address field. _NOTE: This is not supported for IPv6._
|
22
22
|
|
23
23
|
## Local development
|
24
24
|
|
@@ -62,8 +62,8 @@ bundle exec smart-proxy start
|
|
62
62
|
```
|
63
63
|
9. Navigate to Foreman UI at http://localhost:5000
|
64
64
|
10. Add a Local Smart Proxy in the Foreman UI(Infrastructure => Smart Proxies)
|
65
|
-
11. Ensure that the `
|
66
|
-
12. Create a Subnet, and associate the subnet to the `
|
65
|
+
11. Ensure that the `external_ipam` feature is present on the proxy(http://proxy_url/features)
|
66
|
+
12. Create a Subnet, and associate the subnet to the `external_ipam` proxy
|
67
67
|
|
68
68
|
## Contributing
|
69
69
|
|
@@ -13,14 +13,15 @@ module Proxy::Phpipam
|
|
13
13
|
MAX_RETRIES = 5
|
14
14
|
DEFAULT_CLEANUP_INTERVAL = 120 # 2 mins
|
15
15
|
@@ip_cache = nil
|
16
|
+
@@timer_task = nil
|
16
17
|
|
17
18
|
def initialize
|
18
19
|
@conf = Proxy::Ipam.get_config[:phpipam]
|
19
20
|
@api_base = "#{@conf[:url]}/api/#{@conf[:user]}/"
|
20
21
|
@token = nil
|
21
|
-
|
22
|
+
@@m = Monitor.new
|
22
23
|
init_cache if @@ip_cache.nil?
|
23
|
-
start_cleanup_task
|
24
|
+
start_cleanup_task if @@timer_task.nil?
|
24
25
|
end
|
25
26
|
|
26
27
|
def get_subnet(cidr)
|
@@ -157,8 +158,8 @@ module Proxy::Phpipam
|
|
157
158
|
|
158
159
|
def start_cleanup_task
|
159
160
|
logger.info("Starting allocated ip address maintenance (used by get_next_ip call).")
|
160
|
-
|
161
|
-
|
161
|
+
@@timer_task = Concurrent::TimerTask.new(:execution_interval => DEFAULT_CLEANUP_INTERVAL) { init_cache }
|
162
|
+
@@timer_task.execute
|
162
163
|
end
|
163
164
|
|
164
165
|
private
|
@@ -176,14 +177,14 @@ module Proxy::Phpipam
|
|
176
177
|
# }
|
177
178
|
def init_cache
|
178
179
|
logger.debug("Clearing ip cache.")
|
179
|
-
|
180
|
+
@@m.synchronize do
|
180
181
|
@@ip_cache = {}
|
181
182
|
end
|
182
183
|
end
|
183
184
|
|
184
185
|
def add_ip_to_cache(ip, mac, cidr)
|
185
186
|
logger.debug("Adding IP #{ip} to cache for subnet #{cidr}")
|
186
|
-
|
187
|
+
@@m.synchronize do
|
187
188
|
if @@ip_cache.key?(cidr.to_sym)
|
188
189
|
@@ip_cache[cidr.to_sym][mac.to_sym] = ip.to_s
|
189
190
|
else
|
@@ -193,7 +194,7 @@ module Proxy::Phpipam
|
|
193
194
|
end
|
194
195
|
|
195
196
|
# Called when next available IP from external IPAM has been cached by another user/host, but
|
196
|
-
# not actually persisted in external IPAM.
|
197
|
+
# not actually persisted in external IPAM. Will increment the IP(MAX_RETRIES times), and
|
197
198
|
# see if it is available in external IPAM.
|
198
199
|
def find_new_ip(subnet_id, ip, mac, cidr)
|
199
200
|
found_ip = nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_ipam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Smart proxy plugin for IPAM integration with various IPAM providers
|
14
14
|
email: chrisjsmith001@gmail.com
|