Sha256: c3394aa8b0d3e93495970d2373a6e41418e1f5137e700d17426f1f69aad98969

Contents?: true

Size: 1.28 KB

Versions: 19

Compression:

Stored size: 1.28 KB

Contents

module VagrantPlugins
  module CommandDestroy
    class Command < Vagrant.plugin("2", :command)
      def self.synopsis
        "stops and deletes all traces of the vagrant machine"
      end

      def execute
        options = {}
        options[:force] = false

        opts = OptionParser.new do |o|
          o.banner = "Usage: vagrant destroy [options] [name|id]"
          o.separator ""
          o.separator "Options:"
          o.separator ""

          o.on("-f", "--force", "Destroy without confirmation.") do |f|
            options[:force] = f
          end
        end

        # Parse the options
        argv = parse_options(opts)
        return if !argv

        @logger.debug("'Destroy' each target VM...")
        declined = 0
        total    = 0
        with_target_vms(argv, reverse: true) do |vm|
          action_env = vm.action(
            :destroy, force_confirm_destroy: options[:force])

          total    += 1
          declined += 1 if action_env.key?(:force_confirm_destroy_result) &&
            action_env[:force_confirm_destroy_result] == false
        end

        # Nothing was declined
        return 0 if declined == 0

        # Everything was declined
        return 1 if declined == total

        # Some was declined
        return 2
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/plugins/commands/destroy/command.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/plugins/commands/destroy/command.rb
vagrant-unbundled-2.0.0.1 plugins/commands/destroy/command.rb
vagrant-unbundled-1.9.8.1 plugins/commands/destroy/command.rb
vagrant-unbundled-1.9.7.1 plugins/commands/destroy/command.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/destroy/command.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/destroy/command.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/destroy/command.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/commands/destroy/command.rb
vagrant-unbundled-1.9.5.1 plugins/commands/destroy/command.rb
vagrant-unbundled-1.9.1.1 plugins/commands/destroy/command.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/destroy/command.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/destroy/command.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/destroy/command.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/destroy/command.rb
vagrant-unbundled-1.8.5.2 plugins/commands/destroy/command.rb
vagrant-unbundled-1.8.5.1 plugins/commands/destroy/command.rb
vagrant-unbundled-1.8.4.2 plugins/commands/destroy/command.rb
vagrant-unbundled-1.8.4.1 plugins/commands/destroy/command.rb