[PATCH/foreman 1/1] fixes #1383 - aready existing dns entries should not raise a collision exception

Signed-off-by: Paul Kelly <paul.ian.kelly@googlemail.com>

··· --- .idea/encodings.xml | 5 +++++ .idea/misc.xml | 8 ++++++++ .idea/modules.xml | 9 +++++++++ .idea/smart-proxy.iml | 10 ++++++++++ .idea/vcs.xml | 7 +++++++ lib/proxy/dns/bind.rb | 9 +++------ 6 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 .idea/encodings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/smart-proxy.iml create mode 100644 .idea/vcs.xml

diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000…e206d70
— /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+

+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000…dc11a6e
— /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+

+
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000…dbcc0d7
— /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+

  •  <module fileurl="file://$PROJECT_DIR$/.idea/smart-proxy.iml" filepath="$PROJECT_DIR$/.idea/smart-proxy.iml" />
    

+
+
diff --git a/.idea/smart-proxy.iml b/.idea/smart-proxy.iml
new file mode 100644
index 0000000…a1c482c
— /dev/null
+++ b/.idea/smart-proxy.iml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+

+
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000…c80f219
— /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+

+
+
diff --git a/lib/proxy/dns/bind.rb b/lib/proxy/dns/bind.rb
index 14b5969…1b7785f 100644
— a/lib/proxy/dns/bind.rb
+++ b/lib/proxy/dns/bind.rb
@@ -22,13 +22,13 @@ module Proxy::DNS
case @type
when "A"
if ip = dns_find(@fqdn)

  •        raise(Proxy::DNS::Collision, "#{@fqdn} is already used by #{ip}")
    
  •        raise(Proxy::DNS::Collision, "#{@fqdn} is already used by #{ip}") unless ip == @value
         else
           nsupdate "update add #{@fqdn}.  #{@ttl} #{@type} #{@value}"
         end
       when "PTR"
         if name = dns_find(@value)
    
  •        raise(Proxy::DNS::Collision, "#{@value} is already used by #{name}")
    
  •        raise(Proxy::DNS::Collision, "#{@value} is already used by #{name}") unless name == @fqdn
         else
           nsupdate "update add #{@value}.  #{@ttl} IN #{@type} #{@fqdn}"
         end
    

@@ -74,10 +74,7 @@ module Proxy::DNS
@om.close
@om = nil # we cannot serialize an IO object, even if closed.
# TODO Parse output for errors!

  •    if status.empty?
    
  •      logger.debug "nsupdate returned no status!"
    
  •      raise Proxy::DNS::Error.new("Got no response from the DNS server")
    
  •    elsif status[1] !~ /status: NOERROR/
    
  •    if !status.empty? and status[1] !~ /status: NOERROR/
         logger.debug "nsupdate: errors\n" + status.join("\n")
         raise Proxy::DNS::Error.new("Update errors: #{status.join("\n")}")
       end
    


1.7.5.4