lib/engineyard-visualvm/cli.rb in engineyard-visualvm-0.5.1 vs lib/engineyard-visualvm/cli.rb in engineyard-visualvm-0.5.2

- old
+ new

@@ -120,19 +120,25 @@ File.expand_path('../lib/tools.jar', java_home)].detect do |path| File.readable?(path) end end - # Return the public IP assigned to an environment (which may or - # may not be a booted cluster of instances) Displays error and - # exits if no public IP assigned to the environment + # Return the public IP or instance hostname assigned to an + # environment (which may or may not be a booted cluster of + # instances) Displays error and exits if no public IP assigned + # to the environment def fetch_public_ip(environment) - unless environment.load_balancer_ip_address - warn "#{environment.account.name}/#{environment.name} has no assigned public IP address." + if environment.load_balancer_ip_address + return environment.load_balancer_ip_address end - environment.load_balancer_ip_address + if environment.instances.length == 1 && environment.instances.first.public_hostname + return environment.instances.first.public_hostname + end + + warn "#{environment.account.name}/#{environment.name} has no assigned public IP address or hostname." + nil end end class CLI < Thor include EY::UtilityMethods @@ -171,18 +177,22 @@ visualvm_args = [] if ssh? ssh_dest = ssh_host + unless system "ssh #{ssh_dest} true" + warn "Error establishing ssh connection; make sure you can `ssh #{ssh_dest}'." + exit 3 + end if socks_proxy? proxy_port = next_free_port visualvm_args += ["-J-Dnetbeans.system_socks_proxy=localhost:#{proxy_port}", "-J-Djava.net.useSystemProxies=true"] @ssh_process = ChildProcess.build("ssh", "-ND", proxy_port.to_s, ssh_dest) else server_host, server_port = host, port @host, @port = "localhost", next_free_port - @ssh_process = ChildProcess.build("ssh", "-NL", "#{@port}:#{@host}:#{server_port}", "#{ssh_dest}") + @ssh_process = ChildProcess.build("ssh", "-NL", "#{@port}:#{@host}:#{server_port}", ssh_dest) end @ssh_process.start end