Provision, reload, resume
This commit is contained in:
parent
6c7e88c3ec
commit
c5ec4b4a30
|
@ -96,6 +96,9 @@ I18n.load_path << File.expand_path("templates/locales/en.yml", Vagrant.source_ro
|
||||||
# Register the built-in commands
|
# Register the built-in commands
|
||||||
Vagrant.commands.register(:destroy) { Vagrant::Command::Destroy }
|
Vagrant.commands.register(:destroy) { Vagrant::Command::Destroy }
|
||||||
Vagrant.commands.register(:halt) { Vagrant::Command::Halt }
|
Vagrant.commands.register(:halt) { Vagrant::Command::Halt }
|
||||||
|
Vagrant.commands.register(:provision) { Vagrant::Command::Provision }
|
||||||
|
Vagrant.commands.register(:reload) { Vagrant::Command::Reload }
|
||||||
|
Vagrant.commands.register(:resume) { Vagrant::Command::Resume }
|
||||||
Vagrant.commands.register(:up) { Vagrant::Command::Up }
|
Vagrant.commands.register(:up) { Vagrant::Command::Up }
|
||||||
|
|
||||||
# Register the built-in config keys
|
# Register the built-in config keys
|
||||||
|
|
|
@ -4,6 +4,9 @@ module Vagrant
|
||||||
|
|
||||||
autoload :Destroy, 'vagrant/command/destroy'
|
autoload :Destroy, 'vagrant/command/destroy'
|
||||||
autoload :Halt, 'vagrant/command/halt'
|
autoload :Halt, 'vagrant/command/halt'
|
||||||
|
autoload :Provision, 'vagrant/command/provision'
|
||||||
|
autoload :Reload, 'vagrant/command/reload'
|
||||||
|
autoload :Resume, 'vagrant/command/resume'
|
||||||
autoload :Up, 'vagrant/command/up'
|
autoload :Up, 'vagrant/command/up'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,20 +1,33 @@
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Command
|
module Command
|
||||||
class ProvisionCommand < NamedBase
|
class Provision < Base
|
||||||
register "provision", "Rerun the provisioning scripts on a running VM"
|
|
||||||
|
|
||||||
def execute
|
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.created?
|
||||||
if !vm.vm.accessible?
|
if vm.vm.running?
|
||||||
raise Errors::VMInaccessible
|
@logger.info("Provisioning: #{vm.name}")
|
||||||
elsif vm.vm.running?
|
|
||||||
vm.provision
|
vm.provision
|
||||||
else
|
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
|
end
|
||||||
else
|
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
|
end
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Command
|
module Command
|
||||||
class ReloadCommand < NamedBase
|
class Reload < Base
|
||||||
register "reload", "Reload the environment, halting it then restarting it."
|
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
target_vms.each do |vm|
|
options = {}
|
||||||
|
|
||||||
|
opts = OptionParser.new do |opts|
|
||||||
|
opts.banner = "Usage: vagrant reload [vm-name]"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Parse the options
|
||||||
|
argv = parse_options(opts)
|
||||||
|
return if !argv
|
||||||
|
|
||||||
|
@logger.debug("'reload' each target VM...")
|
||||||
|
with_target_vms(argv[0]) do |vm|
|
||||||
if vm.created?
|
if vm.created?
|
||||||
|
@logger.info("Reloading: #{vm.name}")
|
||||||
vm.reload
|
vm.reload
|
||||||
else
|
else
|
||||||
vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
@logger.info("Not created: #{vm.name}. Not reloading.")
|
||||||
|
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Command
|
module Command
|
||||||
class ResumeCommand < NamedBase
|
class Resume < Base
|
||||||
register "resume", "Resume a suspended Vagrant environment."
|
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
target_vms.each do |vm|
|
options = {}
|
||||||
|
|
||||||
|
opts = OptionParser.new do |opts|
|
||||||
|
opts.banner = "Usage: vagrant resume [vm-name]"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Parse the options
|
||||||
|
argv = parse_options(opts)
|
||||||
|
return if !argv
|
||||||
|
|
||||||
|
@logger.debug("'resume' each target VM...")
|
||||||
|
with_target_vms(argv[0]) do |vm|
|
||||||
if vm.created?
|
if vm.created?
|
||||||
|
@logger.info("Resume: #{vm.name}")
|
||||||
vm.resume
|
vm.resume
|
||||||
else
|
else
|
||||||
vm.env.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
@logger.info("Not created: #{vm.name}. Not resuming.")
|
||||||
|
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue