I18nified all the VM actions
This commit is contained in:
parent
bf27d783cc
commit
1d29ba31fa
|
@ -22,18 +22,16 @@ module Vagrant
|
|||
end
|
||||
|
||||
def boot
|
||||
@env.ui.info "Booting VM..."
|
||||
@env.ui.info "vagrant.actions.vm.boot.booting"
|
||||
@env["vm"].vm.start(@env.env.config.vm.boot_mode)
|
||||
end
|
||||
|
||||
def wait_for_boot
|
||||
@env.ui.info "Waiting for VM to boot..."
|
||||
@env.ui.info "vagrant.actions.vm.boot.waiting"
|
||||
|
||||
@env.env.config.ssh.max_tries.to_i.times do |i|
|
||||
@env.ui.info "Trying to connect (attempt ##{i+1} of #{@env.env.config[:ssh][:max_tries]})..."
|
||||
|
||||
if @env["vm"].ssh.up?
|
||||
@env.ui.info "VM booted and ready for use!"
|
||||
@env.ui.info "vagrant.actions.vm.boot.ready"
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -44,7 +42,7 @@ module Vagrant
|
|||
sleep 5 if !@env["vagrant.test"]
|
||||
end
|
||||
|
||||
@env.ui.error "Failed to connect to VM! Failed to boot?"
|
||||
@env.ui.error "vagrant.actions.vm.boot.failed"
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ module Vagrant
|
|||
box_url = env["config"].vm.box_url
|
||||
return env.error!(:box_specified_doesnt_exist, :box_name => box_name) if !box_url
|
||||
|
||||
env.ui.info "Box #{box_name} not found. Fetching box since URL specified..."
|
||||
env.ui.info "vagrant.actions.vm.check_box.not_found", :name => box_name
|
||||
Vagrant::Box.add(env.env, box_name, box_url)
|
||||
env.env.load_box!
|
||||
end
|
||||
|
|
|
@ -16,11 +16,11 @@ module Vagrant
|
|||
# doesn't support guest properties (due to cross platform issues)
|
||||
version = env["vm"].vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version")
|
||||
if version.empty?
|
||||
env.ui.warn Translator.t(:vm_additions_not_detected)
|
||||
env.ui.warn "vagrant.actions.vm.check_guest_additions.not_detected"
|
||||
elsif version != VirtualBox.version
|
||||
env.ui.warn Translator.t(:vm_additions_version_mismatch,
|
||||
:guest_additions_version => version,
|
||||
:virtualbox_version => VirtualBox.version)
|
||||
env.ui.warn("vagrant.actions.vm.check_guest_additions.version_mismatch",
|
||||
:guest_version => version,
|
||||
:virtualbox_version => VirtualBox.version)
|
||||
end
|
||||
|
||||
# Continue
|
||||
|
|
|
@ -19,7 +19,7 @@ module Vagrant
|
|||
|
||||
def clear
|
||||
if used_ports.length > 0
|
||||
@env.ui.info "Deleting any previously set forwarded ports..."
|
||||
@env.ui.info "vagrant.actions.vm.clear_forward_ports.deleting"
|
||||
clear_ports
|
||||
@env["vm"].reload!
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Vagrant
|
|||
|
||||
def clear_shared_folders
|
||||
if @env["vm"].vm.shared_folders.length > 0
|
||||
@env.ui.info "Clearing previously set shared folders..."
|
||||
@env.ui.info "vagrant.actions.vm.clear_shared_folders.deleting"
|
||||
|
||||
folders = @env["vm"].vm.shared_folders.dup
|
||||
folders.each do |shared_folder|
|
||||
|
|
|
@ -8,7 +8,7 @@ module Vagrant
|
|||
|
||||
def call(env)
|
||||
if !env.env.config.vm.proc_stack.empty?
|
||||
env.ui.info "Running any VM customizations..."
|
||||
env.ui.info "vagrant.actions.vm.customize.running"
|
||||
env.env.config.vm.run_procs!(env["vm"].vm)
|
||||
env["vm"].vm.save
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
def call(env)
|
||||
env.ui.info "Destroying VM and associated drives..."
|
||||
env.ui.info "vagrant.actions.vm.destroy.destroying"
|
||||
env["vm"].vm.destroy(:destroy_medium => :delete)
|
||||
env["vm"].vm = nil
|
||||
env.env.update_dotfile
|
||||
|
|
|
@ -21,7 +21,7 @@ module Vagrant
|
|||
# Destroy the network interface if there is only one
|
||||
# attached VM (which must be this VM)
|
||||
if interface.attached_vms.length == 1
|
||||
env.ui.info "Destroying unused network interface..."
|
||||
env.ui.info "vagrant.actions.vm.destroy_network.destroying"
|
||||
interface.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Vagrant
|
|||
next if adapter.attachment_type != :host_only
|
||||
|
||||
if !logged
|
||||
env.ui.info "Disabling host only networks..."
|
||||
env.ui.info "vagrant.actions.vm.disable_networks.disabling"
|
||||
logged = true
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Vagrant
|
|||
|
||||
def call(env)
|
||||
if env["vm"].vm.saved?
|
||||
env.ui.info "Discarding saved state of VM..."
|
||||
env.ui.info "vagrant.actions.vm.discard_state.discarding"
|
||||
env["vm"].vm.discard_state
|
||||
end
|
||||
|
||||
|
|
|
@ -31,13 +31,13 @@ module Vagrant
|
|||
end
|
||||
|
||||
def setup_temp_dir
|
||||
@env.ui.info "Creating temporary directory for export..."
|
||||
@env.ui.info "vagrant.actions.vm.export.create_dir"
|
||||
@temp_dir = @env["export.temp_dir"] = File.join(@env.env.tmp_path, Time.now.to_i.to_s)
|
||||
FileUtils.mkpath(@env["export.temp_dir"])
|
||||
end
|
||||
|
||||
def export
|
||||
@env.ui.info "Exporting VM to #{ovf_path}..."
|
||||
@env.ui.info "vagrant.actions.vm.export.exporting"
|
||||
@env["vm"].vm.export(ovf_path) do |progress|
|
||||
@env.ui.report_progress(progress.percent, 100, false)
|
||||
end
|
||||
|
|
|
@ -67,7 +67,9 @@ module Vagrant
|
|||
existing_ports << options[:hostport]
|
||||
|
||||
# Notify the user
|
||||
@env.ui.info "Fixed port collision: #{name} now on port #{options[:hostport]}"
|
||||
@env.ui.info("vagrant.actions.vm.forward_ports.fixed_collision",
|
||||
:name => name,
|
||||
:new_port => options[:hostport])
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------
|
||||
|
@ -82,20 +84,25 @@ module Vagrant
|
|||
end
|
||||
|
||||
def forward_ports
|
||||
@env.ui.info "Forwarding ports..."
|
||||
@env.ui.info "vagrant.actions.vm.forward_ports.forwarding"
|
||||
|
||||
@env.env.config.vm.forwarded_ports.each do |name, options|
|
||||
adapter = options[:adapter]
|
||||
message_attributes = {
|
||||
:name => name,
|
||||
:guest_port => options[:guestport],
|
||||
:host_port => options[:hostport],
|
||||
:adapter => adapter + 1
|
||||
}
|
||||
|
||||
# Assuming the only reason to establish port forwarding is because the VM is using Virtualbox NAT networking.
|
||||
# Host-only or Bridged networking don't require port-forwarding and establishing forwarded ports on these
|
||||
# attachment types has uncertain behaviour.
|
||||
if @env["vm"].vm.network_adapters[adapter].attachment_type == :nat
|
||||
@env.ui.info "Forwarding \"#{name}\": #{options[:guestport]} on adapter \##{adapter+1} => #{options[:hostport]}"
|
||||
@env.ui.info("vagrant.actions.vm.forward_ports.forwarding_entry", message_attributes)
|
||||
forward_port(name, options)
|
||||
else
|
||||
@env.ui.info "VirtualBox adapter \##{adapter+1} not configured as \"NAT\"."
|
||||
@env.ui.info "Skipped port forwarding \"#{name}\": #{options[:guestport]} on adapter\##{adapter+1} => #{options[:hostport]}"
|
||||
@env.ui.info("vagrant.actions.vm.forward_ports.non_nat", message_attributes)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
if env["vm"].vm.state(true) != :powered_off
|
||||
env.ui.info "Forcing shutdown of VM..."
|
||||
env.ui.info "vagrant.actions.vm.halt.force"
|
||||
env["vm"].vm.stop
|
||||
end
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
def call(env)
|
||||
env.ui.info "Importing base VM (#{env.env.box.ovf_file})"
|
||||
env.ui.info "vagrant.actions.vm.import.importing", :name => env.env.box.name
|
||||
|
||||
# Import the virtual machine
|
||||
env.env.vm.vm = VirtualBox::VM.import(env.env.box.ovf_file) do |progress|
|
||||
|
|
|
@ -7,7 +7,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
def call(env)
|
||||
env.ui.info "Matching MAC addresses..."
|
||||
env.ui.info "vagrant.actions.vm.match_mac.matching"
|
||||
env["vm"].vm.network_adapters.first.mac_address = env.env.config.vm.base_mac
|
||||
env["vm"].vm.save
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ module Vagrant
|
|||
|
||||
if !env.error? && enable_network?
|
||||
catch_action_exception(env) do
|
||||
@env.ui.info "Enabling host only network..."
|
||||
@env.ui.info "vagrant.actions.vm.network.enabling"
|
||||
@env["vm"].system.prepare_host_only_network
|
||||
@env.env.config.vm.network_options.compact.each do |network_options|
|
||||
@env["vm"].system.enable_host_only_network(network_options)
|
||||
|
@ -61,7 +61,7 @@ module Vagrant
|
|||
# Enables and assigns the host only network to the proper
|
||||
# adapter on the VM, and saves the adapter.
|
||||
def assign_network
|
||||
@env.ui.info "Preparing host only network..."
|
||||
@env.ui.info "vagrant.actions.vm.network.preparing"
|
||||
|
||||
@env.env.config.vm.network_options.compact.each do |network_options|
|
||||
adapter = @env["vm"].vm.network_adapters[network_options[:adapter]]
|
||||
|
@ -93,7 +93,7 @@ module Vagrant
|
|||
return @env.error!(:network_not_found, :name => net_options[:name]) if net_options[:name]
|
||||
|
||||
# One doesn't exist, create it.
|
||||
@env.ui.info "Creating new host only network for environment..."
|
||||
@env.ui.info "vagrant.actions.vm.network.creating"
|
||||
|
||||
ni = interfaces.create
|
||||
ni.enable_static(network_ip(net_options[:ip], net_options[:netmask]),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.join(File.dirname(__FILE__), 'nfs_helpers')
|
||||
require File.expand_path("../nfs_helpers", __FILE__)
|
||||
|
||||
module Vagrant
|
||||
class Action
|
||||
|
@ -104,7 +104,7 @@ module Vagrant
|
|||
# involves adding a line to `/etc/exports` for this VM, but it is
|
||||
# up to the host class to define the specific behavior.
|
||||
def export_folders
|
||||
@env.ui.info "Exporting NFS shared folders..."
|
||||
@env.ui.info "vagrant.actions.vm.nfs.exporting"
|
||||
|
||||
catch_action_exception(@env) do
|
||||
@env["host"].nfs_export(guest_ip, folders)
|
||||
|
@ -113,7 +113,7 @@ module Vagrant
|
|||
|
||||
# Uses the system class to mount the NFS folders.
|
||||
def mount_folders
|
||||
@env.ui.info "Mounting NFS shared folders..."
|
||||
@env.ui.info "vagrant.actions.vm.nfs.mounting"
|
||||
|
||||
catch_action_exception(@env) do
|
||||
@env["vm"].system.mount_nfs(host_ip, folders)
|
||||
|
|
|
@ -11,7 +11,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
def call(env)
|
||||
env.ui.info "Persisting the VM UUID (#{env["vm"].uuid})"
|
||||
env.ui.info "vagrant.actions.vm.persist.persisting", :uuid => env["vm"].uuid
|
||||
env.env.update_dotfile
|
||||
|
||||
@app.call(env)
|
||||
|
|
|
@ -13,7 +13,7 @@ module Vagrant
|
|||
@app.call(env)
|
||||
|
||||
if !env.error? && provisioning_enabled?
|
||||
@env.ui.info "Beginning provisioning process..."
|
||||
@env.ui.info "vagrant.actions.vm.provision.beginning"
|
||||
@provisioner.provision!
|
||||
end
|
||||
end
|
||||
|
@ -40,7 +40,7 @@ module Vagrant
|
|||
@provisioner = provisioner_klass.new(@env)
|
||||
end
|
||||
|
||||
@env.ui.info "Provisioning enabled with #{@provisioner.class}"
|
||||
@env.ui.info "vagrant.actions.vm.provision.enabled", :provisioner => provisioner.class.to_s
|
||||
@provisioner.prepare
|
||||
@provisioner
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Vagrant
|
|||
|
||||
def call(env)
|
||||
if env["vm"].vm.saved?
|
||||
env.ui.info "Resuming suspended VM..."
|
||||
env.ui.info "vagrant.actions.vm.resume.resuming"
|
||||
env["actions"].run(Boot)
|
||||
end
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
def create_metadata
|
||||
@env.ui.info "Creating shared folders metadata..."
|
||||
@env.ui.info "vagrant.actions.vm.share_folders.creating"
|
||||
|
||||
shared_folders.each do |name, data|
|
||||
folder = VirtualBox::SharedFolder.new
|
||||
|
@ -73,11 +73,13 @@ module Vagrant
|
|||
end
|
||||
|
||||
def mount_shared_folders
|
||||
@env.ui.info "Mounting shared folders..."
|
||||
@env.ui.info "vagrant.actions.vm.share_folders.mounting"
|
||||
|
||||
@env["vm"].ssh.execute do |ssh|
|
||||
shared_folders.each do |name, data|
|
||||
@env.ui.info "-- #{name}: #{data[:guestpath]}"
|
||||
@env.ui.info("vagrant.actions.vm.share_folders.mounting_entry",
|
||||
:name => name,
|
||||
:guest_path => data[:guestpath])
|
||||
@env["vm"].system.mount_shared_folder(ssh, name, data[:guestpath])
|
||||
end
|
||||
end
|
||||
|
@ -89,7 +91,7 @@ module Vagrant
|
|||
@env["vm"].ssh.execute do |ssh|
|
||||
@env["vm"].system.prepare_unison(ssh)
|
||||
|
||||
@env.ui.info "Creating unison crontab entries..."
|
||||
@env.ui.info "vagrant.actions.vm.share_folders.setup_unison"
|
||||
unison_folders.each do |name, data|
|
||||
@env["vm"].system.create_unison(ssh, data)
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Vagrant
|
|||
|
||||
def call(env)
|
||||
if env["vm"].vm.running?
|
||||
env.ui.info "Saving VM state and suspending execution..."
|
||||
env.ui.info "vagrant.actions.vm.suspend.suspending"
|
||||
env["vm"].vm.save_state
|
||||
end
|
||||
|
||||
|
|
|
@ -81,3 +81,85 @@ en:
|
|||
This environment represents multiple VMs. The VMs are all listed
|
||||
above with their current state. For more information about a specific
|
||||
VM, run `vagrant status NAME`.
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Translations for Vagrant middleware acions
|
||||
#-------------------------------------------------------------------------------
|
||||
actions:
|
||||
vm:
|
||||
boot:
|
||||
booting: Booting VM...
|
||||
waiting: Waiting for VM to boot. This can take a few minutes.
|
||||
ready: VM booted and ready for use!
|
||||
failed: Failed to connect to VM!
|
||||
check_box:
|
||||
not_found: Box %{name} was not found. Fetching box from specified URL...
|
||||
check_guest_additions:
|
||||
not_detected: |-
|
||||
No guest additions were detected on the base box for this VM! Guest
|
||||
additions are required for forwarded ports, shared folders, host only
|
||||
networking, and more. If SSH fails on this machine, please install
|
||||
the guest additions and repackage the box to continue.
|
||||
|
||||
This is not an error message; everything may continue to work properly,
|
||||
in which case you may ignore this message.
|
||||
version_mismatch: |-
|
||||
The guest additions on this VM do not match the install version of
|
||||
VirtualBox! This may cause things such as forwared ports, shared
|
||||
folders, and more to not work properly. If any of those things fail on
|
||||
this machine, please update the guest additions and repackage the
|
||||
box.
|
||||
|
||||
Guest Additions Version: %{guest_version}
|
||||
VirtualBox Version: %{virtualbox_version}
|
||||
clear_forward_ports:
|
||||
deleting: Clearing any previously set forwarded ports...
|
||||
clear_shared_folders:
|
||||
deleting: Cleaing previously set shared folders...
|
||||
customize:
|
||||
running: Running any VM customizations...
|
||||
destroy:
|
||||
destroying: Destroying VM and associated drives...
|
||||
destroy_network:
|
||||
destroying: Destroying unused networking interface...
|
||||
disable_networks:
|
||||
disabling: Disabling host only networks...
|
||||
discard_state:
|
||||
discarding: Discarding saved state of VM...
|
||||
export:
|
||||
create_dir: Creating temporary directory for export...
|
||||
exporting: Exporting VM...
|
||||
forward_ports:
|
||||
fixed_collision: Fixed port collision '%{name}'. Now on port %{new_port}.
|
||||
forwarding: Forwarding ports...
|
||||
forwarding_entry: "-- %{name}: %{guest_port} => %{host_port} (adapter %{adapter})"
|
||||
non_nat: |-
|
||||
VirtualBox adapter #%{adapter} not configured as "NAT"
|
||||
Skipping port forwarding '%{name}'.
|
||||
halt:
|
||||
force: Forcing shutdown of VM...
|
||||
import:
|
||||
importing: Importing base box '%{name}'...
|
||||
match_mac:
|
||||
matching: Matching MAC address for NAT networking...
|
||||
network:
|
||||
enabling: Enabling host only network...
|
||||
preparing: Preparing host only network...
|
||||
creating: Creating new host only network for environment...
|
||||
nfs:
|
||||
exporting: Exporting NFS shared folders...
|
||||
mounting: Mounting NFS shared folders...
|
||||
persist:
|
||||
persisting: Persisting the VM UUID (%{uuid})...
|
||||
provision:
|
||||
beginning: Beginning provisioning process...
|
||||
enabled: Provisioning enabled with %{provisioner}...
|
||||
resume:
|
||||
resuming: Resuming suspended VM...
|
||||
share_folders:
|
||||
creating: Creating shared folders metadata...
|
||||
mounting: Mounting shared folders...
|
||||
mounting_entry: "-- %{name}: %{guest_path}"
|
||||
setup_unison: Creating unison crontab entries...
|
||||
suspend:
|
||||
suspending: Saving VM state and suspending execution...
|
||||
|
|
|
@ -4,26 +4,6 @@
|
|||
# In short, | means keep new lines, trim whitespace left and right
|
||||
# The |- does the above, but trims the new line at the end of all text
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# CATEGORY: Warning Messages
|
||||
#---------------------------------------------------------------------
|
||||
:vm_additions_not_detected: |-
|
||||
WARNING!
|
||||
No guest additions were detected on the base box for this VM! Guest
|
||||
additions are required for forwarded ports, shared folders, host only
|
||||
networking, and more. If SSH fails on this machine, please install
|
||||
the guest additions and repackage the box to continue.
|
||||
:vm_additions_version_mismatch: |-
|
||||
WARNING!
|
||||
The guest additions on this VM do not match the install version of
|
||||
VirtualBox! This often causes things such as forwared ports, shared
|
||||
folders, and more to not work properly. If any of those things fail on
|
||||
this machine, please update the guest additions and repackage the
|
||||
box.
|
||||
|
||||
Guest Additions Version: <%= guest_additions_version %>
|
||||
VirtualBox Version: <%= virtualbox_version %>
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# CATEGORY: Error Messages
|
||||
#---------------------------------------------------------------------
|
||||
|
|
|
@ -8,6 +8,7 @@ class ImportVMActionTest < Test::Unit::TestCase
|
|||
|
||||
ovf_file = "foo"
|
||||
@box = mock("box")
|
||||
@box.stubs(:name).returns("foo")
|
||||
@box.stubs(:ovf_file).returns(ovf_file)
|
||||
@env.env.stubs(:box).returns(@box)
|
||||
|
||||
|
|
Loading…
Reference in New Issue