Class: VagrantPlugins::ProviderZone::Command::DeleteSnapshots

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-zones/command/delete_snapshots.rb

Overview

This is used to delete zfs snapshots the zone

Instance Method Summary collapse

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vagrant-zones/command/delete_snapshots.rb', line 8

def execute
  options = {}
  opts = OptionParser.new do |o|
    o.banner = 'Usage: vagrant zone zfssnapshot list [options]'
    o.on('--dataset DATASETPATH', '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?
  options[:snapshot_name] = 'all' if options[:snapshot_name].nil?
  with_target_vms(argv, provider: :zone) do |machine|
    driver = machine.provider.driver
    driver.zfs(@env.ui, 'destroy', options)
  end
end