mobilize-ssh 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- require 'mobilize-base/rakes'
4
- require 'mobilize-ssh/rakes'
3
+ require 'mobilize-base/tasks'
4
+ require 'mobilize-ssh/tasks'
5
5
 
6
6
  #
7
7
  # Tests
@@ -126,18 +126,18 @@ module Mobilize
126
126
  return tmp_file_path
127
127
  end
128
128
 
129
- def Ssh.file_hash_by_task_path(task_path)
129
+ def Ssh.file_hash_by_stage_path(stage_path)
130
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
131
+ #from the Runner -- it's used by run_by_stage_path
132
+ s = Stage.where(:path=>stage_path).first
133
+ params = s.params
134
134
  gsheet_paths = if params['sources']
135
135
  params['sources']
136
136
  elsif params['source']
137
137
  [params['source']]
138
138
  end
139
- if gsheet_paths.length>0
140
- gdrive_slot = Gdrive.slot_worker_by_path(task_path)
139
+ if gsheet_paths and gsheet_paths.length>0
140
+ gdrive_slot = Gdrive.slot_worker_by_path(stage_path)
141
141
  file_hash = {}
142
142
  gsheet_paths.map do |gpath|
143
143
  string = Gsheet.find_by_path(gpath,gdrive_slot).to_tsv
@@ -146,17 +146,17 @@ module Mobilize
146
146
  end.each do |f|
147
147
  file_hash = f.merge(file_hash)
148
148
  end
149
- Gdrive.unslot_worker_by_path(task_path)
149
+ Gdrive.unslot_worker_by_path(stage_path)
150
150
  return file_hash
151
151
  end
152
152
  end
153
153
 
154
- def Ssh.run_by_task_path(task_path)
155
- t = Task.where(:path=>task_path).first
156
- params = t.params
154
+ def Ssh.run_by_stage_path(stage_path)
155
+ s = Stage.where(:path=>stage_path).first
156
+ params = s.params
157
157
  node, command = [params['node'],params['cmd']]
158
- file_hash = Ssh.file_hash_by_task_path(task_path)
159
- su_user = t.params['su_user']
158
+ file_hash = Ssh.file_hash_by_stage_path(stage_path)
159
+ su_user = s.params['su_user']
160
160
  Ssh.run(node,command,file_hash,su_user)
161
161
  end
162
162
  end
File without changes
@@ -1,5 +1,5 @@
1
1
  module Mobilize
2
2
  module Ssh
3
- VERSION = "1.0.6"
3
+ VERSION = "1.0.7"
4
4
  end
5
5
  end
data/mobilize-ssh.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
- gem.add_runtime_dependency "mobilize-base","1.0.7"
19
+ gem.add_runtime_dependency "mobilize-base","1.0.8"
20
20
  gem.add_runtime_dependency "net-ssh"
21
21
  gem.add_runtime_dependency "net-scp"
22
22
  gem.add_runtime_dependency "net-ssh-gateway"
@@ -18,6 +18,10 @@ describe "Mobilize" do
18
18
  u = Mobilize::User.where(:name=>user_name).first
19
19
  r = u.runner
20
20
 
21
+ rb_code_sheet = Mobilize::Gsheet.find_by_path("#{r.path.split("/")[0..-2].join("/")}/code.rb",gdrive_slot)
22
+ sh_code_sheet = Mobilize::Gsheet.find_by_path("#{r.path.split("/")[0..-2].join("/")}/code.sh",gdrive_slot)
23
+ [rb_code_sheet,sh_code_sheet].each {|s| s.delete if s}
24
+
21
25
  puts "add test code"
22
26
  rb_code_sheet = Mobilize::Gsheet.find_or_create_by_path("#{r.path.split("/")[0..-2].join("/")}/code.rb",gdrive_slot)
23
27
  rb_code_tsv = File.open("#{Mobilize::Base.root}/test/code.rb").read
@@ -29,12 +33,19 @@ describe "Mobilize" do
29
33
 
30
34
  jobs_sheet = r.gsheet(gdrive_slot)
31
35
 
36
+ #delete target sheets if they exist
37
+ ssh_target_sheet_1 = Mobilize::Gsheet.find_by_path("#{r.path.split("/")[0..-2].join("/")}/test_ssh_1.out",gdrive_slot)
38
+ ssh_target_sheet_2 = Mobilize::Gsheet.find_by_path("#{r.path.split("/")[0..-2].join("/")}/test_ssh_2.out",gdrive_slot)
39
+ ssh_target_sheet_3 = Mobilize::Gsheet.find_by_path("#{r.path.split("/")[0..-2].join("/")}/test_ssh_3.out",gdrive_slot)
40
+ [ssh_target_sheet_1,ssh_target_sheet_2,ssh_target_sheet_3].each {|s| s.delete if s}
41
+
32
42
  ssh_job_rows = ::YAML.load_file("#{Mobilize::Base.root}/test/ssh_job_rows.yml")
43
+ ssh_job_rows.map{|j| r.jobs(j['name'])}.each{|j| j.delete if j}
33
44
  jobs_sheet.add_or_update_rows(ssh_job_rows)
34
45
 
35
- puts "job row added, force enqueued runner, wait 90s"
46
+ puts "job row added, force enqueued runner, wait 120s"
36
47
  r.enqueue!
37
- sleep 90
48
+ sleep 120
38
49
 
39
50
  puts "update job status and activity"
40
51
  r.update_gsheet(gdrive_slot)
@@ -42,9 +53,11 @@ describe "Mobilize" do
42
53
  puts "jobtracker posted data to test sheet"
43
54
  ssh_target_sheet_1 = Mobilize::Gsheet.find_by_path("#{r.path.split("/")[0..-2].join("/")}/test_ssh_1.out",gdrive_slot)
44
55
  ssh_target_sheet_2 = Mobilize::Gsheet.find_by_path("#{r.path.split("/")[0..-2].join("/")}/test_ssh_2.out",gdrive_slot)
56
+ ssh_target_sheet_3 = Mobilize::Gsheet.find_by_path("#{r.path.split("/")[0..-2].join("/")}/test_ssh_3.out",gdrive_slot)
45
57
 
46
58
  assert ssh_target_sheet_1.to_tsv.length > 100
47
59
  assert ssh_target_sheet_2.to_tsv.length > 100
60
+ assert ssh_target_sheet_3.to_tsv.length > 3
48
61
 
49
62
  end
50
63
 
@@ -2,11 +2,17 @@
2
2
  active: true
3
3
  trigger: once
4
4
  status: ""
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)/test_ssh_1.out"'
5
+ stage1: 'ssh.run node:"test_node", cmd:"ruby code.rb", su_user:"root", sources:["Runner_mobilize(test)/code.rb", "Runner_mobilize(test)/code.sh"]'
6
+ stage2: 'gsheet.write source:"stage1", target:"Runner_mobilize(test)/test_ssh_1.out"'
7
7
  - name: test_ssh_2
8
8
  active: true
9
9
  trigger: once
10
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"'
11
+ stage1: 'ssh.run node:"test_node", cmd:"sh code.sh", su_user:"root", source:"Runner_mobilize(test)/code.sh"'
12
+ stage2: 'gsheet.write source:"stage1", target:"Runner_mobilize(test)/test_ssh_2.out"'
13
+ - name: test_ssh_3
14
+ active: true
15
+ trigger: once
16
+ status: ""
17
+ stage1: 'ssh.run node:"test_node", cmd:"whoami"'
18
+ stage2: 'gsheet.write source:"stage1", target:"Runner_mobilize(test)/test_ssh_3.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.6
4
+ version: 1.0.7
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-15 00:00:00.000000000 Z
12
+ date: 2012-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mobilize-base
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.7
21
+ version: 1.0.8
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.7
29
+ version: 1.0.8
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: net-ssh
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -93,7 +93,7 @@ files:
93
93
  - lib/mobilize-ssh/extensions/socket.rb
94
94
  - lib/mobilize-ssh/extensions/string.rb
95
95
  - lib/mobilize-ssh/handlers/ssh.rb
96
- - lib/mobilize-ssh/rakes.rb
96
+ - lib/mobilize-ssh/tasks.rb
97
97
  - lib/mobilize-ssh/version.rb
98
98
  - lib/samples/ssh.yml
99
99
  - mobilize-ssh.gemspec