blackstack-nodes 1.2.4 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blackstack-nodes.rb +25 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dfff9ef5d2e94244befce50fd7dff63ff570be36b54da12e550ef100841c2de
|
4
|
+
data.tar.gz: fa9f19672395322af75efafc19d09add8ddc86e510125f4f37433ef7c9c1bd29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18abefb039af30eddfca6d081b563b053205e35ee209adb26b1c5e85c3bad8b9ba44198f62552bcc15a76aa5e53d571096881571451d04c4861df60bfbaf1f92
|
7
|
+
data.tar.gz: '08df674fc7bcc63bbf792a53d57473bffdd12cc5b72a716ca9b2782e58317e940070b05df16400588d5ab2199827038a0aaa63aa3b3902a15be86abbbfae7257'
|
data/lib/blackstack-nodes.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'net/ssh'
|
2
|
+
require 'shellwords'
|
2
3
|
require 'simple_cloud_logging'
|
3
4
|
#
|
4
5
|
module BlackStack
|
@@ -33,7 +34,7 @@ module BlackStack
|
|
33
34
|
errors << "The parameter h[:ssh_username] is not a string" unless h[:ssh_username].is_a?(String)
|
34
35
|
|
35
36
|
# if the parameter h has a key :ssh_private_key_file
|
36
|
-
if h.has_key?(:ssh_private_key_file)
|
37
|
+
if h.has_key?(:ssh_private_key_file) && !h[:ssh_private_key_file].nil?
|
37
38
|
# validate: the parameter h[:ssh_private_key_file] is a string
|
38
39
|
errors << "The parameter h[:ssh_private_key_file] is not a string" unless h[:ssh_private_key_file].is_a?(String)
|
39
40
|
|
@@ -104,13 +105,28 @@ module BlackStack
|
|
104
105
|
self.ssh.close
|
105
106
|
end
|
106
107
|
|
107
|
-
def exec(command)
|
108
|
-
|
109
|
-
if
|
110
|
-
|
111
|
-
|
112
|
-
|
108
|
+
def exec(command, sudo=true)
|
109
|
+
code = nil
|
110
|
+
if sudo
|
111
|
+
if self.using_password?
|
112
|
+
code = "echo '#{self.ssh_password}' | sudo -S su root -c '#{command}'"
|
113
|
+
elsif self.using_private_key_file?
|
114
|
+
code = "sudo -S su root -c '#{command}'"
|
115
|
+
end
|
116
|
+
else
|
117
|
+
code = command
|
113
118
|
end
|
119
|
+
#puts
|
120
|
+
#puts
|
121
|
+
#puts code
|
122
|
+
#puts
|
123
|
+
#puts
|
124
|
+
s = self.ssh.exec!(code)
|
125
|
+
#puts
|
126
|
+
#puts
|
127
|
+
#puts s
|
128
|
+
#puts
|
129
|
+
#puts
|
114
130
|
s
|
115
131
|
end # def exec
|
116
132
|
|
@@ -124,7 +140,7 @@ module BlackStack
|
|
124
140
|
logger.logs 'reboot... '
|
125
141
|
#stdout = host.reboot
|
126
142
|
begin
|
127
|
-
|
143
|
+
stdout = self.exec("reboot")
|
128
144
|
rescue
|
129
145
|
end
|
130
146
|
logger.done #logf("done (#{stdout})")
|
@@ -150,6 +166,7 @@ module BlackStack
|
|
150
166
|
raise 'reboot failed' if !success
|
151
167
|
end # def reboot
|
152
168
|
|
169
|
+
|
153
170
|
end # module NodeModule
|
154
171
|
|
155
172
|
# TODO: declare these classes (stub and skeleton) using blackstack-rpc
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackstack-nodes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|