net-ssh-cli 1.8.0 → 1.9.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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/lib/net/ssh/cli/version.rb +1 -1
- data/lib/net/ssh/cli.rb +31 -12
- data/net-ssh-cli.gemspec +17 -17
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7056a8a1973f705133135914df49d4b16e1b9213b35b987677094b9993b3b059
|
4
|
+
data.tar.gz: 5520b049f17149f5a17849f396b150451a0b7f50f0ceee4e79d616f23ec876e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5d34700dc16a246ce3706828d2043993b34496d5b1a742f5dbbff366a62591ae2327bf7f9a1ec0044281962ae65f7f6297f2b49025f4acc1ba2175d2004ae12
|
7
|
+
data.tar.gz: 0231d51bb361bbb6181138d1f0ec3350071c804f06e0e863bbe9d97fb85e5e9a156019f0fb6e7332a3e36baeda0d67050f34bbe519b275d8b0fa4c5439331878
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.1
|
data/lib/net/ssh/cli/version.rb
CHANGED
data/lib/net/ssh/cli.rb
CHANGED
@@ -44,19 +44,19 @@ module Net
|
|
44
44
|
cmd_rm_prompt: false, # whether the prompt should be removed in the output of #cmd
|
45
45
|
cmd_rm_command: false, # whether the given command should be removed in the output of #cmd
|
46
46
|
cmd_rm_command_tail: "\n", # which format does the end of line return after a command has been submitted. Could be something like "ls\n" "ls\r\n" or "ls \n" (extra spaces)
|
47
|
-
cmd_minimum_duration: 0, # how long do you want to wait/sleep after sending the command. After this waiting time, the output will be processed and the prompt will be searched.
|
47
|
+
cmd_minimum_duration: 0, # how long do you want to wait/sleep after sending the command. After this waiting time, the output will be processed and the prompt will be searched.
|
48
48
|
run_impact: false, # whether to run #impact commands. This might align with testing|development|production. example #impact("reboot")
|
49
49
|
read_till_timeout: nil, # timeout for #read_till to find the match
|
50
50
|
read_till_hard_timeout: nil, # hard timeout for #read_till to find the match using Timeout.timeout(hard_timeout) {}. Might creates unpredicted sideffects
|
51
51
|
read_till_hard_timeout_factor: 1.2, # hard timeout factor in case read_till_hard_timeout is true
|
52
|
-
named_prompts: ActiveSupport::HashWithIndifferentAccess.new, # you can used named prompts for #with_prompt {}
|
53
|
-
before_cmd_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call before #cmd
|
52
|
+
named_prompts: ActiveSupport::HashWithIndifferentAccess.new, # you can used named prompts for #with_prompt {}
|
53
|
+
before_cmd_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call before #cmd
|
54
54
|
after_cmd_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call after #cmd
|
55
|
-
before_on_stdout_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call before data arrives from the underlying connection
|
55
|
+
before_on_stdout_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call before data arrives from the underlying connection
|
56
56
|
after_on_stdout_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call after data arrives from the underlying connection
|
57
|
-
before_on_stdin_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call before data is sent to the underlying channel
|
57
|
+
before_on_stdin_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call before data is sent to the underlying channel
|
58
58
|
after_on_stdin_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call after data is sent to the underlying channel
|
59
|
-
before_open_channel_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call before opening a channel
|
59
|
+
before_open_channel_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call before opening a channel
|
60
60
|
after_open_channel_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call after opening a channel, for example you could call #detect_prompt or #read_till
|
61
61
|
open_channel_timeout: nil, # timeout to open the channel
|
62
62
|
net_ssh_options: ActiveSupport::HashWithIndifferentAccess.new, # a wrapper for options to pass to Net::SSH.start in case net_ssh is undefined
|
@@ -64,6 +64,12 @@ module Net
|
|
64
64
|
background_processing: false, # default false, whether the process method maps to the underlying net_ssh#process or the net_ssh#process happens in a separate loop
|
65
65
|
on_stdout_processing: 100, # whether to optimize the on_stdout performance by calling #process #optimize_on_stdout-times in case more data arrives
|
66
66
|
sleep_procs: ActiveSupport::HashWithIndifferentAccess.new, # procs to call instead of Kernel.sleep(), perfect for async hooks
|
67
|
+
terminal_chars_width: 320, # Sets and sends the terminal dimensions during the opening of the channel. It does not send a channel_request on change.
|
68
|
+
terminal_chars_height: 120, # See also https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/connection/channel.rb#L220 section 'def request_pty'
|
69
|
+
terminal_pixels_width: 1920, # See also https://www.ietf.org/rfc/rfc4254.txt section pty-req and section window-change
|
70
|
+
terminal_pixels_height: 1080, #
|
71
|
+
terminal_term: nil, # Sets the terminal term, usually xterm
|
72
|
+
terminal_modes: nil, #
|
67
73
|
)
|
68
74
|
|
69
75
|
def options
|
@@ -99,7 +105,9 @@ module Net
|
|
99
105
|
|
100
106
|
OPTIONS.keys.select {|key| key.to_s.include? "procs"}.each do |name|
|
101
107
|
define_method name.sub("_procs","") do |&blk|
|
102
|
-
|
108
|
+
id = SecureRandom.uuid
|
109
|
+
self.send(name)[id] = Proc.new {blk.call}
|
110
|
+
id
|
103
111
|
end
|
104
112
|
end
|
105
113
|
|
@@ -289,7 +297,7 @@ module Net
|
|
289
297
|
# removes the prompt from the given output
|
290
298
|
# prompt should contain a named match 'prompt' /(?<prompt>.*something.*)\z/
|
291
299
|
# for backwards compatibility it also tries to replace the first match of the prompt /(something)\z/
|
292
|
-
# it removes the whole match if no matches are given /something\z/
|
300
|
+
# it removes the whole match if no matches are given /something\z/
|
293
301
|
def rm_prompt!(output, prompt: current_prompt, **opts)
|
294
302
|
if rm_prompt?(**opts)
|
295
303
|
if output[prompt]
|
@@ -312,10 +320,10 @@ module Net
|
|
312
320
|
|
313
321
|
# the same as #cmd but it will only run the command if the option run_impact is set to true.
|
314
322
|
# this can be used for commands which you might not want to run in development|testing mode but in production
|
315
|
-
# cli.impact("reboot")
|
323
|
+
# cli.impact("reboot")
|
316
324
|
# => "skip: reboot"
|
317
325
|
# cli.run_impact = true
|
318
|
-
# cli.impact("reboot")
|
326
|
+
# cli.impact("reboot")
|
319
327
|
# => "system is going to reboot NOW"
|
320
328
|
def impact(command, **opts)
|
321
329
|
run_impact? ? cmd(command, **opts) : "skip: #{command.inspect}"
|
@@ -352,7 +360,7 @@ module Net
|
|
352
360
|
return @net_ssh if @net_ssh
|
353
361
|
|
354
362
|
logger.debug { 'Net:SSH #start' }
|
355
|
-
self.net_ssh = Net::SSH.start(net_ssh_options[:ip] || net_ssh_options[:host] || 'localhost', net_ssh_options[:user] || ENV['USER'], formatted_net_ssh_options)
|
363
|
+
self.net_ssh = Net::SSH.start(net_ssh_options[:ip] || net_ssh_options[:host] || 'localhost', net_ssh_options[:user] || ENV['USER'], **formatted_net_ssh_options)
|
356
364
|
rescue StandardError => error
|
357
365
|
self.net_ssh = nil
|
358
366
|
raise
|
@@ -375,7 +383,7 @@ module Net
|
|
375
383
|
net_ssh.open_channel do |new_channel|
|
376
384
|
logger.debug 'channel is open'
|
377
385
|
self.channel = new_channel
|
378
|
-
new_channel.request_pty do |_ch, success|
|
386
|
+
new_channel.request_pty(terminal_options) do |_ch, success|
|
379
387
|
raise Error::Pty, "#{host || ip} Failed to open ssh pty" unless success
|
380
388
|
end
|
381
389
|
new_channel.send_channel_request('shell') do |_ch, success|
|
@@ -428,6 +436,17 @@ module Net
|
|
428
436
|
ensure
|
429
437
|
self.process_count -= 1
|
430
438
|
end
|
439
|
+
|
440
|
+
def terminal_options
|
441
|
+
{
|
442
|
+
term: terminal_term,
|
443
|
+
chars_wide: terminal_chars_width,
|
444
|
+
chars_high: terminal_chars_height,
|
445
|
+
pixels_wide: terminal_pixels_width,
|
446
|
+
pixels_high: terminal_pixels_height,
|
447
|
+
modes: terminal_modes
|
448
|
+
}.reject {|k,v| v.nil?}
|
449
|
+
end
|
431
450
|
end
|
432
451
|
end
|
433
452
|
end
|
data/net-ssh-cli.gemspec
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "net/ssh/cli/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
8
|
+
spec.name = "net-ssh-cli"
|
9
9
|
spec.version = Net::SSH::CLI::VERSION
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
10
|
+
spec.authors = ["Fabian Stillhart"]
|
11
|
+
spec.email = ["fabian.stillhart1@swisscom.com"]
|
12
12
|
|
13
|
-
spec.summary =
|
14
|
-
spec.description =
|
15
|
-
spec.homepage =
|
16
|
-
spec.license =
|
13
|
+
spec.summary = "Net::SSH::CLI: A library to handle CLI Sessions"
|
14
|
+
spec.description = "Net::SSH::CLI: A library to handle CLI Sessions. It allows you to write programs that invoke and interact with (long-running) CLI Sessions via NET::SSH."
|
15
|
+
spec.homepage = "https://github.com/swisscom/net-ssh-cli"
|
16
|
+
spec.license = "MIT"
|
17
17
|
|
18
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -33,14 +33,14 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
34
34
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
35
35
|
end
|
36
|
-
spec.bindir =
|
36
|
+
spec.bindir = "exe"
|
37
37
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
|
-
spec.require_paths = [
|
38
|
+
spec.require_paths = ["lib"]
|
39
39
|
|
40
|
-
spec.add_development_dependency
|
41
|
-
spec.add_development_dependency
|
42
|
-
spec.add_development_dependency
|
43
|
-
spec.add_development_dependency
|
44
|
-
spec.add_dependency
|
45
|
-
spec.add_dependency
|
40
|
+
spec.add_development_dependency "bump"
|
41
|
+
spec.add_development_dependency "bundler"
|
42
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
43
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
44
|
+
spec.add_dependency "activesupport", ">= 4.0"
|
45
|
+
spec.add_dependency "net-ssh", ">= 7.0"
|
46
46
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ssh-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabian Stillhart
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bump
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '7.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '7.0'
|
97
97
|
description: 'Net::SSH::CLI: A library to handle CLI Sessions. It allows you to write
|
98
98
|
programs that invoke and interact with (long-running) CLI Sessions via NET::SSH.'
|
99
99
|
email:
|
@@ -125,7 +125,7 @@ homepage: https://github.com/swisscom/net-ssh-cli
|
|
125
125
|
licenses:
|
126
126
|
- MIT
|
127
127
|
metadata: {}
|
128
|
-
post_install_message:
|
128
|
+
post_install_message:
|
129
129
|
rdoc_options: []
|
130
130
|
require_paths:
|
131
131
|
- lib
|
@@ -140,8 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
-
signing_key:
|
143
|
+
rubygems_version: 3.3.25
|
144
|
+
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: 'Net::SSH::CLI: A library to handle CLI Sessions'
|
147
147
|
test_files: []
|