lib/gogetit/util.rb in gogetit-0.4.2 vs lib/gogetit/util.rb in gogetit-0.5.0

- old
+ new

@@ -99,11 +99,11 @@ logger.info("Calling <#{__method__.to_s}> for ping to be ready..") sleep 3 end logger.info("#{fqdn} is now available to ping..") - until ssh_available?(fqdn, 'ubuntu') + until ssh_available?(fqdn, 'ubuntu', logger) logger.info("Calling <#{__method__.to_s}> for ssh to be ready..") sleep 3 end logger.info("#{fqdn} is now available to ssh..") end @@ -113,11 +113,12 @@ logger.info("Calling <#{__method__.to_s}> for #{host}") `ping -c 1 -W 1 #{host}` $?.exitstatus == 0 end - def ssh_available?(fqdn, user) + def ssh_available?(fqdn, user, logger) + logger.info("Calling <#{__method__.to_s}>") begin Net::SSH.start(fqdn, user).class rescue Exception => e puts e end @@ -134,7 +135,17 @@ abort("one of #{addresses.join(', ')} is already being used.") \ unless ifaces return ifaces end + def run_through_ssh(host, commands, logger) + logger.info("Calling <#{__method__.to_s}>") + Net::SSH.start(host, 'ubuntu') do |ssh| + commands.each do |cmd| + logger.info("'#{cmd}' is being executed..") + output = ssh.exec!(cmd) + puts output if output != '' + end + end + end end end