Devops 0.0.3 → 0.0.4
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/lib/host/default.rb +33 -20
- data/lib/ops/console.rb +8 -0
- data/lib/version.rb +1 -1
- metadata +4 -4
data/lib/host/default.rb
CHANGED
@@ -82,41 +82,54 @@ module Host
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
def shell_exec! command
|
85
|
+
def shell_exec!( command, opts = {} )
|
86
86
|
ssh_pem
|
87
87
|
|
88
88
|
options = { :keys => ssh_pem }
|
89
89
|
|
90
90
|
color = Color.random_color
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
92
|
+
begin
|
93
|
+
Net::SSH.start( host_name, user, options ) do | s |
|
94
|
+
|
95
|
+
channel = s.open_channel do |ch|
|
96
|
+
channel.request_pty do |ch, success|
|
97
|
+
if success
|
98
|
+
puts "pty successfully obtained"
|
99
|
+
else
|
100
|
+
puts "could not obtain pty"
|
101
|
+
end
|
102
|
+
end if opts.has_key? :pty
|
103
|
+
|
104
|
+
ch.exec( command ) do | ch, success |
|
105
|
+
raise( IOError,
|
106
|
+
"#{ host_name } > could not execute command" ) unless
|
107
|
+
success
|
108
|
+
|
109
|
+
ch.on_data do | c, data |
|
110
|
+
data.split("\n").each do | line |
|
111
|
+
puts "#{ Color.print(
|
112
|
+
self.alias, [ :bold, color ] ) } > #{ line }"
|
113
|
+
end
|
114
|
+
end
|
99
115
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
116
|
+
ch.on_extended_data do |c, type, data|
|
117
|
+
data.split("\n").each do | line |
|
118
|
+
puts "#{ Color.print(
|
119
|
+
self.alias, [ :bold, color ] ) } > #{ line }"
|
120
|
+
end
|
104
121
|
end
|
105
|
-
end
|
106
122
|
|
107
|
-
|
108
|
-
data.split("\n").each do | line |
|
123
|
+
ch.on_close do
|
109
124
|
puts "#{ Color.print(
|
110
|
-
self.alias, [ :bold, color ] ) } >
|
125
|
+
self.alias, [ :bold, color ] ) } > COMMAND finished"
|
111
126
|
end
|
112
|
-
end
|
113
127
|
|
114
|
-
ch.on_close do
|
115
|
-
puts "#{ Color.print(
|
116
|
-
self.alias, [ :bold, color ] ) } > COMMAND finished"
|
117
128
|
end
|
118
129
|
end
|
119
130
|
end
|
131
|
+
rescue => e
|
132
|
+
puts "Error: #{ self.alias } > #{ e.message }".error
|
120
133
|
end
|
121
134
|
end
|
122
135
|
end
|
data/lib/ops/console.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Devops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hardeep Shoker
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-03
|
19
|
+
date: 2013-04-03 00:00:00 Z
|
20
20
|
dependencies: []
|
21
21
|
|
22
22
|
description: Ops tool for remote servers
|