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
|
||||
Vagrant.commands.register(:destroy) { Vagrant::Command::Destroy }
|
||||
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 }
|
||||
|
||||
# Register the built-in config keys
|
||||
|
|
|
@ -4,6 +4,9 @@ module Vagrant
|
|||
|
||||
autoload :Destroy, 'vagrant/command/destroy'
|
||||
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'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,20 +1,33 @@
|
|||
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.vm.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
|
||||
|
|
|
@ -1,14 +1,27 @@
|
|||
require 'optparse'
|
||||
|
||||
module Vagrant
|
||||
module Command
|
||||
class ReloadCommand < NamedBase
|
||||
register "reload", "Reload the environment, halting it then restarting it."
|
||||
|
||||
class Reload < Base
|
||||
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?
|
||||
@logger.info("Reloading: #{vm.name}")
|
||||
vm.reload
|
||||
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
|
||||
|
|
|
@ -1,14 +1,27 @@
|
|||
require 'optparse'
|
||||
|
||||
module Vagrant
|
||||
module Command
|
||||
class ResumeCommand < NamedBase
|
||||
register "resume", "Resume a suspended Vagrant environment."
|
||||
|
||||
class Resume < Base
|
||||
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?
|
||||
@logger.info("Resume: #{vm.name}")
|
||||
vm.resume
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue