File: test_ssh.rb

package info (click to toggle)
ruby-train 3.13.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,208 kB
  • sloc: ruby: 10,002; sh: 17; makefile: 8
file content (38 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# author: Dominik Richter

require_relative "helper"
require "train"
require "logger"

backends = {}
backend_conf = {
  "target" => ENV["target"] || "vagrant@localhost",
  "key_files" => ENV["key_files"] || "/root/.ssh/id_rsa",
  "logger" => Logger.new($stdout),
}

backend_conf["target"] = "ssh://" + backend_conf["target"]
backend_conf["logger"].level = \
  if ENV.key?("debug")
    case ENV["debug"].to_s
    when /^false$/i, /^0$/i
      Logger::INFO
    else
      Logger::DEBUG
    end
  else
    Logger::INFO
  end

backends[:ssh] = proc { |*args|
  conf = Train.target_config(backend_conf)
  Train.create("ssh", conf).connection(args[0])
}

tests = ARGV

backends.each do |type, get_backend|
  tests.each do |test|
    instance_eval(File.read(test), test, 1)
  end
end