-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathcommand.rb
67 lines (53 loc) · 1.78 KB
/
command.rb
1
2
3
4
5
6
7
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
require 'optparse'
require "vagrant"
require Vagrant.source_root.join("plugins/commands/up/start_mixins")
module VagrantPlugins
module CommandReload
class Command < Vagrant.plugin("2", :command)
# We assume that the `up` plugin exists and that we'll have access
# to this.
include VagrantPlugins::CommandUp::StartMixins
def self.synopsis
"restarts vagrant machine, loads new Vagrantfile configuration"
end
def execute
options = {}
options[:provision_ignore_sentinel] = false
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant reload [vm-name]"
o.separator ""
build_start_options(o, options)
o.on("-f", "--force", "Force shut down (equivalent of pulling power)") do |f|
options[:force_halt] = f
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
# Validate the provisioners
validate_provisioner_flags!(options, argv)
@logger.debug("'reload' each target VM...")
machines = []
with_target_vms(argv) do |machine|
machines << machine
machine.action(:reload, options)
end
# Output the post-up messages that we have, if any
machines.each do |m|
next if !m.config.vm.post_up_message
next if m.config.vm.post_up_message == ""
# Add a newline to separate things.
@env.ui.info("", prefix: false)
m.ui.success(I18n.t(
"vagrant.post_up_message",
name: m.name.to_s,
message: m.config.vm.post_up_message))
end
# Success, exit status 0
0
end
end
end
end