Module: RHN::Session
- Included in:
- Satellite
- Defined in:
- lib/satops/rhsat.rb
Overview
Represent the RHN Satellite XML-RPC server
Constant Summary collapse
- @@path =
"/rpc/api"
Instance Attribute Summary collapse
-
#exception ⇒ Object
Instance methods.
Class Method Summary collapse
Instance Method Summary collapse
- #connect(sat) ⇒ Object
-
#exec(*params) ⇒ Object
command, session.
-
#exec_async(*params) ⇒ Object
Async call will reconnect if needed.
- #get(command) ⇒ Object
- #get_exception ⇒ Object
- #run(command, *params) ⇒ Object
- #terminate ⇒ Object
Instance Attribute Details
#exception ⇒ Object
Instance methods
16 17 18 |
# File 'lib/satops/rhsat.rb', line 16 def exception @exception end |
Class Method Details
.running?(host, ssl) ⇒ Boolean
6 7 8 9 10 11 12 |
# 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 |
Instance Method Details
#connect(sat) ⇒ Object
18 19 20 21 22 |
# 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) ⇒ Object
command, session
33 34 35 36 37 38 39 40 41 42 |
# 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) ⇒ Object
Async call will reconnect if needed
45 46 47 48 49 50 51 52 53 54 |
# 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) ⇒ Object
24 25 26 |
# File 'lib/satops/rhsat.rb', line 24 def get(command) self.exec_async(command) end |
#get_exception ⇒ Object
56 57 58 |
# 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) ⇒ Object
28 29 30 31 |
# 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 ⇒ Object
60 61 62 |
# File 'lib/satops/rhsat.rb', line 60 def terminate @server.call_async('auth.logout', @session) end |