Class: VagrantPlugins::Proxmox::Action::ConnectProxmox
- Inherits:
-
ProxmoxAction
- Object
- ProxmoxAction
- VagrantPlugins::Proxmox::Action::ConnectProxmox
- Defined in:
- lib/vagrant-proxmox/action/connect_proxmox.rb
Overview
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ConnectProxmox
constructor
A new instance of ConnectProxmox.
Constructor Details
#initialize(app, env) ⇒ ConnectProxmox
Returns a new instance of ConnectProxmox.
10 11 12 13 |
# File 'lib/vagrant-proxmox/action/connect_proxmox.rb', line 10 def initialize app, env @app = app @logger = Log4r::Logger.new 'vagrant_proxmox::action::connect_proxmox' end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vagrant-proxmox/action/connect_proxmox.rb', line 15 def call env config = env[:machine].provider_config response = RestClient.post "#{config.endpoint}/access/ticket", username: config.user_name, password: config.password begin json_response = JSON.parse response.to_s, symbolize_names: true env[:proxmox_ticket] = json_response[:data][:ticket] env[:proxmox_csrf_prevention_token] = json_response[:data][:CSRFPreventionToken] rescue => e raise Errors::CommunicationError, error_msg: e. end next_action env end |