From 01e95ce31e136f1be16cc8c41af66810f582e2da Mon Sep 17 00:00:00 2001 From: Eric Putnam Date: Fri, 30 Sep 2016 13:24:58 -0700 Subject: [PATCH] in which cond logic is added to ssh.rb --- lib/vmfloaty/ssh.rb | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/vmfloaty/ssh.rb b/lib/vmfloaty/ssh.rb index 4ee4b8c..c07af51 100644 --- a/lib/vmfloaty/ssh.rb +++ b/lib/vmfloaty/ssh.rb @@ -21,22 +21,29 @@ class Ssh os_types = {} os_types[host_os] = 1 - response = Pooler.retrieve(verbose, os_types, token, url) - if response["ok"] == true - if host_os =~ /win/ - user = "Administrator" - else - user = "root" - end - - hostname = "#{response[host_os]["hostname"]}.#{response["domain"]}" - cmd = "#{ssh_path} #{user}@#{hostname}" - - # TODO: Should this respect more ssh settings? Can it be configured - # by users ssh config and does this respect those settings? + if host_os =~ /.*\..*/ + cmd = "#{ssh_path} root@#{host_os}" Kernel.exec(cmd) else - raise "Could not get vm from vmpooler:\n #{response}" + response = Pooler.retrieve(verbose, os_types, token, url) + + if response["ok"] == true + if host_os =~ /win/ + user = "Administrator" + else + user = "root" + end + + hostname = "#{response[host_os]["hostname"]}.#{response["domain"]}" + + cmd = "#{ssh_path} #{user}@#{hostname}" + + # TODO: Should this respect more ssh settings? Can it be configured + # by users ssh config and does this respect those settings? + Kernel.exec(cmd) + else + raise "Could not get vm from vmpooler:\n #{response}" + end end return end