class PulpProxy::PulpcoreClient

Public Class Methods

capabilities() click to toggle source
# File lib/smart_proxy_pulp_plugin/pulpcore_client.rb, line 17
def self.capabilities
  body = JSON.parse(get("/pulp/api/v3/status/").body)
  body['versions'].map { |item| item['component'] }
rescue StandardError => e
  logger.error("Could not fetch capabilities: #{e.message}")
  []
end
get(path) click to toggle source
# File lib/smart_proxy_pulp_plugin/pulpcore_client.rb, line 10
def self.get(path)
  uri = URI.parse(pulp_url)
  req = Net::HTTP::Get.new(URI.join("#{uri.to_s.chomp('/')}/", path))
  req.add_field('Accept', 'application/json')
  http.request(req)
end
http() click to toggle source
# File lib/smart_proxy_pulp_plugin/pulpcore_client.rb, line 29
def self.http
  ssl_ca = ::PulpProxy::PulpcorePlugin.settings.ssl_ca ||
           ::Proxy::SETTINGS.foreman_ssl_ca ||
           ::Proxy::SETTINGS.ssl_ca_file
  uri = URI.parse(pulp_url)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = uri.scheme == 'https'
  http.ca_file = ssl_ca if http.use_ssl? && ssl_ca && !ssl_ca.empty?
  http
end
logger() click to toggle source
# File lib/smart_proxy_pulp_plugin/pulpcore_client.rb, line 25
def self.logger
  Proxy::LoggerFactory.logger
end
pulp_url() click to toggle source
# File lib/smart_proxy_pulp_plugin/pulpcore_client.rb, line 40
def self.pulp_url
  ::PulpProxy::PulpcorePlugin.settings.pulp_url.to_s
end