Class: VagrantPlugins::Proxmox::Action::StartVm
- Inherits:
-
ProxmoxAction
- Object
- ProxmoxAction
- VagrantPlugins::Proxmox::Action::StartVm
- Defined in:
- lib/vagrant-proxmox/action/start_vm.rb
Overview
This action starts a Proxmox virtual machine.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ StartVm
constructor
A new instance of StartVm.
Constructor Details
#initialize(app, env) ⇒ StartVm
Returns a new instance of StartVm.
8 9 10 11 |
# File 'lib/vagrant-proxmox/action/start_vm.rb', line 8 def initialize app, env @app = app @logger = Log4r::Logger.new 'vagrant_proxmox::action::start_vm' end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant-proxmox/action/start_vm.rb', line 13 def call env endpoint = env[:machine].provider_config.endpoint node, vm_id = env[:machine].id.split '/' env[:ui].info I18n.t('vagrant_proxmox.starting_vm') response = RestClient.post "#{endpoint}/nodes/#{node}/openvz/#{vm_id}/status/start", nil, {CSRFPreventionToken: env[:proxmox_csrf_prevention_token], cookies: {PVEAuthCookie: env[:proxmox_ticket]}} wait_for_completion parse_task_id(response), node, env, 'vagrant_proxmox.errors.start_vm_timeout' env[:ui].info I18n.t('vagrant_proxmox.done') env[:ui].info I18n.t('vagrant_proxmox.waiting_for_ssh_connection') loop do # If we're interrupted then just back out break if env[:interrupted] break if env[:machine].communicate.ready? sleep env[:machine].provider_config.task_status_check_interval end env[:ui].info I18n.t('vagrant_proxmox.done') next_action env end |