smart_proxy_ipam 0.0.18 → 0.0.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58e0c15cc7ee1369b7a1c5b7fa7cfcae0c7c54d75c8fc6486f02c8672447e0f8
4
- data.tar.gz: f7937ba79296964dbfb142c3655e8c0c2c6f97745c10c40fcb3b3eec2b2390d2
3
+ metadata.gz: 557b60d8a66e595502b01b96675bcfd85c1c6e40df80fd824d1aa57e7a11d29f
4
+ data.tar.gz: e1488f94cfa129ccbd3da7006c535bc4632b4206511a25cd7c81778c27bf7dcc
5
5
  SHA512:
6
- metadata.gz: 68a637fbf28997b2fff0d961f1d8c6b5ffb6dcd8b32824bc25753a913429ba168e94261c3c9706ad1f2edeb786926c3626c91912c4b14976e34013f7e1bb419d
7
- data.tar.gz: 291c8293ee1e81b577ac96e25fbcb497c6438c9a1d6c4411f7e91e073dfbf3d77847115cf0621a9c0c279f0d20bd259eed148e81375551c6fa6f5540c4fa6e9e
6
+ metadata.gz: 4f9b9a41c0367c7aaa4abd902a2db04faf8026a9c61d28b001b5b57ef94169a6b219ea799fb2819a7209a081d304f393098b452e72fbcefb67c98a3aa845e779
7
+ data.tar.gz: ca812b143249eb666d02c2af202576024e0b2993332b7563b897950b40b7ef4ba0944b844b7eea9aa83c3c7074c55a3baa392aa59835c5b40c0ed3e7d7a56180
@@ -176,12 +176,16 @@ module Proxy::Phpipam
176
176
  #
177
177
  # Groups of subnets are cached under the External IPAM Group name. For example,
178
178
  # "IPAM Group Name" would be the section name in phpIPAM. All IP's cached for subnets
179
- # that do not have an External IPAM group specified, they are cached under the "" key.
179
+ # that do not have an External IPAM group specified, they are cached under the "" key. IP's
180
+ # are cached using one of two possible keys:
181
+ # 1). Mac Address
182
+ # 2). UUID (Used when Mac Address not specified)
180
183
  #
181
184
  # {
182
185
  # "": {
183
186
  # "100.55.55.0/24":{
184
- # "00:0a:95:9d:68:10": {"ip": "100.55.55.1", "timestamp": "2019-09-17 12:03:43 -D400"}
187
+ # "00:0a:95:9d:68:10": {"ip": "100.55.55.1", "timestamp": "2019-09-17 12:03:43 -D400"},
188
+ # "906d8bdc-dcc0-4b59-92cb-665935e21662": {"ip": "100.55.55.2", "timestamp": "2019-09-17 11:43:22 -D400"}
185
189
  # },
186
190
  # },
187
191
  # "IPAM Group Name": {
@@ -223,18 +227,21 @@ module Proxy::Phpipam
223
227
  logger.debug("Adding IP #{ip} to cache for subnet #{cidr} in section #{section_name}")
224
228
  @@m.synchronize do
225
229
  # Clear cache data which has the same mac and ip with the new one
230
+
231
+ mac_addr = (mac.nil? || mac.empty?) ? SecureRandom.uuid : mac
226
232
  section_hash = @@ip_cache[section_name.to_sym]
233
+
227
234
  section_hash.each do |key, values|
228
- if values.keys.include? mac.to_sym
229
- @@ip_cache[section_name.to_sym][key].delete(mac.to_sym)
235
+ if values.keys.include? mac_addr.to_sym
236
+ @@ip_cache[section_name.to_sym][key].delete(mac_addr.to_sym)
230
237
  end
231
238
  @@ip_cache[section_name.to_sym].delete(key) if @@ip_cache[section_name.to_sym][key].nil? or @@ip_cache[section_name.to_sym][key].empty?
232
239
  end
233
240
 
234
241
  if section_hash.key?(cidr.to_sym)
235
- @@ip_cache[section_name.to_sym][cidr.to_sym][mac.to_sym] = {:ip => ip.to_s, :timestamp => Time.now.to_s}
242
+ @@ip_cache[section_name.to_sym][cidr.to_sym][mac_addr.to_sym] = {:ip => ip.to_s, :timestamp => Time.now.to_s}
236
243
  else
237
- @@ip_cache = @@ip_cache.merge({section_name.to_sym => {cidr.to_sym => {mac.to_sym => {:ip => ip.to_s, :timestamp => Time.now.to_s}}}})
244
+ @@ip_cache = @@ip_cache.merge({section_name.to_sym => {cidr.to_sym => {mac_addr.to_sym => {:ip => ip.to_s, :timestamp => Time.now.to_s}}}})
238
245
  end
239
246
  end
240
247
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Proxy
3
3
  module Ipam
4
- VERSION = '0.0.18'
4
+ VERSION = '0.0.19'
5
5
  end
6
6
  end
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.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-24 00:00:00.000000000 Z
11
+ date: 2020-03-04 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