Class: VagrantPlugins::SoftLayer::Command::Rebuild

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-softlayer/command/rebuild.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vagrant-softlayer/command/rebuild.rb', line 7

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

  opts = OptionParser.new do |o|
    o.banner = "Usage: vagrant rebuild [vm-name]"
    o.separator ""

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

  argv = parse_options(opts)
  return if !argv

  declined = false
  with_target_vms(argv) do |vm|
    action_env = vm.action(:rebuild, :force_rebuild => options[:force], :provision_ignore_sentinel => false)
    declined = true if action_env.has_key?(:force_rebuild_result) && action_env[:force_rebuild_result] == false
  end

  declined ? 1 : 0
end