clusterfuck 0.1.0 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.3
@@ -0,0 +1,23 @@
1
+ subnet_prefix = "129.215.59"
2
+ range = (10..20)
3
+
4
+ Clusterfuck::Task.new do |task|
5
+ # List of machines to use. Since we're using this clusterfile to find machines, build a list of legal ips for subnet/range.
6
+ task.hosts = range.map { |postfix| "#{subnet_prefix}.#{postfix}" }
7
+
8
+ # List of jobs to run. Here, we want to find the hostname of each ip, so we build a list of size N (where N is the number of hosts we're using).
9
+ task.jobs = task.hosts.map { |host| "hostname" }
10
+
11
+ # Where to store the result fragments
12
+ task.temp = "hosts"
13
+
14
+ # SSH username/password
15
+ task.username = "SSH_USERNAME"
16
+ task.password = "SSH_PASSWORD"
17
+
18
+ # Do a dry run -- just list jobs/machines and exit.
19
+ #task.debug = true
20
+
21
+ # Show performance report
22
+ task.show_report = false
23
+ end
@@ -31,6 +31,8 @@ module Clusterfuck
31
31
  # [jobs] Array of Job objects, one per job, which will be allocated to the +hosts+. If you're lazy,
32
32
  # you can also just use an array of strings (where each string is the command to run) -- a short
33
33
  # name for each will be produced using the first 8 chars from the command.
34
+ # [jobnames] Array of strings, one per job, which will be used as the short name for the corresponding
35
+ # Job.
34
36
  # [verbose] Level of message reporting. One of +VERBOSE_CANCEL+,+VERBOSE_FAIL+, or +VERBOSE_ALL+
35
37
  # (DEFAULT: +VERBOSE_CANCEL+)
36
38
  # [username] The SSH username to use to connect
@@ -75,15 +77,21 @@ module Clusterfuck
75
77
 
76
78
  # Convert array of string commands to Job objects if necessary
77
79
  def jobify!
78
- @options["jobs"].map! do |job|
79
- if not job.is_a?(Job) # Ah-ha, make this string into a job
80
- short = job.downcase.gsub(/[^a-z]/,"")
81
- short = job[0..7] if short.size > 8
82
- Job.new(short,job)
83
- else # Don't change anything...
84
- job
85
- end
86
- end
80
+ jobs = []
81
+ @options["jobs"].each_with_index do |job,index|
82
+ if not job.is_a?(Job)
83
+ short = nil
84
+ if @options.include?("jobnames")
85
+ short = @options["jobnames"][index]
86
+ else
87
+ short = job.downcase.gsub(/[^a-z]/,"")
88
+ short = job.gsub(/\s/,'')[0..7] if short.size > 8
89
+ end
90
+ job = Job.new(short,job)
91
+ end
92
+ jobs.push job
93
+ end
94
+ @options["jobs"] = jobs
87
95
  end
88
96
  end
89
97
 
@@ -108,15 +116,20 @@ module Clusterfuck
108
116
  # Wait for jobs to terminate
109
117
  machines.each do |machine|
110
118
  begin
119
+ STDERR.puts "Waiting on #{machine.host}" if config.verbose >= VERBOSE_ALL
111
120
  machine.thread.join
121
+ STDERR.puts "#{machine.host} finished" if config.verbose >= VERBOSE_ALL
112
122
  rescue Timeout::Error
113
- STDERR.puts machine.to_s
123
+ STDERR.puts machine.to_s if config.verbose >= VERBOSE_FAIL
124
+ rescue
125
+ STDERR.puts machine.to_s if config.verbose >= VERBOSE_FAIL
126
+ raise $!
114
127
  end
115
128
  end
116
129
 
117
130
  # Print a report, if requested
118
131
  if config.show_report
119
- puts " Machine\t| STARTED\t| COMPLETE\t| FAILED\t|"
132
+ puts " Machine[0..7]\t| STARTED\t| COMPLETE\t| FAILED\t|"
120
133
  machines.each { |machine| puts machine.report }
121
134
  end
122
135
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clusterfuck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 3
10
+ version: 0.1.3
5
11
  platform: ruby
6
12
  authors:
7
13
  - Trevor Fountain
@@ -9,7 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-10-20 00:00:00 +01:00
18
+ date: 2010-09-06 00:00:00 +01:00
13
19
  default_executable: clusterfuck
14
20
  dependencies: []
15
21
 
@@ -30,6 +36,7 @@ files:
30
36
  - Rakefile
31
37
  - VERSION
32
38
  - bin/clusterfuck
39
+ - example/find_machines.cluster
33
40
  - lib/clusterfuck.rb
34
41
  - test/clusterfuck_test.rb
35
42
  - test/test_helper.rb
@@ -43,24 +50,30 @@ rdoc_options:
43
50
  require_paths:
44
51
  - lib
45
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
46
54
  requirements:
47
55
  - - ">="
48
56
  - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
49
60
  version: "0"
50
- version:
51
61
  required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
52
63
  requirements:
53
64
  - - ">="
54
65
  - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
55
69
  version: "0"
56
- version:
57
70
  requirements: []
58
71
 
59
72
  rubyforge_project:
60
- rubygems_version: 1.3.5
73
+ rubygems_version: 1.3.7
61
74
  signing_key:
62
75
  specification_version: 3
63
76
  summary: Run jobs across multiple machines via ssh
64
77
  test_files:
65
- - test/test_helper.rb
66
78
  - test/clusterfuck_test.rb
79
+ - test/test_helper.rb