Module: Cobbler::Connection::Handling::ClassMethods
- Defined in:
- lib/cobbler/connection/handling.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
Set hostname, username, password for the Cobbler server, overriding any settings from cobbler.yml.
-
#password ⇒ Object
Set hostname, username, password for the Cobbler server, overriding any settings from cobbler.yml.
-
#username ⇒ Object
Set hostname, username, password for the Cobbler server, overriding any settings from cobbler.yml.
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 Attribute Details
#hostname ⇒ Object
Set hostname, username, password for the Cobbler server, overriding any settings from cobbler.yml.
39 40 41 |
# File 'lib/cobbler/connection/handling.rb', line 39 def hostname @hostname end |
#password ⇒ Object
Set hostname, username, password for the Cobbler server, overriding any settings from cobbler.yml.
39 40 41 |
# File 'lib/cobbler/connection/handling.rb', line 39 def password @password end |
#username ⇒ Object
Set hostname, username, password for the Cobbler server, overriding any settings from cobbler.yml.
39 40 41 |
# File 'lib/cobbler/connection/handling.rb', line 39 def username @username end |
Instance Method Details
#in_transaction(do_login = false, &blk) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/cobbler/connection/handling.rb', line 68 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.
48 49 50 |
# File 'lib/cobbler/connection/handling.rb', line 48 def login @auth_token ||= make_call('login', username, password) end |
#logout ⇒ Object
52 53 54 55 |
# File 'lib/cobbler/connection/handling.rb', line 52 def logout make_call('logout',@auth_token) @auth_token = nil end |
#make_call(*args) ⇒ Object
Makes a remote call.
59 60 61 62 63 64 65 66 |
# File 'lib/cobbler/connection/handling.rb', line 59 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.
42 43 44 45 |
# File 'lib/cobbler/connection/handling.rb', line 42 def remote_version connect unless connection @version ||= make_call("version") end |