OpenShift::DnsService
OpenShift DNS Plugin to interact with dynamic DNS using {www.ietf.org/rfc/rfc2136 RFC 2136} update protocol and {www.ietf.org/rfc/rfc2845 RFC 2845} DNS TSIG
Implements the OpenShift::DnsService interface
This class uses the nsupdate(8) program to communicate with the DNS service.
The object can be configured either by providing the access_info parameter or by pulling the settings from the Rails.application.config object (if it exists).
When pulling from the Rails configuration this plugin expects to find the domain_suffix in
Rails.application.config.openshift[:domain_suffix]
and the rest of the parameters in a hash at
Rails.application.config.dns
@example nsupdate plugin configuration hash - HMAC-MD5 TSIG
{:server => "myserver", :port => portnumber, :keyname => "TSIG key name", :keyvalue => "TSIG key string", :keyalgorithm => ["HMAC-MD5"|"HMAC-SHA1"|"HMAC-SHA256"|"HMAC-SHA512"] :zone => "zone to update", # only when configuring with parameters :domain_suffix => "suffix for application domain names" }
@example nsupdate plugin configuration hash - KRB5 GSS-TSIG
{:server => "myserver", :port => portnumber, :krb_principal => "The authentication principal", :krb_keytab => "The authentication key", :zone => "zone to update", # only when configuring with parameters :domain_suffix => "suffix for application domain names" }
@!attribute [r] server
@return [String] IP address of the DNS update server
@!attribute [r] port
@return [Fixnum] UDP port for the DNS update server
@!attribute [r] keyname
@return [String] the TSIG key name
@!attribute [r] keyvalue
@return [String] the TSIG key value
@!attribute [r] keyalgorithm
@return [String] the TSIG key algorithm
@!attribute [r] krb_principal
@return [String] A Kerberos 5 principal
@!attribute [r] krb_keytab
@return [String] the Kerberos keytab
Establish the parameters for a connection to the DNS update service
@param access_info [Hash] communication configuration settings @see NsupdatePlugin NsupdatePlugin class Examples
# File lib/openshift/nsupdate_plugin.rb, line 74 def initialize(access_info = nil) if access_info != nil @domain_suffix = access_info[:domain_suffix] elsif defined? Rails access_info = Rails.application.config.dns @domain_suffix = Rails.application.config.openshift[:domain_suffix] else raise DNSException.new("Nsupdate DNS updates are not initialized") end @server = access_info[:server] @port = access_info[:port].to_i @keyname = access_info[:keyname] @keyvalue = access_info[:keyvalue] @keyalgorithm = access_info[:keyalgorithm] || "HMAC-MD5" @krb_principal = access_info[:krb_principal] @krb_keytab = access_info[:krb_keytab] @zone = access_info[:zone] # verify that the plugin can read the keytab file, if specified if @krb_keytab if not File.exists? @krb_keytab raise DNSException.new "missing GSS keytab file: #{@krb_keytab}" elsif not File.readable? @krb_keytab raise DNSException.new( "keytab file #{@krb_keytab} is not readable by UID #{Process.uid}" ) end end end
close any persistent connection to the update server @return [nil]
# File lib/openshift/nsupdate_plugin.rb, line 250 def close end
Unpublish an application - remove DNS record
@param [String] app_name
The name of the application to publish
@param [String] namespace
The namespace which contains the application
@return [Object]
The response from the service provider in what ever form that takes
# File lib/openshift/nsupdate_plugin.rb, line 211 def deregister_application(app_name, namespace) # delete the CNAME record for the application in the domain fqdn = "#{app_name}-#{namespace}.#{@domain_suffix}" cmd = del_cmd(fqdn) # authenticate if credentials have been given if @krb_principal cmd = "kinit -kt #{@krb_keytab} #{@krb_principal} &&" + cmd end success = system cmd if not success raise DNSException.new("error deleting app record #{fqdn}") end end
Change the published location of an application - Modify DNS record
@param [String] app_name
The name of the application to publish
@param [String] namespace
The namespace which contains the application
@param [String] public_hostname
The name of the location where the application resides
@return [Object]
The response from the service provider in what ever form that takes
# File lib/openshift/nsupdate_plugin.rb, line 238 def modify_application(app_name, namespace, public_hostname) deregister_application(app_name, namespace) register_application(app_name, namespace, public_hostname) end
send any queued requests to the update server @return [nil]
# File lib/openshift/nsupdate_plugin.rb, line 245 def publish end
Publish an application - create DNS record
@param [String] app_name
The name of the application to publish
@param [String] namespace
The namespace which contains the application
@param [String] public_hostname
The name of the location where the application resides
@return [Object]
The response from the service provider in what ever form that takes
# File lib/openshift/nsupdate_plugin.rb, line 190 def register_application(app_name, namespace, public_hostname) # create an A record for the application in the domain fqdn = "#{app_name}-#{namespace}.#{@domain_suffix}" cmd = add_cmd(fqdn, public_hostname) success = system cmd if not success raise DNSException.new("error adding app record #{fqdn}") end end
Generated with the Darkfish Rdoc Generator 2.