Module: ForemanFogProxmox::ProxmoxConnection
- Included in:
- Proxmox
- Defined in:
- app/models/foreman_fog_proxmox/proxmox_connection.rb
Instance Method Summary collapse
- #connection_options ⇒ Object
- #credentials_valid? ⇒ Boolean
- #disconnect ⇒ Object
- #fog_credentials ⇒ Object
- #test_connection(options = {}) ⇒ Object
Instance Method Details
#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
41 42 43 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 41 def credentials_valid? errors[:url].empty? && errors[:user].empty? && errors[:user].include?('@') && errors[:password].empty? && errors[:node_id].empty? end |
#disconnect ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 58 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 |
#fog_credentials ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 31 def fog_credentials credentials = { pve_url: url, pve_username: user, pve_password: password, connection_options: } ticket = Fog::Proxmox.credentials[:ticket] credentials.store(:pve_ticket, ticket) if renew credentials end |
#test_connection(options = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/foreman_fog_proxmox/proxmox_connection.rb', line 45 def test_connection( = {}) super credentials_valid? version_suitable? rescue StandardError => e errors[:base] << e. if e..include?('SSL') errors[:ssl_certs] << e. else errors[:url] << e. end end |