Sha256: f3c9c0cce23d067955e210475b5b8f602f127ad8138acc58088fefdc8d9dc5b9

Contents?: true

Size: 902 Bytes

Versions: 5

Compression:

Stored size: 902 Bytes

Contents

require 'i18n'

module VagrantPlugins
  module VCenter
    module Action
      # This class powers on the VM that the Vagrant provider is managing.
      class PowerOn
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new('vagrant_vcenter::action::power_on')
        end

        def call(env)
          config = env[:machine].provider_config
          # FIXME: Raise a correct exception
          dc = config.vcenter_cnx.serviceInstance.find_datacenter(
               config.datacenter_name) or abort 'datacenter not found'
          root_vm_folder = dc.vmFolder
          vm = root_vm_folder.findByUuid(env[:machine].id)

          # Poweron VM
          env[:ui].info('Powering on VM...')
          vm.PowerOnVM_Task.wait_for_completion
          sleep(20) until env[:machine].communicate.ready?
          @app.call env
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vagrant-vcenter-0.3.2 lib/vagrant-vcenter/action/power_on.rb
vagrant-vcenter-0.3.1 lib/vagrant-vcenter/action/power_on.rb
vagrant-vcenter-0.3.0 lib/vagrant-vcenter/action/power_on.rb
vagrant-vcenter-0.2.1 lib/vagrant-vcenter/action/power_on.rb
vagrant-vcenter-0.2.0 lib/vagrant-vcenter/action/power_on.rb