Class: VagrantPlugins::ProviderZone::Command::ConfigureSnapshots

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

Overview

This is used to configure snapshots for 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
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vagrant-zones/command/configure_snapshots.rb', line 8

def execute
  options = {}
  opts = OptionParser.new do |o|
    o.banner = 'Usage: vagrant zone zfssnapshot list [options]'
    o.on('--dataset DATASETPATH/ALL', 'Specify path to enable snapshots on, defaults to ALL') do |p|
      options[:dataset] = p
    end
    frequencymsg = 'Set a policy with one of the available optional frequencies'
    o.on('--set_frequency <hourly/daily/weekly/monthly/all>', frequencymsg) do |p|
      options[:set_frequency] = p
    end
    frequency_rtnmsg = 'Number of snapshots to take for the frequency policy'
    o.on('--set_frequency_rtn <#>/defaults ', frequency_rtnmsg) do |p|
      options[:set_frequency_rtn] = p
    end
    deletemsg = 'Delete frequency policy'
    o.on('--delete  <hourly/daily/weekly/monthly/all>', deletemsg) do |p|
      options[:delete] = p
    end
    listmsg = 'Show Cron Policies'
    o.on('--list  <hourly/daily/weekly/monthly/all>', listmsg) do |p|
      options[:list] = p
    end
  end

  argv = parse_options(opts)
  return unless argv

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

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