Module: ForemanFogProxmox::ProxmoxConnection
- Included in:
- Proxmox
- Defined in:
- app/models/foreman_fog_proxmox/proxmox_connection.rb
Instance Method Summary collapse
- #access_ticket? ⇒ Boolean
- #connection_options ⇒ Object
- #credentials_valid? ⇒ Boolean
- #current_user_token_expire ⇒ Object
- #disconnect ⇒ Object
- #test_connection(options = {}) ⇒ Object
- #user_token? ⇒ Boolean
Instance Method Details
#access_ticket? ⇒ Boolean
31 32 33 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 31 def access_ticket? auth_method == 'access_ticket' end |
#connection_options ⇒ Object
24 25 26 27 28 29 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 24 def opts = super opts.store(:ssl_verify_peer, ssl_verify_peer) opts.store(:ssl_cert_store, certs_to_store) if Foreman::Cast.to_bool(ssl_verify_peer) opts end |
#credentials_valid? ⇒ Boolean
39 40 41 42 43 44 45 46 47 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 39 def credentials_valid? errors[:url].empty? && errors[:auth_method].empty? if access_ticket? errors[:user].empty? && errors[:user].include?('@') && errors[:password].empty? && errors[:node_id].empty? end if user_token? errors[:user].empty? && errors[:user].include?('@') && errors[:token_id].empty? && errors[:token].empty? && errors[:node_id].empty? end end |
#current_user_token_expire ⇒ Object
49 50 51 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 49 def current_user_token_expire identity_client ? identity_client.expires : 0 end |
#disconnect ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 67 def disconnect client.terminate if @client @client = nil identity_client.terminate if @identity_client @identity_client = nil network_client.terminate if @network_client @network_client = nil end |
#test_connection(options = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 53 def test_connection( = {}) super credentials_valid? identity_client version_suitable? rescue StandardError => e errors[:base] << e. if e..include?('SSL') errors[:ssl_certs] << e. else errors[:url] << e. end end |
#user_token? ⇒ Boolean
35 36 37 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 35 def user_token? auth_method == 'user_token' end |