From c80ad123369c7dec89c43bffe677bb64330da891 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 1 Mar 2013 17:20:31 -0800 Subject: [PATCH] Validate forwarded ports --- plugins/kernel_v2/config/vm.rb | 11 +++++++++++ templates/locales/en.yml | 2 ++ 2 files changed, 13 insertions(+) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 406e207aa..26eb53c89 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -245,6 +245,17 @@ module VagrantPlugins end end + # Validate networks + has_fp_port_error = false + networks.each do |type, options| + if type == :forwarded_port + if !has_fp_port_error && (!options[:guest] || !options[:host]) + errors << I18n.t("vagrant.config.vm.network_fp_requires_ports") + has_fp_port_error = true + end + end + end + # We're done with VM level errors so prepare the section errors = { "vm" => errors } diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 3f04c3195..804a323dd 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -444,6 +444,8 @@ en: nfs_requires_host: |- Using NFS shared folders requires a host to be specified using `config.vagrant.host`. + network_fp_requires_ports: |- + Forwarded port definitions require a "host" and "guest" value shared_folder_hostpath_missing: |- The host path of the shared folder is missing: %{path} shared_folder_nfs_owner_group: |-