ztk 1.6.2 → 1.6.3
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/Gemfile +1 -0
- data/Rakefile +1 -1
- data/lib/ztk/command.rb +14 -160
- data/lib/ztk/command/download.rb +16 -0
- data/lib/ztk/command/exec.rb +139 -0
- data/lib/ztk/command/private.rb +26 -0
- data/lib/ztk/command/upload.rb +16 -0
- data/lib/ztk/locator.rb +13 -0
- data/lib/ztk/report.rb +11 -155
- data/lib/ztk/report/list.rb +67 -0
- data/lib/ztk/report/private.rb +44 -0
- data/lib/ztk/report/spreadsheet.rb +72 -0
- data/lib/ztk/ssh.rb +20 -114
- data/lib/ztk/ssh/bootstrap.rb +1 -1
- data/lib/ztk/ssh/console.rb +28 -0
- data/lib/ztk/ssh/core.rb +37 -0
- data/lib/ztk/ssh/download.rb +2 -2
- data/lib/ztk/ssh/file.rb +1 -1
- data/lib/ztk/ssh/private.rb +67 -0
- data/lib/ztk/ssh/upload.rb +2 -2
- data/lib/ztk/ui.rb +14 -0
- data/lib/ztk/version.rb +1 -1
- data/spec/ztk/logger_spec.rb +1 -1
- data/spec/ztk/ssh_spec.rb +8 -8
- metadata +18 -2
data/lib/ztk/ssh/file.rb
CHANGED
@@ -30,7 +30,7 @@ module ZTK
|
|
30
30
|
tempfile = Tempfile.new("tempfile")
|
31
31
|
|
32
32
|
local_tempfile = tempfile.path
|
33
|
-
remote_tempfile = ::File.join(
|
33
|
+
remote_tempfile = ::File.join(ZTK::Locator.root, "tmp", ::File.basename(local_tempfile))
|
34
34
|
|
35
35
|
::File.open(local_tempfile, 'w') do |file|
|
36
36
|
yield(file)
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module ZTK
|
2
|
+
class SSH
|
3
|
+
|
4
|
+
# SSH Private Functionality
|
5
|
+
module Private
|
6
|
+
|
7
|
+
# Builds our SSH options hash.
|
8
|
+
def ssh_options
|
9
|
+
options = {}
|
10
|
+
|
11
|
+
# These are plainly documented on the Net::SSH config class.
|
12
|
+
options.merge!(:encryption => config.encryption) if config.encryption
|
13
|
+
options.merge!(:compression => config.compression) if config.compression
|
14
|
+
options.merge!(:compression_level => config.compression_level) if config.compression_level
|
15
|
+
options.merge!(:timeout => config.timeout) if config.timeout
|
16
|
+
options.merge!(:forward_agent => config.forward_agent) if config.forward_agent
|
17
|
+
options.merge!(:global_known_hosts_file => config.global_known_hosts_file) if config.global_known_hosts_file
|
18
|
+
options.merge!(:auth_methods => config.auth_methods) if config.auth_methods
|
19
|
+
options.merge!(:host_key => config.host_key) if config.host_key
|
20
|
+
options.merge!(:host_key_alias => config.host_key_alias) if config.host_key_alias
|
21
|
+
options.merge!(:host_name => config.host_name) if config.host_name
|
22
|
+
options.merge!(:keys => config.keys) if config.keys
|
23
|
+
options.merge!(:keys_only => config.keys_only) if config.keys_only
|
24
|
+
options.merge!(:hmac => config.hmac) if config.hmac
|
25
|
+
options.merge!(:port => config.port) if config.port
|
26
|
+
options.merge!(:proxy => Net::SSH::Proxy::Command.new(proxy_command)) if config.proxy_host_name
|
27
|
+
options.merge!(:rekey_limit => config.rekey_limit) if config.rekey_limit
|
28
|
+
options.merge!(:user => config.user) if config.user
|
29
|
+
options.merge!(:user_known_hosts_file => config.user_known_hosts_file) if config.user_known_hosts_file
|
30
|
+
|
31
|
+
# This is not plainly documented on the Net::SSH config class.
|
32
|
+
options.merge!(:password => config.password) if config.password
|
33
|
+
|
34
|
+
config.ui.logger.debug { "ssh_options(#{options.inspect})" }
|
35
|
+
options
|
36
|
+
end
|
37
|
+
|
38
|
+
# Builds a human readable tag about our connection. Used for internal
|
39
|
+
# logging purposes.
|
40
|
+
def tag
|
41
|
+
tags = Array.new
|
42
|
+
|
43
|
+
if config.proxy_host_name
|
44
|
+
proxy_user_host = "#{config.proxy_user}@#{config.proxy_host_name}"
|
45
|
+
proxy_port = (config.proxy_port ? ":#{config.proxy_port}" : nil)
|
46
|
+
tags << [proxy_user_host, proxy_port].compact.join
|
47
|
+
tags << " >>> "
|
48
|
+
end
|
49
|
+
|
50
|
+
user_host = "#{config.user}@#{config.host_name}"
|
51
|
+
port = (config.port ? ":#{config.port}" : nil)
|
52
|
+
tags << [user_host, port].compact.join
|
53
|
+
|
54
|
+
tags.join.strip
|
55
|
+
end
|
56
|
+
|
57
|
+
def log_header(what)
|
58
|
+
count = 8
|
59
|
+
sep = ("=" * count)
|
60
|
+
header = [sep, "[ #{what} ]", sep, "[ #{tag} ]", sep, "[ #{what} ]", sep].join
|
61
|
+
"#{header}\n"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
data/lib/ztk/ssh/upload.rb
CHANGED
@@ -13,8 +13,8 @@ module ZTK
|
|
13
13
|
# config.user = ENV["USER"]
|
14
14
|
# config.host_name = "127.0.0.1"
|
15
15
|
# end
|
16
|
-
# local = File.expand_path(File.join(
|
17
|
-
# remote = File.expand_path(File.join("
|
16
|
+
# local = File.expand_path(File.join(Dir.home, ".ssh", "id_rsa.pub"))
|
17
|
+
# remote = File.expand_path(File.join(ZTK::Locator.root, "tmp", "id_rsa.pub"))
|
18
18
|
# ssh.upload(local, remote)
|
19
19
|
#
|
20
20
|
# @param [String] local The local file/path you wish to upload from.
|
data/lib/ztk/ui.rb
CHANGED
@@ -17,6 +17,9 @@ module ZTK
|
|
17
17
|
|
18
18
|
attr_accessor :stdout, :stderr, :stdin, :logger
|
19
19
|
|
20
|
+
attr_accessor :verbose
|
21
|
+
attr_accessor :quiet
|
22
|
+
|
20
23
|
def initialize(configuration={})
|
21
24
|
defined?(Rails) and (rails_logger = Rails.logger)
|
22
25
|
null_logger = (::ZTK::Logger.new("/dev/null") rescue ::Logger.new("/dev/null"))
|
@@ -30,6 +33,17 @@ module ZTK
|
|
30
33
|
(@stderr && @stderr.respond_to?(:sync=)) and @stderr.sync = true
|
31
34
|
(@stdin && @stdin.respond_to?(:sync=)) and @stdin.sync = true
|
32
35
|
(@logger && @logger.respond_to?(:sync=)) and @logger.sync = true
|
36
|
+
|
37
|
+
@verbose = (configuration[:verbose] || false)
|
38
|
+
@quiet = (configuration[:quiet] || false)
|
39
|
+
end
|
40
|
+
|
41
|
+
def verbose?
|
42
|
+
(@verbose == true)
|
43
|
+
end
|
44
|
+
|
45
|
+
def quiet?
|
46
|
+
(@quiet == true)
|
33
47
|
end
|
34
48
|
|
35
49
|
end
|
data/lib/ztk/version.rb
CHANGED
data/spec/ztk/logger_spec.rb
CHANGED
data/spec/ztk/ssh_spec.rb
CHANGED
@@ -241,10 +241,10 @@ describe ZTK::SSH do
|
|
241
241
|
|
242
242
|
data = "Hello World @ #{Time.now.utc}"
|
243
243
|
|
244
|
-
remote_file = File.join("
|
244
|
+
remote_file = File.join(ZTK::Locator.root, "tmp", "ssh-upload-remote")
|
245
245
|
File.exists?(remote_file) && File.delete(remote_file)
|
246
246
|
|
247
|
-
local_file = File.join("
|
247
|
+
local_file = File.join(ZTK::Locator.root, "tmp", "ssh-upload-local")
|
248
248
|
if RUBY_VERSION < "1.9.3"
|
249
249
|
File.open(local_file, 'w') do |file|
|
250
250
|
file.puts(data)
|
@@ -275,10 +275,10 @@ describe ZTK::SSH do
|
|
275
275
|
|
276
276
|
data = "Hello World @ #{Time.now.utc}"
|
277
277
|
|
278
|
-
local_file = File.join("
|
278
|
+
local_file = File.join(ZTK::Locator.root, "tmp", "ssh-download-local")
|
279
279
|
File.exists?(local_file) && File.delete(local_file)
|
280
280
|
|
281
|
-
remote_file = File.join("
|
281
|
+
remote_file = File.join(ZTK::Locator.root, "tmp", "ssh-download-remote")
|
282
282
|
if RUBY_VERSION < "1.9.3"
|
283
283
|
File.open(remote_file, 'w') do |file|
|
284
284
|
file.puts(data)
|
@@ -523,10 +523,10 @@ describe ZTK::SSH do
|
|
523
523
|
|
524
524
|
data = "Hello World @ #{Time.now.utc}"
|
525
525
|
|
526
|
-
remote_file = File.join("
|
526
|
+
remote_file = File.join(ZTK::Locator.root, "tmp", "ssh-upload-remote")
|
527
527
|
File.exists?(remote_file) && File.delete(remote_file)
|
528
528
|
|
529
|
-
local_file = File.join("
|
529
|
+
local_file = File.join(ZTK::Locator.root, "tmp", "ssh-upload-local")
|
530
530
|
if RUBY_VERSION < "1.9.3"
|
531
531
|
File.open(local_file, 'w') do |file|
|
532
532
|
file.puts(data)
|
@@ -559,10 +559,10 @@ describe ZTK::SSH do
|
|
559
559
|
|
560
560
|
data = "Hello World @ #{Time.now.utc}"
|
561
561
|
|
562
|
-
local_file = File.join("
|
562
|
+
local_file = File.join(ZTK::Locator.root, "tmp", "ssh-download-local")
|
563
563
|
File.exists?(local_file) && File.delete(local_file)
|
564
564
|
|
565
|
-
remote_file = File.join("
|
565
|
+
remote_file = File.join(ZTK::Locator.root, "tmp", "ssh-download-remote")
|
566
566
|
if RUBY_VERSION < "1.9.3"
|
567
567
|
File.open(remote_file, 'w') do |file|
|
568
568
|
file.puts(data)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -196,6 +196,10 @@ files:
|
|
196
196
|
- lib/ztk/base.rb
|
197
197
|
- lib/ztk/benchmark.rb
|
198
198
|
- lib/ztk/command.rb
|
199
|
+
- lib/ztk/command/download.rb
|
200
|
+
- lib/ztk/command/exec.rb
|
201
|
+
- lib/ztk/command/private.rb
|
202
|
+
- lib/ztk/command/upload.rb
|
199
203
|
- lib/ztk/config.rb
|
200
204
|
- lib/ztk/dsl.rb
|
201
205
|
- lib/ztk/dsl/base.rb
|
@@ -215,14 +219,20 @@ files:
|
|
215
219
|
- lib/ztk/parallel.rb
|
216
220
|
- lib/ztk/pty.rb
|
217
221
|
- lib/ztk/report.rb
|
222
|
+
- lib/ztk/report/list.rb
|
223
|
+
- lib/ztk/report/private.rb
|
224
|
+
- lib/ztk/report/spreadsheet.rb
|
218
225
|
- lib/ztk/rescue_retry.rb
|
219
226
|
- lib/ztk/spinner.rb
|
220
227
|
- lib/ztk/ssh.rb
|
221
228
|
- lib/ztk/ssh/bootstrap.rb
|
222
229
|
- lib/ztk/ssh/command.rb
|
230
|
+
- lib/ztk/ssh/console.rb
|
231
|
+
- lib/ztk/ssh/core.rb
|
223
232
|
- lib/ztk/ssh/download.rb
|
224
233
|
- lib/ztk/ssh/exec.rb
|
225
234
|
- lib/ztk/ssh/file.rb
|
235
|
+
- lib/ztk/ssh/private.rb
|
226
236
|
- lib/ztk/ssh/upload.rb
|
227
237
|
- lib/ztk/tcp_socket_check.rb
|
228
238
|
- lib/ztk/template.rb
|
@@ -263,12 +273,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
273
|
- - ! '>='
|
264
274
|
- !ruby/object:Gem::Version
|
265
275
|
version: '0'
|
276
|
+
segments:
|
277
|
+
- 0
|
278
|
+
hash: 2265396699828621560
|
266
279
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
280
|
none: false
|
268
281
|
requirements:
|
269
282
|
- - ! '>='
|
270
283
|
- !ruby/object:Gem::Version
|
271
284
|
version: '0'
|
285
|
+
segments:
|
286
|
+
- 0
|
287
|
+
hash: 2265396699828621560
|
272
288
|
requirements: []
|
273
289
|
rubyforge_project:
|
274
290
|
rubygems_version: 1.8.25
|