From 656f9f9056a59cca2edf7939d14390127eca152b Mon Sep 17 00:00:00 2001 From: elijah Date: Sun, 10 Feb 2013 12:31:08 -0800 Subject: moved vagrant config to Leapfile, added ~/.leaprc support. --- lib/leap_cli/leapfile.rb | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'lib/leap_cli/leapfile.rb') diff --git a/lib/leap_cli/leapfile.rb b/lib/leap_cli/leapfile.rb index 439b60c..c24f939 100644 --- a/lib/leap_cli/leapfile.rb +++ b/lib/leap_cli/leapfile.rb @@ -15,6 +15,11 @@ module LeapCli attr_accessor :custom_vagrant_vm_line attr_accessor :leap_version attr_accessor :log + attr_accessor :vagrant_network + + def initialize + @vagrant_network = '10.5.5.0/24' + end def load directory = File.expand_path(find_in_directory_tree('Leapfile')) @@ -22,8 +27,8 @@ module LeapCli return nil else self.provider_directory_path = directory - leapfile = directory + '/Leapfile' - instance_eval(File.read(leapfile), leapfile) + read_settings(directory + '/Leapfile') + read_settings(ENV['HOME'] + '/.leaprc') self.platform_directory_path = File.expand_path(self.platform_directory_path || '../leap_platform', self.provider_directory_path) return true end @@ -31,6 +36,14 @@ module LeapCli private + def read_settings(file) + if File.exists? file + Util::log 2, :read, file + instance_eval(File.read(file), file) + validate(file) + end + end + def find_in_directory_tree(filename) search_dir = Dir.pwd while search_dir != "/" @@ -41,6 +54,15 @@ module LeapCli end return search_dir end + + PRIVATE_IP_RANGES = /(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)/ + + def validate(file) + Util::assert! vagrant_network =~ PRIVATE_IP_RANGES do + Util::log 0, :error, "in #{file}: vagrant_network is not a local private network" + end + end + end end -- cgit v1.2.3