Module: Cobbler::Connection::Handling::ClassMethods

Defined in:
lib/cobbler/connection/handling.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostnameObject

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

#passwordObject

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

#usernameObject

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(=false,&blk)
    begin
        begin_transaction
        token =  ?  : nil 
        result = yield(token)
        logout if 
    ensure
        end_transaction
    end
    result
end

#loginObject

Logs into the Cobbler server.



48
49
50
# File 'lib/cobbler/connection/handling.rb', line 48

def 
    @auth_token ||= make_call('login', username, password)
end

#logoutObject



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.

Raises:

  • (Exception)


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_versionObject

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