lib/poolparty/installers/vmware.rb in auser-poolparty-1.3.4 vs lib/poolparty/installers/vmware.rb in auser-poolparty-1.3.5

- old
+ new

@@ -57,23 +57,35 @@ def get_vm_ip ip_help =<<-EOV Right now, vmrun, the remoter base needs an explicitly set ip. Log into your vm and type ifconfig. Copy and paste that here. EOV - @ip = ask_with_help :message => "Now, what's the ip of your vm?", :help => ip_help + @ip = ask_with_help :message => "what's the ip of your vm?", :help => ip_help - puts @ip + if @ip =~ /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/ + @ip + else + colored_say "<red>You must enter a valid ip</red>" + get_vm_ip + end end def get_key key_help =<<-EOV Finally, we'll set somethings up here shortly, but first we'll need to know where your public key is. We'll assume it's at ~/.ssh/id_rsa.pub. If this is true, then just press enter. Otherwise, enter the path of your public key. EOV - ask_with_help :message => "What keypair would you like to use? (default: ~/.ssh/id_rsa.pub)", - :help => key_help do |k| - @key = k.empty? ? ::File.expand_path("~/.ssh/id_rsa.pub") : k + ask_with_help :message => "What keypair would you like to use? (default: ~/.ssh/id_rsa.pub)", :help => key_help do |responded_key| + responded_key = "~/.ssh/id_rsa.pub" if responded_key.empty? + + @key = File.expand_path(responded_key) + if File.file?(@key) + @key + else + colored_say "<red>You must enter a valid path to a keyfile</red>" + get_key + end end end def wait_for_connection ping_port_and(@ip, 22) do \ No newline at end of file