Module: Cobbler::Connection::Handling::ClassMethods
- Defined in:
- lib/cobbler/connection/handling.rb
Instance Method Summary collapse
- #in_transaction(do_login = false, &blk) ⇒ Object
-
#login ⇒ Object
Logs into the Cobbler server.
- #logout ⇒ Object
-
#make_call(*args) ⇒ Object
Makes a remote call.
-
#remote_version ⇒ Object
Returns the version for the remote cobbler instance.
Instance Method Details
#in_transaction(do_login = false, &blk) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/cobbler/connection/handling.rb', line 69 def in_transaction(do_login=false,&blk) begin begin_transaction token = do_login ? login : nil result = yield(token) logout if do_login ensure end_transaction end result end |
#login ⇒ Object
Logs into the Cobbler server.
49 50 51 |
# File 'lib/cobbler/connection/handling.rb', line 49 def login @auth_token ||= make_call('login', username, password) end |
#logout ⇒ Object
53 54 55 56 |
# File 'lib/cobbler/connection/handling.rb', line 53 def logout make_call('logout',@auth_token) @auth_token = nil end |
#make_call(*args) ⇒ Object
Makes a remote call.
60 61 62 63 64 65 66 67 |
# File 'lib/cobbler/connection/handling.rb', line 60 def make_call(*args) raise Exception.new("No connection established on #{self.name}.") unless connection debug("Remote call: #{args.first} (#{args[1..-1].inspect})") result = connection.call(*args) debug("Result: #{result}\n") result end |
#remote_version ⇒ Object
Returns the version for the remote cobbler instance.
43 44 45 46 |
# File 'lib/cobbler/connection/handling.rb', line 43 def remote_version connect unless connection @version ||= make_call("version") end |