mobilize-ssh 1.0.5 → 1.0.6
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/mobilize-ssh/handlers/ssh.rb +23 -13
- data/lib/mobilize-ssh/version.rb +1 -1
- data/test/mobilize-ssh_test.rb +5 -2
- data/test/ssh_job_rows.yml +8 -2
- metadata +2 -2
@@ -126,26 +126,36 @@ module Mobilize
|
|
126
126
|
return tmp_file_path
|
127
127
|
end
|
128
128
|
|
129
|
-
def Ssh.
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
129
|
+
def Ssh.file_hash_by_task_path(task_path)
|
130
|
+
#this is not meant to be called directly
|
131
|
+
#from the Runner -- it's used by run_by_task_path
|
132
|
+
t = Task.where(:path=>task_path).first
|
133
|
+
params = t.params
|
134
|
+
gsheet_paths = if params['sources']
|
135
|
+
params['sources']
|
136
|
+
elsif params['source']
|
137
|
+
[params['source']]
|
138
|
+
end
|
139
|
+
if gsheet_paths.length>0
|
140
|
+
gdrive_slot = Gdrive.slot_worker_by_path(task_path)
|
141
|
+
file_hash = {}
|
142
|
+
gsheet_paths.map do |gpath|
|
143
|
+
string = Gsheet.find_by_path(gpath,gdrive_slot).to_tsv
|
144
|
+
fname = gpath.split("/").last
|
145
|
+
{fname => string}
|
146
|
+
end.each do |f|
|
147
|
+
file_hash = f.merge(file_hash)
|
148
|
+
end
|
149
|
+
Gdrive.unslot_worker_by_path(task_path)
|
150
|
+
return file_hash
|
137
151
|
end
|
138
|
-
file_hash
|
139
152
|
end
|
140
153
|
|
141
154
|
def Ssh.run_by_task_path(task_path)
|
142
155
|
t = Task.where(:path=>task_path).first
|
143
156
|
params = t.params
|
144
157
|
node, command = [params['node'],params['cmd']]
|
145
|
-
file_hash =
|
146
|
-
gdrive_slot = Gdrive.slot_worker_by_path(task_path)
|
147
|
-
Ssh.get_file_hash(params['sources'],gdrive_slot)
|
148
|
-
end
|
158
|
+
file_hash = Ssh.file_hash_by_task_path(task_path)
|
149
159
|
su_user = t.params['su_user']
|
150
160
|
Ssh.run(node,command,file_hash,su_user)
|
151
161
|
end
|
data/lib/mobilize-ssh/version.rb
CHANGED
data/test/mobilize-ssh_test.rb
CHANGED
@@ -40,9 +40,12 @@ describe "Mobilize" do
|
|
40
40
|
r.update_gsheet(gdrive_slot)
|
41
41
|
|
42
42
|
puts "jobtracker posted data to test sheet"
|
43
|
-
|
43
|
+
ssh_target_sheet_1 = Mobilize::Gsheet.find_by_path("#{r.path.split("/")[0..-2].join("/")}/test_ssh_1.out",gdrive_slot)
|
44
|
+
ssh_target_sheet_2 = Mobilize::Gsheet.find_by_path("#{r.path.split("/")[0..-2].join("/")}/test_ssh_2.out",gdrive_slot)
|
45
|
+
|
46
|
+
assert ssh_target_sheet_1.to_tsv.length > 100
|
47
|
+
assert ssh_target_sheet_2.to_tsv.length > 100
|
44
48
|
|
45
|
-
assert ssh_target_sheet.to_tsv.length > 100
|
46
49
|
end
|
47
50
|
|
48
51
|
end
|
data/test/ssh_job_rows.yml
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
- name:
|
1
|
+
- name: test_ssh_1
|
2
2
|
active: true
|
3
3
|
trigger: once
|
4
4
|
status: ""
|
5
5
|
task1: 'ssh.run node:"test_node", cmd:"ruby code.rb", su_user:"root", sources:["Runner_mobilize(test)/code.rb", "Runner_mobilize(test)/code.sh"]'
|
6
|
-
task2: 'gsheet.write source:"task1", target:"Runner_mobilize(test)/
|
6
|
+
task2: 'gsheet.write source:"task1", target:"Runner_mobilize(test)/test_ssh_1.out"'
|
7
|
+
- name: test_ssh_2
|
8
|
+
active: true
|
9
|
+
trigger: once
|
10
|
+
status: ""
|
11
|
+
task1: 'ssh.run node:"test_node", cmd:"sh code.sh", su_user:"root", source:"Runner_mobilize(test)/code.sh"'
|
12
|
+
task2: 'gsheet.write source:"task1", target:"Runner_mobilize(test)/test_ssh_2.out"'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobilize-ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mobilize-base
|