Class: DnsResolvableController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- DnsResolvableController
- Defined in:
- app/controllers/dns_resolvable_controller.rb
Constant Summary
Constants inherited from BaseController
BaseController::API_VERSION, BaseController::SUPPORTED_API_VERSIONS
Instance Method Summary collapse
-
#show ⇒ Object
GET /domains//applications/<id>/dns_resolvable.
Methods included from UserActionLogger
#get_action_logger, #log_action
Instance Method Details
#show ⇒ Object
GET /domains//applications/<id>/dns_resolvable
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/dns_resolvable_controller.rb', line 9 def show domain_id = params[:domain_id] id = params[:application_id] domain = Domain.get(@cloud_user, domain_id) return render_error(:not_found, "Domain #{domain_id} not found", 127, "DNS_RESOLVABLE") if !domain || !domain.hasAccess?(@cloud_user) @domain_name = domain.namespace application = Application.find(@cloud_user,id) return render_error(:not_found, "Application '#{id}' not found", 101, "DNS_RESOLVABLE") unless application @application_name = application.name @application_uuid = application.uuid name = "#{application.name}-#{application.domain.namespace}.#{Rails.configuration.openshift[:domain_suffix]}" nameservers = NameServerCache.get_name_servers dns = Dnsruby::Resolver.new(:nameserver => nameservers[rand(nameservers.length)]) begin dns.query(name, Dnsruby::Types.A) render_success(:ok, "boolean", true, "DNS_RESOLVABLE", "Resolved DNS #{name}") rescue render_error(:not_found, "Could not resolve DNS #{name}", 170, "DNS_RESOLVABLE") end end |