ruby-cute 0.10 → 0.11
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/examples/g5k-tutorial.md +3 -5
- data/lib/cute.rb +1 -0
- data/lib/cute/g5k_api.rb +1 -5
- data/lib/cute/net-ssh-exec3.rb +56 -0
- data/lib/cute/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6202a18499e60b25ccb685d69285251288e565a8
|
4
|
+
data.tar.gz: 3878e7c9fb9822fc911889ca8fb48b6b28df7f7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c929691eb5b0c87268c6626d70f45544cd144df051f02941cda40297e6b151ed0a18ab8bc83664c456f22f8c6ab5c44d1793dd0edace7e17c8a8cb6e69b8c43
|
7
|
+
data.tar.gz: 5eec3f8391dc7c2462abdbec4c1ef5a5c2d994b1fc53faaa377007ff3b9504e1935824fd3d85b559de20f5a6a0233247570240257f69920c547cefd9b39ca19a
|
data/examples/g5k-tutorial.md
CHANGED
@@ -468,12 +468,10 @@ Let's execute the script using `play` command:
|
|
468
468
|
Nodes assigned ["edel-10.grenoble.grid5000.fr", "edel-11.grenoble.grid5000.fr", "edel-12.grenoble.grid5000.fr", "edel-13.grenoble.grid5000.fr"]
|
469
469
|
=> nil
|
470
470
|
|
471
|
-
The variable `job` is updated in Pry context.
|
472
|
-
which enables the access via default SSH to the reserved machines. You can verify it by doing:
|
471
|
+
The variable `job` is updated in Pry context.
|
473
472
|
|
474
|
-
|
475
|
-
|
476
|
-
edel-11.grenoble.grid5000.fr
|
473
|
+
Up to version 0.10 of ruby-cute, when no job types were specified, the type *allow_classic_ssh* was activated
|
474
|
+
which enabled the access via default SSH to the reserved machines. You now have to specify it manually.
|
477
475
|
|
478
476
|
Let's explore the available modules for the parallel execution of commands in several remote machines.
|
479
477
|
The following example shows how to use the {Cute::TakTuk TakTuk} module.
|
data/lib/cute.rb
CHANGED
data/lib/cute/g5k_api.rb
CHANGED
@@ -914,9 +914,7 @@ module Cute
|
|
914
914
|
# job = g5k.reserve(:site => "nancy", :nodes => 1, :walltime => "2:00:00", :type => [:deploy,:destructive])
|
915
915
|
#
|
916
916
|
# == Before using OAR hierarchy
|
917
|
-
#
|
918
|
-
# which does not take advantage of the CPU/core management level.
|
919
|
-
# Therefore, in order to take advantage of this capability, SSH keys have to be specified at the moment of reserving resources.
|
917
|
+
# In order to take advantage of this capability, SSH keys have to be specified at the moment of reserving resources.
|
920
918
|
# This has to be used whenever we perform a reservation with cpu and core hierarchy.
|
921
919
|
# Given that OAR needs access to both keys private and public users are encouraged
|
922
920
|
# to create a pair of SSH keys for managing jobs, for instance the following command can be used:
|
@@ -1062,8 +1060,6 @@ module Cute
|
|
1062
1060
|
unless type.include?(:deploy)
|
1063
1061
|
if opts[:keys]
|
1064
1062
|
payload['import-job-key-from-file'] = [ File.expand_path(keys) ]
|
1065
|
-
else
|
1066
|
-
payload['types'] += [ 'allow_classic_ssh' ]
|
1067
1063
|
end
|
1068
1064
|
end
|
1069
1065
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'net/ssh'
|
2
|
+
|
3
|
+
class Net::SSH::Connection::Session
|
4
|
+
# Monkey patch that adds the exec3! method.
|
5
|
+
# It executes a command, waits for the result, and returns the output as a hash indexed with :stdout, :stderr, :exit_code, :exit_signal.
|
6
|
+
# Several options are available: :no_log (don't display anything), :no_output (don't show command output), :merge_outputs (merge stdout and stderr),
|
7
|
+
# :ignore_error (don't raise an exception if the command execution fails).
|
8
|
+
#
|
9
|
+
# @return [Hash] result Hash stdout, stderr, exit_code, exit_signal of executed command
|
10
|
+
def exec3!(command, o = {})
|
11
|
+
puts "SSH exec3 on #{host}: #{command}" unless o[:no_log]
|
12
|
+
res = {}
|
13
|
+
res[:stdout] = ""
|
14
|
+
res[:stderr] = ""
|
15
|
+
res[:exit_code] = nil
|
16
|
+
res[:exit_signal] = nil
|
17
|
+
open_channel do |channel|
|
18
|
+
channel.exec(command) do |ch, success|
|
19
|
+
unless success
|
20
|
+
abort "FAILED: couldn't execute command (ssh.channel.exec)"
|
21
|
+
end
|
22
|
+
channel.on_data do |ch,data|
|
23
|
+
print data unless o[:no_output]
|
24
|
+
res[:stdout]+=data
|
25
|
+
end
|
26
|
+
|
27
|
+
channel.on_extended_data do |ch,type,data|
|
28
|
+
print data unless o[:no_output]
|
29
|
+
if o[:merge_outputs]
|
30
|
+
res[:stdout]+=data
|
31
|
+
else
|
32
|
+
res[:stderr]+=data
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
channel.on_request("exit-status") do |ch,data|
|
37
|
+
res[:exit_code] = data.read_long
|
38
|
+
puts "EXITCODE: #{res[:exit_code]}" unless o[:no_log]
|
39
|
+
end
|
40
|
+
|
41
|
+
channel.on_request("exit-signal") do |ch, data|
|
42
|
+
res[:exit_signal] = data.read_long
|
43
|
+
puts "EXITSIGNAL: #{res[:exit_signal]}" unless o[:no_log]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
self.loop
|
48
|
+
if res[:exit_code] != 0 and not o[:ignore_error]
|
49
|
+
puts "SSH exec3 failed: #{command}"
|
50
|
+
pp res
|
51
|
+
raise "SSH exec3 failed: #{command}"
|
52
|
+
end
|
53
|
+
res
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
data/lib/cute/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-cute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.11'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algorille team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- lib/cute/execute.rb
|
202
202
|
- lib/cute/extensions.rb
|
203
203
|
- lib/cute/g5k_api.rb
|
204
|
+
- lib/cute/net-ssh-exec3.rb
|
204
205
|
- lib/cute/net-ssh.rb
|
205
206
|
- lib/cute/net.rb
|
206
207
|
- lib/cute/synchronization.rb
|