remote-exec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/remote/exec/fake.rb +15 -0
- data/lib/remote/exec/local.rb +21 -0
- data/lib/remote/exec/ssh.rb +36 -0
- data/lib/remote/exec/version.rb +6 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8abbf419411c6fb963244ec42deb4c7d9703d1c4
|
4
|
+
data.tar.gz: 684effcebaabb98fa386ca30691c65ac455e5978
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c22eefd7ccc0b51b8f9cdc336ad2f7bd08729678731b24ea1e5b7e176524d9ab0a31ccba44b0aa8602f23b39d3c9bac4c2de41b0a11bdd72313acd8d24180f7a
|
7
|
+
data.tar.gz: b5b45613930e25e460b8c03f2adc66315e614fd9a920878d08d04515862f55584767eeeb200ba6bdb2156652eb849a68e77da04834d60d30bd3c4da676d5a796
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Remote::Exec::Fake
|
2
|
+
attr_reader :last_status
|
3
|
+
|
4
|
+
def execute(command)
|
5
|
+
@last_status, outputs = @respond.call(command)
|
6
|
+
outputs.each do |out, err|
|
7
|
+
yield(out, err)
|
8
|
+
end
|
9
|
+
@last_status
|
10
|
+
end
|
11
|
+
|
12
|
+
def respond(&block)
|
13
|
+
@respond = block
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'session'
|
2
|
+
|
3
|
+
class Remote::Exec::Local
|
4
|
+
attr_reader :shell, :last_status
|
5
|
+
|
6
|
+
def initialize(shell = "sh")
|
7
|
+
@shell = shell
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute(command)
|
11
|
+
@last_status = nil
|
12
|
+
shell_session.execute(command) do |out, err|
|
13
|
+
yield(out, err)
|
14
|
+
end
|
15
|
+
@last_status = shell_session.status
|
16
|
+
end
|
17
|
+
|
18
|
+
def shell_session
|
19
|
+
@shell_session ||= Session::Sh.new(:prog => shell)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'net/ssh'
|
2
|
+
|
3
|
+
class Remote::Exec::Ssh
|
4
|
+
attr_reader :host, :user, :last_status
|
5
|
+
|
6
|
+
def initialize(host, user = nil)
|
7
|
+
@host = host
|
8
|
+
@user = user
|
9
|
+
end
|
10
|
+
|
11
|
+
# TODO: make it run in one session
|
12
|
+
def execute(command)
|
13
|
+
@last_status = nil
|
14
|
+
ssh.open_channel do |channel|
|
15
|
+
channel.request_pty
|
16
|
+
channel.exec command do |ch, success|
|
17
|
+
channel.on_data do |ch, data|
|
18
|
+
yield(data, nil)
|
19
|
+
end
|
20
|
+
channel.on_extended_data do |ch, type, data|
|
21
|
+
yield(nil, data)
|
22
|
+
end
|
23
|
+
channel.on_request("exit-status") do |ch, data|
|
24
|
+
@last_status = data.read_long
|
25
|
+
end
|
26
|
+
end
|
27
|
+
channel.wait
|
28
|
+
end
|
29
|
+
ssh.loop
|
30
|
+
@last_status
|
31
|
+
end
|
32
|
+
|
33
|
+
def ssh
|
34
|
+
@ssh ||= Net::SSH.start(host, user)
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: remote-exec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michal Papis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: session
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: net-ssh
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Invoke commands on remote hosts
|
56
|
+
email:
|
57
|
+
- mpapis@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/remote/exec/fake.rb
|
63
|
+
- lib/remote/exec/local.rb
|
64
|
+
- lib/remote/exec/ssh.rb
|
65
|
+
- lib/remote/exec/version.rb
|
66
|
+
homepage: https://github.com/remote-exec/remote-exec
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.4.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Invoke commands on remote hosts
|
90
|
+
test_files: []
|
91
|
+
has_rdoc:
|