smart_proxy_dns_infoblox 0.0.7 → 0.0.8

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
  SHA256:
3
- metadata.gz: 5cfadf774e686f392163cab090cda18e690ae0c89a2ecfcd54e1c6d916fb7ef5
4
- data.tar.gz: cc14db4c7b8931fb8e49310aa9eba1d9570b34530c1048f2e556de9b345192a1
3
+ metadata.gz: 786631c2c2929335d895bb171f087fb3481c84a0e9b0c365431ae6de0e22adcc
4
+ data.tar.gz: 9fec1c9e89928b02a9e405f852996042795e2b7add7411458c015c40817a814e
5
5
  SHA512:
6
- metadata.gz: 2f12f800f8df1cfb0673a3a0e30b0196fae46ee4b42c505d66da87e155311ec02fc375a9ae132a9e558a7779990b93183d1d0343eb83e4ea10ff71b7053451dc
7
- data.tar.gz: 97d0999844145b63635f671164933b825003b29c2ec656ae1ca6545a69b1ba7a43970aa077dffc34c96c622f81b2b32d089f7346a4a1446019ac1db392b32939
6
+ metadata.gz: b5f1e9f182f123bd9aebc8489ae8d402f3f3ac91e2ba8aa36bcbc947ffe6441ce743508c41bd63206c2353ef3a944e8a59629b4e96b62b9546af650842ed820d
7
+ data.tar.gz: 2a8d73c0fdeda7c3c74cb3181aae682ae193b5fbbba9a1160ea6df38008e06f8feabc0d9239a0abded82e9d26bef8ccbf3da0ead4deae13cde83ce4e89073475
@@ -74,7 +74,23 @@ module Proxy::Dns::Infoblox
74
74
  record = clazz.find(connection, params.merge(:_max_results => 1)).first
75
75
 
76
76
  raise Proxy::Dns::NotFound, "Cannot find #{clazz.class.name} entry for #{params}" if record.nil?
77
- record.delete || (raise Proxy::Dns::NotFound, "Cannot find #{clazz.class.name} entry for #{params}")
77
+ ret_value = record.delete || (raise Proxy::Dns::NotFound, "Cannot find #{clazz.class.name} entry for #{params}")
78
+
79
+ ib_clear_dns_cache(record)
80
+
81
+ ret_value
82
+ end
83
+
84
+ def ib_clear_dns_cache(record)
85
+ # Created in WAPI version 2.6
86
+ return if Gem::Version.new(Infoblox.wapi_version) < Gem::Version.new('2.6')
87
+
88
+ MemberDns.all(connection).each do |member|
89
+ member.clear_dns_cache(view: record.view, domain: record.name)
90
+ end
91
+ rescue StandardError => ex
92
+ # Failing to clear the DNS cache should never be an error
93
+ logger.warn("Exception #{ex} was raised when clearing DNS cache")
78
94
  end
79
95
  end
80
96
  end
@@ -1,7 +1,7 @@
1
1
  module Proxy
2
2
  module Dns
3
3
  module Infoblox
4
- VERSION = '0.0.7'.freeze
4
+ VERSION = '0.0.8'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,19 @@
1
+ module Proxy::Dns::Infoblox
2
+ class MemberDns < Infoblox::Resource
3
+ remote_attr_reader :host_name
4
+
5
+ wapi_object 'member:dns'
6
+
7
+ def clear_dns_cache(clear_full_tree: false,
8
+ domain: nil,
9
+ view: nil)
10
+ post_body = {
11
+ clear_full_tree: clear_full_tree
12
+ }
13
+ post_body[:domain] = domain unless domain.nil?
14
+ post_body[:view] = view unless view.nil?
15
+
16
+ JSON.parse(connection.post(resource_uri + "?_function=clear_dns_cache", post_body).body)
17
+ end
18
+ end
19
+ end
@@ -4,6 +4,7 @@ module Proxy::Dns::Infoblox
4
4
  require 'infoblox'
5
5
  require 'dns_common/dns_common'
6
6
  require 'smart_proxy_dns_infoblox/dns_infoblox_main'
7
+ require 'smart_proxy_dns_infoblox/infoblox_member_dns'
7
8
  end
8
9
 
9
10
  def load_dependency_injection_wirings(container_instance, settings)
@@ -2,6 +2,7 @@ require 'test_helper'
2
2
  require 'dns_common/dns_common'
3
3
  require 'infoblox'
4
4
  require 'smart_proxy_dns_infoblox/dns_infoblox_main'
5
+ require 'smart_proxy_dns_infoblox/infoblox_member_dns'
5
6
 
6
7
  class InfobloxTest < Test::Unit::TestCase
7
8
  class DummyRecord
@@ -90,4 +91,36 @@ class InfobloxTest < Test::Unit::TestCase
90
91
  @provider.expects(:ib_delete).with(Infoblox::Ptr, :ipv6addr => ip)
91
92
  @provider.do_remove(ptr, 'PTR')
92
93
  end
94
+
95
+ def test_wapi_old
96
+ fqdn = 'test.example.com'
97
+ record = Infoblox::Arecord.new name: fqdn
98
+ record.stubs(:delete).returns(record)
99
+
100
+ old_version = Infoblox.wapi_version
101
+ Infoblox.wapi_version = '2.0'
102
+
103
+ Infoblox::Arecord.expects(:find).returns([record])
104
+ Proxy::Dns::Infoblox::MemberDns.expects(:all).never
105
+ @provider.do_remove(fqdn, 'A')
106
+ ensure
107
+ Infoblox.wapi_version = old_version
108
+ end
109
+
110
+ def test_wapi_new
111
+ fqdn = 'test.example.com'
112
+ record = Infoblox::Arecord.new name: fqdn, view: 'test'
113
+ record.stubs(:delete).returns(record)
114
+ member = Proxy::Dns::Infoblox::MemberDns.new name: 'ns1.example.com'
115
+
116
+ old_version = Infoblox.wapi_version
117
+ Infoblox.wapi_version = '2.7'
118
+
119
+ Infoblox::Arecord.expects(:find).returns([record])
120
+ Proxy::Dns::Infoblox::MemberDns.expects(:all).returns([member])
121
+ member.expects(:clear_dns_cache).with(view: 'test', domain: fqdn)
122
+ @provider.do_remove(fqdn, 'A')
123
+ ensure
124
+ Infoblox.wapi_version = old_version
125
+ end
93
126
  end
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Nicholson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2019-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -39,6 +39,7 @@ files:
39
39
  - lib/smart_proxy_dns_infoblox/dns_infoblox_main.rb
40
40
  - lib/smart_proxy_dns_infoblox/dns_infoblox_plugin.rb
41
41
  - lib/smart_proxy_dns_infoblox/dns_infoblox_version.rb
42
+ - lib/smart_proxy_dns_infoblox/infoblox_member_dns.rb
42
43
  - lib/smart_proxy_dns_infoblox/plugin_configuration.rb
43
44
  - test/configuration_test.rb
44
45
  - test/infoblox_test.rb