Class: Proxmox::Application::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/proxmox/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



8
9
10
11
12
13
14
15
# File 'lib/proxmox/configuration.rb', line 8

def initialize
  @endpoint = nil
  @base_path = nil
  @username = nil
  @password = nil
  @realm = nil
  @verbose = false
end

Instance Attribute Details

#base_pathObject

Returns the value of attribute base_path.



6
7
8
# File 'lib/proxmox/configuration.rb', line 6

def base_path
  @base_path
end

#endpointObject

Returns the value of attribute endpoint.



6
7
8
# File 'lib/proxmox/configuration.rb', line 6

def endpoint
  @endpoint
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/proxmox/configuration.rb', line 6

def password
  @password
end

#realmObject

Returns the value of attribute realm.



6
7
8
# File 'lib/proxmox/configuration.rb', line 6

def realm
  @realm
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/proxmox/configuration.rb', line 6

def username
  @username
end

#verboseObject

Returns the value of attribute verbose.



6
7
8
# File 'lib/proxmox/configuration.rb', line 6

def verbose
  @verbose
end

Instance Method Details

#credentials_paramsObject



17
18
19
20
21
22
23
# File 'lib/proxmox/configuration.rb', line 17

def credentials_params
  {
    username: @username,
    password: @password,
    realm: @realm
  }
end

#load_from_hash(hash) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/proxmox/configuration.rb', line 33

def load_from_hash(hash)
  raise InvalidConfiguration, 'Invalid configuration hash' if hash.empty?

  @endpoint = hash[:endpoint]
  @base_path = hash[:base_path]
  @username = hash[:username]
  @password = hash[:password]
  @realm = hash[:realm]
end

#load_from_path(path) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/proxmox/configuration.rb', line 43

def load_from_path(path)
  raise InvalidConfiguration, "no such file #{path}" unless File.exist?(path)

  hash = JSON.parse(File.read(path), symbolize_names: true)

  load_from_hash(hash)
end

#ssl_optionsObject



25
26
27
28
29
30
31
# File 'lib/proxmox/configuration.rb', line 25

def ssl_options
  {
    verify: false,
    verify_hostname: false,
    verify_mode: OpenSSL::SSL::VERIFY_NONE
  }
end