Module: Fog::Proxmox::Core

Included in:
Fog::Proxmox::Compute::Real, Identity::Real, Network::Real, Storage::Real
Defined in:
lib/fog/proxmox/core.rb

Overview

Core module

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auth_methodObject (readonly)

Returns the value of attribute auth_method.



29
30
31
# File 'lib/fog/proxmox/core.rb', line 29

def auth_method
  @auth_method
end

#current_userObject (readonly)

Returns the value of attribute current_user.



29
30
31
# File 'lib/fog/proxmox/core.rb', line 29

def current_user
  @current_user
end

#expiresObject (readonly)

Returns the value of attribute expires.



29
30
31
# File 'lib/fog/proxmox/core.rb', line 29

def expires
  @expires
end

#tokenObject

Returns the value of attribute token.



28
29
30
# File 'lib/fog/proxmox/core.rb', line 28

def token
  @token
end

Class Method Details

.not_found_classObject

fallback



36
37
38
# File 'lib/fog/proxmox/core.rb', line 36

def self.not_found_class
  Fog::Proxmox::Core::NotFound
end

Instance Method Details

#credentialsObject



68
69
70
71
72
73
74
75
76
# File 'lib/fog/proxmox/core.rb', line 68

def credentials
  options = {
    provider: 'proxmox',
    proxmox_auth_method: @auth_method,
    proxmox_url: @proxmox_uri.to_s,
    current_user: @current_user
  }
  proxmox_options.merge options
end

#initialize(options = {}) ⇒ Object



40
41
42
43
44
45
# File 'lib/fog/proxmox/core.rb', line 40

def initialize(options = {})
  setup(options)
  authenticate
  @auth_token.missing_credentials(options)
  @connection = Fog::Core::Connection.new(@proxmox_url, @persistent, @connection_options)
end

#reloadObject



78
79
80
# File 'lib/fog/proxmox/core.rb', line 78

def reload
  @connection.reset
end

#setup(options) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fog/proxmox/core.rb', line 47

def setup(options)
  if options.respond_to?(:config_service?) && options.config_service?
    configure(options)
    return
  end
  Fog::Proxmox::Variables.to_variables(self, options, 'proxmox')
  @connection_options = options[:connection_options] || {}
  @connection_options[:disable_proxy] = true if ENV['DISABLE_PROXY'] == 'true'
  @connection_options[:ssl_verify_peer] = false if ENV['SSL_VERIFY_PEER'] == 'false'
  @connection_options[:ignore_unexpected_eof] = true
  @proxmox_must_reauthenticate = true
  @persistent = options[:persistent] || false
  @token ||= options[:proxmox_token]
  @auth_method ||= options[:proxmox_auth_method]
  @proxmox_can_reauthenticate = if @token
                                  false
                                else
                                  true
                                end
end

#user_token?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/fog/proxmox/core.rb', line 31

def user_token?
  @auth_token == 'user_token'
end