ruby-cute 0.10 → 0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e75eb4ece743b61f9f6b99471737e8254a99ff24
4
- data.tar.gz: 11cb6aa7d6f013d72b8b31724b608723b934f7b8
3
+ metadata.gz: 6202a18499e60b25ccb685d69285251288e565a8
4
+ data.tar.gz: 3878e7c9fb9822fc911889ca8fb48b6b28df7f7c
5
5
  SHA512:
6
- metadata.gz: 6ded1372ed4b88ae5937becf2d1c20a84bc70ce9ba3039328fe873804253b71e1a7cb2ea415de768dc6cfa27b751abfaa81c5d67d70ed834bb6222f2e46bb3f5
7
- data.tar.gz: 37d332de8dda6d1df60125e282f4ea34e34dea46b8e8a94135168f5f37df577374ec863641ca3f20ff1f28b045d0e3e01c016aa540d19e88ebc011f3f31a4445
6
+ metadata.gz: 2c929691eb5b0c87268c6626d70f45544cd144df051f02941cda40297e6b151ed0a18ab8bc83664c456f22f8c6ab5c44d1793dd0edace7e17c8a8cb6e69b8c43
7
+ data.tar.gz: 5eec3f8391dc7c2462abdbec4c1ef5a5c2d994b1fc53faaa377007ff3b9504e1935824fd3d85b559de20f5a6a0233247570240257f69920c547cefd9b39ca19a
@@ -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. When no keys are specified, the option *-allow_classic_ssh* is activated
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
- [11] pry(main)> .ssh edel-11.grenoble.grid5000.fr "hostname"
475
- Warning: Permanently added 'edel-11.grenoble.grid5000.fr,172.16.17.11' (RSA) to the list of known hosts.
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.
@@ -4,3 +4,4 @@ require 'cute/taktuk'
4
4
  require 'cute/g5k_api'
5
5
  require 'cute/extensions'
6
6
  require 'cute/net-ssh'
7
+ require 'cute/net-ssh-exec3'
@@ -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
- # All non-deploy reservations are submitted by default with the OAR option "-allow_classic_ssh"
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
+
@@ -1,3 +1,3 @@
1
1
  module Cute
2
- VERSION = "0.10"
2
+ VERSION = "0.11"
3
3
  end
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.10'
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-06-20 00:00:00.000000000 Z
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