Sha256: 08e32d33dc1ef4ecdf1f5d2a4c30fd575fa02493b4be5a51d7b241182dbd4e50

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

require 'optparse'

module VagrantPlugins
  module CommandSnapshot
    module Command
      class Save < Vagrant.plugin("2", :command)
        def execute
          options = {}

          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant snapshot save [options] [vm-name] <name>"
            o.separator ""
            o.separator "Take a snapshot of the current state of the machine. The snapshot"
            o.separator "can be restored via `vagrant snapshot restore` at any point in the"
            o.separator "future to get back to this exact machine state."
            o.separator ""
            o.separator "Snapshots are useful for experimenting in a machine and being able"
            o.separator "to rollback quickly."
          end

          # Parse the options
          argv = parse_options(opts)
          return if !argv
          if argv.empty? || argv.length > 2
            raise Vagrant::Errors::CLIInvalidUsage,
              help: opts.help.chomp
          end

          name = argv.pop
          with_target_vms(argv) do |vm|
            vm.action(:snapshot_save, snapshot_name: name)
          end

          # Success, exit status 0
          0
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
vagrant-unbundled-1.9.5.1 plugins/commands/snapshot/command/save.rb
vagrant-unbundled-1.9.1.1 plugins/commands/snapshot/command/save.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/snapshot/command/save.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/snapshot/command/save.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/snapshot/command/save.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/commands/snapshot/command/save.rb
vagrant-unbundled-1.8.5.2 plugins/commands/snapshot/command/save.rb
vagrant-unbundled-1.8.5.1 plugins/commands/snapshot/command/save.rb
vagrant-unbundled-1.8.4.2 plugins/commands/snapshot/command/save.rb
vagrant-unbundled-1.8.4.1 plugins/commands/snapshot/command/save.rb
vagrant-unbundled-1.8.1.2 plugins/commands/snapshot/command/save.rb
vagrant-unbundled-1.8.1.1 plugins/commands/snapshot/command/save.rb