DEPENDENCIES Rails.application.config.ss Rails.application.config.dns
DEPENDENCIES Rails.application.config.ss Rails.application.config.dns
DEPENDENCIES Rails.application.config.ss Rails.application.config.dns
DEPENDENCIES Rails.application.config.ss Rails.application.config.dns
# File lib/uplift-bind-plugin/uplift/bind_plugin.rb, line 17 def initialize(access_info = nil) if access_info != nil @domain_suffix = access_info[:domain_suffix] elsif defined? Rails # extract from Rails.application.config[dns,ss] access_info = Rails.application.config.dns @domain_suffix = Rails.application.config.ss[:domain_suffix] else raise Exception.new("BIND DNS service is not inilialized") end @server = access_info[:server] @port = access_info[:port].to_i @src_port = access_info[:src_port].to_i if access_info[:src_port].to_i @keyname = access_info[:keyname] @keyvalue = access_info[:keyvalue] @zone = access_info[:zone] end
# File lib/uplift-bind-plugin/uplift/bind_plugin.rb, line 114 def close end
# File lib/uplift-bind-plugin/uplift/bind_plugin.rb, line 90 def deregister_application(app_name, namespace) begin # delete the CNAME record for the application in the domain fqdn = "#{app_name}-#{namespace}.#{@domain_suffix}" # We know we only have one CNAME per app, so look it up # We need it for the delete # should be an error if there's not exactly one answer current = dns.query(fqdn, 'CNAME') cnamevalue = current.answer[0].rdata.to_s # enable updates with key dns.tsig = @keyname, @keyvalue update = Dnsruby::Update.new(@zone) update_response = update.delete(fqdn, 'CNAME', cnamevalue) send_response = dns.send_message(update) rescue Dnsruby::NXDomain Rails.logger.debug "DEBUG: BIND: Could not find CNAME for #{fqdn} to delete" end end
# File lib/uplift-bind-plugin/uplift/bind_plugin.rb, line 68 def deregister_namespace(namespace) # create a TXT record for the namespace in the domain fqdn = "#{namespace}.#{@domain_suffix}" # enable updates with key dns.tsig = @keyname, @keyvalue update = Dnsruby::Update.new(@zone) update.delete(fqdn, 'TXT') dns.send_message(update) end
# File lib/uplift-bind-plugin/uplift/bind_plugin.rb, line 35 def dns if not @dns_con @dns_con = Dnsruby::Resolver.new(:nameserver => @server, :port => @port) @dns_con.src_port = @src_port if @src_port end @dns_con end
# File lib/uplift-bind-plugin/uplift/bind_plugin.rb, line 43 def namespace_available?(namespace) fqdn = "#{namespace}.#{@domain_suffix}" # If we get a response, then the namespace is reserved # An exception means that it is available begin dns.query(fqdn, Dnsruby::Types::TXT) return false rescue Dnsruby::NXDomain return true end end
# File lib/uplift-bind-plugin/uplift/bind_plugin.rb, line 111 def publish end
# File lib/uplift-bind-plugin/uplift/bind_plugin.rb, line 79 def register_application(app_name, namespace, public_hostname) # create an A record for the application in the domain fqdn = "#{app_name}-#{namespace}.#{@domain_suffix}" # enable updates with key dns.tsig = @keyname, @keyvalue update = Dnsruby::Update.new(@zone) update.add(fqdn, 'CNAME', 60, public_hostname) dns.send_message(update) end
# File lib/uplift-bind-plugin/uplift/bind_plugin.rb, line 56 def register_namespace(namespace) # create a TXT record for the namespace in the domain fqdn = "#{namespace}.#{@domain_suffix}" # enable updates with key dns.tsig = @keyname, @keyvalue update = Dnsruby::Update.new(@zone) # update.absent(fqdn, 'TXT') update.add(fqdn, 'TXT', 60, "Text record for #{namespace}") dns.send_message(update) end