Sha256: 4a44a27f2044bf8613cca0153c56417e57b5e6e5a13bcd6b85723e3f5e80ee73

Contents?: true

Size: 946 Bytes

Versions: 4

Compression:

Stored size: 946 Bytes

Contents

module Veewee
  module Provider
    module Kvm
      module BoxCommand
        # Destroy a vm
        def destroy(options={})
          if @connection.servers.all(:name => name).nil?
            env.ui.error "Error:: You tried to destroy a non-existing box '#{name}'"
            exit -1
          end

          self.poweroff if running?
          destroy_vm if exists_vm?

          vol_exists=!@connection.volumes.all(:name => "#{name}.img").nil?
          env.logger.info "Volume exists? : #{vol_exists}"
          destroy_volume if exists_volume?
        end

        def destroy_vm
          matched_servers=@connection.servers.all(:name => name)
          matched_servers.first.destroy() unless matched_servers.nil?
        end

        def destroy_volume
          vol=@connection.volumes.all(:name => "#{name}.img").first
          vol.destroy
        end
      end # End Module

    end # End Module
  end # End Module
end # End Module

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veewee-0.3.0.alpha8 lib/veewee/provider/kvm/box/destroy.rb
veewee-0.3.0.alpha7 lib/veewee/provider/kvm/box/destroy.rb
veewee-0.3.0.alpha6 lib/veewee/provider/kvm/box/destroy.rb
veewee-0.3.0.alpha5 lib/veewee/provider/kvm/box/destroy.rb