2012-04-19 20:59:48 +00:00
|
|
|
require 'optparse'
|
|
|
|
|
2012-05-23 23:18:29 +00:00
|
|
|
require "vagrant"
|
|
|
|
|
|
|
|
require File.expand_path("../start_mixins", __FILE__)
|
|
|
|
|
2012-04-19 20:59:48 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module CommandUp
|
2012-11-07 05:05:14 +00:00
|
|
|
class Command < Vagrant.plugin("2", :command)
|
2012-04-20 04:33:26 +00:00
|
|
|
include StartMixins
|
2012-04-19 20:59:48 +00:00
|
|
|
|
|
|
|
def execute
|
|
|
|
options = {}
|
2013-08-29 19:12:53 +00:00
|
|
|
options[:destroy_on_error] = true
|
2013-04-16 22:22:14 +00:00
|
|
|
options[:parallel] = true
|
|
|
|
|
2012-08-15 05:38:41 +00:00
|
|
|
opts = OptionParser.new do |o|
|
2013-04-16 22:22:14 +00:00
|
|
|
o.banner = "Usage: vagrant up [vm-name] [options] [-h]"
|
2012-08-15 05:38:41 +00:00
|
|
|
o.separator ""
|
2012-11-08 05:45:09 +00:00
|
|
|
|
2012-08-15 05:38:41 +00:00
|
|
|
build_start_options(o, options)
|
2012-11-08 05:45:09 +00:00
|
|
|
|
2013-08-29 19:12:53 +00:00
|
|
|
o.on("--[no-]destroy-on-error",
|
|
|
|
"Destroy machine if any fatal error happens (default to true).") do |destroy|
|
|
|
|
options[:destroy_on_error] = destroy
|
|
|
|
end
|
|
|
|
|
2013-04-16 22:22:14 +00:00
|
|
|
o.on("--[no-]parallel",
|
|
|
|
"Enable or disable parallelism if provider supports it.") do |parallel|
|
|
|
|
options[:parallel] = parallel
|
|
|
|
end
|
|
|
|
|
2012-11-08 05:45:09 +00:00
|
|
|
o.on("--provider provider", String,
|
|
|
|
"Back the machine with a specific provider.") do |provider|
|
2012-12-24 05:23:08 +00:00
|
|
|
options[:provider] = provider
|
2012-11-08 05:45:09 +00:00
|
|
|
end
|
2012-04-19 20:59:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Parse the options
|
|
|
|
argv = parse_options(opts)
|
|
|
|
return if !argv
|
|
|
|
|
|
|
|
# Go over each VM and bring it up
|
|
|
|
@logger.debug("'Up' each target VM...")
|
2013-03-22 02:22:54 +00:00
|
|
|
|
|
|
|
# Build up the batch job of what we'll do
|
2013-04-16 22:22:14 +00:00
|
|
|
@env.batch(options[:parallel]) do |batch|
|
2013-03-22 02:22:54 +00:00
|
|
|
with_target_vms(argv, :provider => options[:provider]) do |machine|
|
|
|
|
@env.ui.info(I18n.t(
|
|
|
|
"vagrant.commands.up.upping",
|
|
|
|
:name => machine.name,
|
|
|
|
:provider => machine.provider_name))
|
|
|
|
|
2013-03-22 02:36:15 +00:00
|
|
|
batch.action(machine, :up, options)
|
2013-03-22 02:22:54 +00:00
|
|
|
end
|
2012-04-19 20:59:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Success, exit status 0
|
|
|
|
0
|
2012-08-15 05:38:41 +00:00
|
|
|
end
|
2012-04-19 20:59:48 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|