lib/vagrant/command/provision.rb in vagrant-0.8.10 vs lib/vagrant/command/provision.rb in vagrant-0.9.0

- old
+ new

@@ -1,21 +1,34 @@ +require 'optparse' + module Vagrant module Command - class ProvisionCommand < NamedBase - register "provision", "Rerun the provisioning scripts on a running VM" - + class Provision < Base def execute - target_vms.each do |vm| + options = {} + + opts = OptionParser.new do |opts| + opts.banner = "Usage: vagrant provision [vm-name]" + end + + # Parse the options + argv = parse_options(opts) + return if !argv + + # Go over each VM and provision! + @logger.debug("'provision' each target VM...") + with_target_vms(argv[0]) do |vm| if vm.created? - if !vm.vm.accessible? - raise Errors::VMInaccessible - elsif vm.vm.running? + if vm.state == :running + @logger.info("Provisioning: #{vm.name}") vm.provision else - vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_running") + @logger.info("#{vm.name} not running. Not provisioning.") + vm.ui.info I18n.t("vagrant.commands.common.vm_not_running") end else - vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_created") + @logger.info("#{vm.name} not created. Not provisioning.") + vm.ui.info I18n.t("vagrant.commands.common.vm_not_created") end end end end end