module RHN::Session

Represent the RHN Satellite XML-RPC server

Attributes

exception[RW]

Instance methods

Public Class Methods

running?(host, ssl) click to toggle source
# File lib/satops/rhsat.rb, line 6
def self.running?(host, ssl)
  server=XMLRPC::Client.new(host, @@path, nil, nil, nil, nil, nil, ssl, 30)
  server.call('api.getVersion')
rescue Errno::ECONNREFUSED => e
  puts "FATAL: #{host}: #{e}"
  exit
end

Public Instance Methods

connect(sat) click to toggle source
# File lib/satops/rhsat.rb, line 18
def connect(sat)
  @server=XMLRPC::Client.new(@host.name, @@path, nil, nil, nil, nil, nil, @ssl, 90)
  @session=@server.call('auth.login', sat.login, sat.auth)
  @exception=nil
end
exec(*params) click to toggle source
# File lib/satops/rhsat.rb, line 33
def exec(*params) # command, session
  begin
    result=@server.call(*params)
    @log.debug("API-RETURN => #{params.inspect}")
  rescue XMLRPC::FaultException => e
    @exception=e
    @log.debug e.faultCode.to_s+':' + e.faultString
  end
  return result
end
exec_async(*params) click to toggle source

Async call will reconnect if needed

# File lib/satops/rhsat.rb, line 45
def exec_async(*params)  # command, session
  begin
    result=@server.call_async(*params)
    @log.debug("API-RETURN:#{params.inspect}")
  rescue XMLRPC::FaultException => e
    @exception=e
    @log.debug e.faultCode.to_s+':' + e.faultString
  end
  return result
end
get(command) click to toggle source
# File lib/satops/rhsat.rb, line 24
def get(command)
  self.exec_async(command)
end
get_exception() click to toggle source
# File lib/satops/rhsat.rb, line 56
def get_exception
  "RHN API Exception:#{@exception.faultCode.to_s}:#{@exception.faultString}" if @exception
end
run(command, *params) click to toggle source
# File lib/satops/rhsat.rb, line 28
def run(command, *params)
  @log.debug("API-CALL:#{command} => #{params.inspect}")
  self.exec_async(command, @session, *params)
end
terminate() click to toggle source
# File lib/satops/rhsat.rb, line 60
def terminate
  @server.call_async('auth.logout', @session)
end