Sha256: 5d2e9827b26834e2d06c43e269cb6054aa8eed268dc43148904eeed074e7b901

Contents?: true

Size: 840 Bytes

Versions: 8

Compression:

Stored size: 840 Bytes

Contents

require 'i18n'

module VagrantPlugins
  module VCenter
    module Action
      # This class destroy the VM created by the Vagrant provider.
      class Destroy
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new('vagrant_vcenter::action::destroy')
        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('Destroying VM...')
          vm.Destroy_Task.wait_for_completion
          env[:machine].id = nil
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vagrant-vcenter-0.3.2 lib/vagrant-vcenter/action/destroy.rb
vagrant-vcenter-0.3.1 lib/vagrant-vcenter/action/destroy.rb
vagrant-vcenter-0.3.0 lib/vagrant-vcenter/action/destroy.rb
vagrant-vcenter-0.2.1 lib/vagrant-vcenter/action/destroy.rb
vagrant-vcenter-0.2.0 lib/vagrant-vcenter/action/destroy.rb
vagrant-vcenter-0.1.1 lib/vagrant-vcenter/action/destroy.rb
vagrant-vcenter-0.1.0 lib/vagrant-vcenter/action/destroy.rb
vagrant-vcenter-0.0.2.pre.dev lib/vagrant-vcenter/action/destroy.rb