Project

General

Profile

« Previous | Next » 

Revision 7cdaddab

Added by Shlomi Zadok over 8 years ago

fixes #12714 - Show proxy status in index, and create a show page for proxy

View differences:

app/models/smart_proxy.rb
scoped_search :on => :url, :complete_value => :true
scoped_search :in => :features, :on => :name, :rename => :feature, :complete_value => :true
delegate :version, :tftp_server, :to => :proxy_status
# with proc support, default_scope can no longer be chained
# include all default scoping here
default_scope lambda {
......
scope :with_features, ->(*feature_names) { where(:features => { :name => feature_names }).joins(:features) if feature_names.any? }
HTTP_ERRORS = [Errno::EINVAL, Errno::ECONNRESET, EOFError, Timeout::Error,
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError]
def hostname
URI(url).host
end
......
end
def refresh
proxy_status.revoke_cache!
associate_features
errors
end
......
self.features.any? { |proxy_feature| proxy_feature.name == feature }
end
def version
result = {}
begin
Timeout::timeout(20) do
version = ProxyAPI::Version.new(:url => url).version
result[:success] = true
result[:message] = version
end
rescue *HTTP_ERRORS => exception
raise ::Foreman::WrappedException.new exception, N_("Unable to connect to smart proxy")
end
result
end
private
def proxy_status
@proxy_status ||= ProxyStatus.new(self)
end
def sanitize_url
self.url.chomp!('/') unless url.empty?
end

Also available in: Unified diff