Sha256: d0eb8132db38e2e1bfe3a5f9e5e106c630f97138cc094ea1f0747d0c8453613c

Contents?: true

Size: 1.38 KB

Versions: 54

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

module VagrantPlugins
  module ProviderZone
    module Command
      # This is used to create zfs snapshots the zone
      class CreateSnapshots < Vagrant.plugin('2', :command)
        def execute
          options = {}
          opts = OptionParser.new do |o|
            o.banner = 'Usage: vagrant zone zfssnapshot list [options]'
            o.on('--dataset SNAPSHOTPATH', 'Specify snapshot path') do |p|
              options[:dataset] = p
            end
            o.on('--snapshot_name @SNAPSHOTNAME', 'Specify snapshot name') do |p|
              options[:snapshot_name] = p
            end
          end

          argv = parse_options(opts)
          return unless argv

          unless argv.length <= 4
            @env.ui.info(opts.help)
            return
          end

          options[:dataset] = 'all' if options[:dataset].nil?

          if options[:snapshot_name].nil?
            t = Time.new
            dash = '-'
            colon = ':'
            datetime = t.year.to_s + dash + t.month.to_s + dash + t.day.to_s + dash + t.hour.to_s + colon + t.min.to_s + colon + t.sec.to_s
            options[:snapshot_name] = datetime
          end

          with_target_vms(argv, provider: :zone) do |machine|
            driver = machine.provider.driver
            driver.zfs(@env.ui, 'create', options)
          end
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
vagrant-zones-0.1.77 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.76 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.75 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.73 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.72 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.71 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.70 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.69 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.67 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.66 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.65 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.64 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.63 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.62 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.61 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.60 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.59 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.58 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.57 lib/vagrant-zones/command/create_snapshots.rb
vagrant-zones-0.1.56 lib/vagrant-zones/command/create_snapshots.rb