class Proxy::Spacewalk::SpacewalkClient

Attributes

key[R]
login[R]
password[R]
url[R]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/smart_proxy_spacewalk/spacewalk_client.rb, line 9
def initialize(opts = {})
  @url = opts[:url]
  @login = opts[:login]
  @password = opts[:password]
  client.instance_variable_get(:@http).verify_mode = OpenSSL::SSL::VERIFY_NONE
end

Public Instance Methods

delete_host(hostname) click to toggle source
# File lib/smart_proxy_spacewalk/spacewalk_client.rb, line 25
def delete_host(hostname)
  id = get_host_id_by_hostname(hostname)
  client.call('system.deleteSystem', key, id)
end
get_host_id_by_hostname(hostname) click to toggle source
# File lib/smart_proxy_spacewalk/spacewalk_client.rb, line 16
def get_host_id_by_hostname(hostname)
  systems = client.call('system.search.hostname', key, hostname)
  system_ids = systems.map { |system| system['id'] }
  id = system_ids.first
  raise ::Proxy::Spacewalk::HostNotFound unless id
  logger.debug "Spacewalk: Resolved hostname #{hostname} to ID #{id}"
  id
end
login!() click to toggle source
# File lib/smart_proxy_spacewalk/spacewalk_client.rb, line 30
def login!
  logger.debug "Spacewalk: Login with username #{login}."
  @key = client.call('auth.login', login, password)
end
logout!() click to toggle source
# File lib/smart_proxy_spacewalk/spacewalk_client.rb, line 35
def logout!
  return unless key
  logger.debug "Spacewalk: Logout."
  client.call('auth.logout', key)
  @key = nil
end

Private Instance Methods

client() click to toggle source
# File lib/smart_proxy_spacewalk/spacewalk_client.rb, line 44
def client
  @client ||= XMLRPC::Client.new2(url)
end