From cf2f6da4dbcb4f57c9cdb3b94dcd0bba62c5f5fd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 9 Jun 2013 13:46:46 -0700 Subject: [PATCH] Validate an IP is given for a private network [GH-1788] --- CHANGELOG.md | 1 + plugins/kernel_v2/config/vm.rb | 8 ++++++++ templates/locales/en.yml | 2 ++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ada510468..bba9c9a50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ BUG FIXES: - `config.vm.guest` properly forces guests again. [GH-1800] - The `read_ip_address` capability for linux properly reads the IP of only the first network interface. [GH-1799] + - Validate that an IP is given for a private network. [GH-1788] ## 1.2.2 (April 23, 2013) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index e57042f61..e77cce812 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -385,6 +385,14 @@ module VagrantPlugins fp_host_ports.add(options[:host]) end end + + if type == :private_network + if options[:type] != :dhcp + if !options[:ip] + errors << I18n.t("vagrant.config.vm.network_ip_required") + end + end + end end # We're done with VM level errors so prepare the section diff --git a/templates/locales/en.yml b/templates/locales/en.yml index b5d423b0b..43f7ce41b 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -613,6 +613,8 @@ en: nfs_requires_host: |- Using NFS shared folders requires a host to be specified using `config.vagrant.host`. + network_ip_required: |- + An IP is required for a private network. network_fp_host_not_unique: |- Forwarded port '%{host}' (host port) is declared multiple times network_fp_requires_ports: |-