auger 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The Auger library implements a ruby DSL for describing tests to be run
4
4
  against remote applications on multiple servers. The gem includes
5
- 'aug', a multi-threaded command-line client.
5
+ 'aug', a multi-process command-line client.
6
6
 
7
7
  The primary goal of Auger is test-driven operations: unit testing for
8
8
  application admins. The library can also be used as a framework for
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0
1
+ 1.4.1
data/auger.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["rlister@gmail.com", "heffergm@gmail.com"]
7
7
  gem.description = %q{Auger: test-driven ops}
8
8
  gem.summary = %q{App && infrastructure testing DSL}
9
- gem.homepage = "https://rubygems.org/gems/auger"
9
+ gem.homepage = "https://github.com/brewster/auger"
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
12
12
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
data/bin/aug CHANGED
@@ -38,6 +38,11 @@ OptionParser.new do |opts|
38
38
  end.flatten.sort)
39
39
  exit
40
40
  end
41
+
42
+ opts.on('-T', '--tunnel [USER@]HOST', 'Set a [user@]host to use as ssh tunnel.') do |t|
43
+ options[:tunnel] = t
44
+ end
45
+
41
46
  end.parse!
42
47
 
43
48
  ## load plugins
@@ -88,6 +93,7 @@ end || ARGV[0]
88
93
  Auger::Config.load(cfg).projects.each do |project|
89
94
 
90
95
  servers = project.servers.map do |server|
96
+ server.options[:tunnel] = options[:tunnel]
91
97
 
92
98
  pipes = project.connections(*server.roles).map do |connection|
93
99
  read, write = IO.pipe
@@ -1,7 +1,8 @@
1
+ require 'net/ssh/gateway'
1
2
  module Auger
2
3
 
3
4
  class Connection
4
- attr_accessor :requests, :connection, :response, :roles, :options
5
+ attr_accessor :requests, :connection, :response, :roles, :options, :gateway
5
6
 
6
7
  def self.load(port, &block)
7
8
  connection = new(port)
@@ -29,9 +30,14 @@ module Auger
29
30
  @options[method] = arg
30
31
  end
31
32
 
32
- ## call plugin open() and return plugin-specific connection object, or exception
33
+ ## setup options and call appropriate connection open()
33
34
  def try_open(server)
34
- options = @options.merge(server.options)
35
+ options = @options.merge(server.options) # merge connection and server options
36
+ options[:tunnel] ? try_open_tunnel(server, options) : try_open_direct(server, options)
37
+ end
38
+
39
+ ## call plugin open() and return plugin-specific connection object, or exception
40
+ def try_open_direct(server, options)
35
41
  begin
36
42
  self.open(server.name, options)
37
43
  rescue => e
@@ -39,10 +45,25 @@ module Auger
39
45
  end
40
46
  end
41
47
 
48
+ ## call plugin open() via an ssh tunnel
49
+ def try_open_tunnel(server, options)
50
+ host, user = options[:tunnel].split('@').reverse #for ssh to the gateway host
51
+ user ||= ENV['USER']
52
+ begin
53
+ @gateway = Net::SSH::Gateway.new(host, user)
54
+ gateway.open(server.name, options[:port]) do |port|
55
+ self.open('127.0.0.1', options.merge({:port => port}))
56
+ end
57
+ rescue => e
58
+ e
59
+ end
60
+ end
61
+
42
62
  ## safe way to call plugin close() (rescue if the connection did not exist)
43
63
  def try_close(conn)
44
64
  begin
45
65
  self.close(conn)
66
+ @gateway.shutdown! if @gateway
46
67
  rescue => e
47
68
  e
48
69
  end
@@ -9,13 +9,11 @@ module Auger
9
9
  end
10
10
 
11
11
  class Dns < Auger::Connection
12
- def domain(&block)
13
- @requests << DnsDomainRequest.load(nil, &block)
14
- end
15
-
16
12
  def open(host, options)
17
13
  options[:nameserver] = host
18
- dns = Net::DNS::Resolver.new(options)
14
+ ## resolver checks args and raises error if no matching method, so only pass valid options
15
+ safe_options = options.select{ |key| Net::DNS::Resolver.method_defined? key }
16
+ dns = Net::DNS::Resolver.new(safe_options)
19
17
  dns.use_tcp = true if options[:use_tcp]
20
18
  dns
21
19
  end
@@ -24,19 +22,23 @@ module Auger
24
22
  dns = nil
25
23
  end
26
24
 
25
+ def domain(&block)
26
+ @requests << DnsDomainRequest.load(nil, &block)
27
+ end
28
+
27
29
  def query(name, &block)
28
30
  @requests << DnsQueryRequest.load(name, &block)
29
31
  end
30
32
  end
31
33
 
32
34
  class DnsDomainRequest < Auger::Request
33
- def run(dns)
35
+ def run(dns, ignored_arg)
34
36
  dns.domain
35
37
  end
36
38
  end
37
39
 
38
40
  class DnsQueryRequest < Auger::Request
39
- def run(dns)
41
+ def run(dns, ignored_arg)
40
42
  dns.query(@arg)
41
43
  end
42
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-24 00:00:00.000000000 Z
13
+ date: 2012-10-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -130,7 +130,7 @@ files:
130
130
  - lib/auger/status.rb
131
131
  - lib/auger/test.rb
132
132
  - lib/auger/version.rb
133
- homepage: https://rubygems.org/gems/auger
133
+ homepage: https://github.com/brewster/auger
134
134
  licenses: []
135
135
  post_install_message:
136
136
  rdoc_options: []
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  version: '0'
151
151
  requirements: []
152
152
  rubyforge_project:
153
- rubygems_version: 1.8.24
153
+ rubygems_version: 1.8.23
154
154
  signing_key:
155
155
  specification_version: 3
156
156
  summary: App && infrastructure testing DSL