isono 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ require 'isono'
4
+ include Isono
5
+
6
+ require 'stringio'
7
+ require 'eventmachine'
8
+
9
+ describe Isono::Util do
10
+
11
+ it "gen_id" do
12
+ Util.gen_id.length.should > 0
13
+ end
14
+
15
+ it "quote_args" do
16
+ Util.quote_args('/bin/ls').should == '/bin/ls'
17
+ Util.quote_args('/bin/ls %s', %w[/home]).should == '/bin/ls \'/home\''
18
+ Util.quote_args('/bin/ls %s', ['$a']).should == '/bin/ls \'\\$a\''
19
+ end
20
+
21
+ it "system" do
22
+ io = StringIO.new
23
+
24
+ EM.run {
25
+ EM.defer {
26
+ begin
27
+ Util.system('/bin/ls', [], {:io=>io})
28
+ puts io.string
29
+ io.string.length.should > 0
30
+ EM.next_tick {EM.stop}
31
+ rescue => e
32
+ p e
33
+ end
34
+ }
35
+ }
36
+ end
37
+
38
+ end
@@ -0,0 +1,7 @@
1
+
2
+ require 'isono'
3
+
4
+ raise "Please set ENV['RESOURCE_MANIFEST']" if ENV['RESOURCE_MANIFEST'].nil? || ENV['RESOURCE_MANIFEST'] == ''
5
+
6
+ $manifest = Isono::ResourceManifest.load(ENV['RESOURCE_MANIFEST'])
7
+ $instance_data = $manifest.instance_data
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isono
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 1
8
+ - 2
8
9
  - 0
9
- version: 0.1.0
10
+ version: 0.2.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - axsh Ltd.
@@ -15,44 +16,52 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-11-18 00:00:00 +09:00
19
+ date: 2011-05-26 00:00:00 +09:00
19
20
  default_executable: cli
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: amqp
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
25
27
  requirements:
26
- - - ">="
28
+ - - "="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 3
28
31
  segments:
29
32
  - 0
30
- - 6
31
33
  - 7
32
- version: 0.6.7
34
+ - 0
35
+ version: 0.7.0
33
36
  type: :runtime
34
37
  version_requirements: *id001
35
38
  - !ruby/object:Gem::Dependency
36
39
  name: eventmachine
37
40
  prerelease: false
38
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
39
43
  requirements:
40
- - - ">="
44
+ - - "="
41
45
  - !ruby/object:Gem::Version
46
+ hash: 62196357
42
47
  segments:
48
+ - 1
43
49
  - 0
44
- - 12
45
- - 10
46
- version: 0.12.10
50
+ - 0
51
+ - beta
52
+ - 3
53
+ version: 1.0.0.beta.3
47
54
  type: :runtime
48
55
  version_requirements: *id002
49
56
  - !ruby/object:Gem::Dependency
50
57
  name: statemachine
51
58
  prerelease: false
52
59
  requirement: &id003 !ruby/object:Gem::Requirement
60
+ none: false
53
61
  requirements:
54
62
  - - ">="
55
63
  - !ruby/object:Gem::Version
64
+ hash: 23
56
65
  segments:
57
66
  - 1
58
67
  - 0
@@ -64,9 +73,11 @@ dependencies:
64
73
  name: log4r
65
74
  prerelease: false
66
75
  requirement: &id004 !ruby/object:Gem::Requirement
76
+ none: false
67
77
  requirements:
68
78
  - - ">="
69
79
  - !ruby/object:Gem::Version
80
+ hash: 3
70
81
  segments:
71
82
  - 0
72
83
  version: "0"
@@ -76,9 +87,11 @@ dependencies:
76
87
  name: bacon
77
88
  prerelease: false
78
89
  requirement: &id005 !ruby/object:Gem::Requirement
90
+ none: false
79
91
  requirements:
80
92
  - - ">="
81
93
  - !ruby/object:Gem::Version
94
+ hash: 3
82
95
  segments:
83
96
  - 0
84
97
  version: "0"
@@ -88,9 +101,11 @@ dependencies:
88
101
  name: rake
89
102
  prerelease: false
90
103
  requirement: &id006 !ruby/object:Gem::Requirement
104
+ none: false
91
105
  requirements:
92
106
  - - ">="
93
107
  - !ruby/object:Gem::Version
108
+ hash: 3
94
109
  segments:
95
110
  - 0
96
111
  version: "0"
@@ -107,48 +122,65 @@ extensions: []
107
122
  extra_rdoc_files: []
108
123
 
109
124
  files:
125
+ - .gitignore
126
+ - LICENSE
127
+ - NOTICE
128
+ - Rakefile
110
129
  - bin/cli
130
+ - isono.gemspec
111
131
  - lib/ext/shellwords.rb
112
132
  - lib/isono.rb
113
- - lib/isono/rack/object_method.rb
114
- - lib/isono/rack/proc.rb
115
- - lib/isono/rack/data_store.rb
116
- - lib/isono/rack/map.rb
117
- - lib/isono/rack/job.rb
118
- - lib/isono/rack/builder.rb
119
- - lib/isono/rack/thread_pass.rb
133
+ - lib/isono/amqp_client.rb
134
+ - lib/isono/daemonize.rb
135
+ - lib/isono/event_delegate_context.rb
136
+ - lib/isono/event_observable.rb
120
137
  - lib/isono/logger.rb
121
- - lib/isono/rack.rb
138
+ - lib/isono/manifest.rb
122
139
  - lib/isono/messaging_client.rb
123
- - lib/isono/resource_manifest.rb
140
+ - lib/isono/models/event_log.rb
141
+ - lib/isono/models/job_state.rb
142
+ - lib/isono/models/node_state.rb
143
+ - lib/isono/models/resource_instance.rb
124
144
  - lib/isono/node.rb
125
- - lib/isono/manifest.rb
126
- - lib/isono/event_delegate_context.rb
127
- - lib/isono/amqp_client.rb
128
- - lib/isono/node_modules/job_channel.rb
129
145
  - lib/isono/node_modules/base.rb
130
- - lib/isono/node_modules/event_logger.rb
131
- - lib/isono/node_modules/event_channel.rb
132
- - lib/isono/node_modules/node_heartbeat.rb
133
- - lib/isono/node_modules/node_collector.rb
134
146
  - lib/isono/node_modules/data_store.rb
147
+ - lib/isono/node_modules/event_channel.rb
148
+ - lib/isono/node_modules/event_logger.rb
149
+ - lib/isono/node_modules/job_channel.rb
135
150
  - lib/isono/node_modules/job_collector.rb
136
- - lib/isono/node_modules/rpc_channel.rb
137
151
  - lib/isono/node_modules/job_worker.rb
152
+ - lib/isono/node_modules/node_collector.rb
153
+ - lib/isono/node_modules/node_heartbeat.rb
154
+ - lib/isono/node_modules/rpc_channel.rb
155
+ - lib/isono/rack.rb
156
+ - lib/isono/rack/builder.rb
157
+ - lib/isono/rack/data_store.rb
158
+ - lib/isono/rack/job.rb
159
+ - lib/isono/rack/map.rb
160
+ - lib/isono/rack/object_method.rb
161
+ - lib/isono/rack/proc.rb
162
+ - lib/isono/rack/thread_pass.rb
163
+ - lib/isono/resource_manifest.rb
164
+ - lib/isono/runner/base.rb
165
+ - lib/isono/runner/cli.rb
166
+ - lib/isono/runner/rpc_server.rb
138
167
  - lib/isono/serializer.rb
139
- - lib/isono/models/node_state.rb
140
- - lib/isono/models/resource_instance.rb
141
- - lib/isono/models/event_log.rb
142
- - lib/isono/models/job_state.rb
143
- - lib/isono/daemonize.rb
144
- - lib/isono/util.rb
145
168
  - lib/isono/thread_pool.rb
146
- - lib/isono/runner/rpc_server.rb
147
- - lib/isono/runner/agent.rb
148
- - lib/isono/event_observable.rb
149
- - isono.gemspec
150
- - LICENSE
151
- - NOTICE
169
+ - lib/isono/util.rb
170
+ - lib/isono/version.rb
171
+ - spec/amqp_client_spec.rb
172
+ - spec/event_observable_spec.rb
173
+ - spec/file_channel_spec.rb
174
+ - spec/job_channel_spec.rb
175
+ - spec/logger_spec.rb
176
+ - spec/manifest_spec.rb
177
+ - spec/node_spec.rb
178
+ - spec/resource_loader_spec.rb
179
+ - spec/rpc_channel_spec.rb
180
+ - spec/spec_helper.rb
181
+ - spec/thread_pool_spec.rb
182
+ - spec/util_spec.rb
183
+ - tasks/load_resource_manifest.rake
152
184
  has_rdoc: true
153
185
  homepage: http://github.com/axsh/isono
154
186
  licenses: []
@@ -159,27 +191,31 @@ rdoc_options: []
159
191
  require_paths:
160
192
  - lib
161
193
  required_ruby_version: !ruby/object:Gem::Requirement
194
+ none: false
162
195
  requirements:
163
196
  - - ">="
164
197
  - !ruby/object:Gem::Version
198
+ hash: 57
165
199
  segments:
166
200
  - 1
167
201
  - 8
168
202
  - 7
169
203
  version: 1.8.7
170
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
+ none: false
171
206
  requirements:
172
207
  - - ">="
173
208
  - !ruby/object:Gem::Version
209
+ hash: 3
174
210
  segments:
175
211
  - 0
176
212
  version: "0"
177
213
  requirements: []
178
214
 
179
- rubyforge_project:
180
- rubygems_version: 1.3.6
215
+ rubyforge_project: isono
216
+ rubygems_version: 1.3.7
181
217
  signing_key:
182
218
  specification_version: 3
183
- summary: Messageing and agent fabric
219
+ summary: Messaging and agent fabric
184
220
  test_files: []
185
221
 
@@ -1,89 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'optparse'
4
- require 'amqp'
5
- require 'digest/sha1'
6
-
7
- require 'isono/agent'
8
-
9
- module Isono
10
- module Runner
11
- class Agent
12
- include Daemonize
13
-
14
- def initialize(argv)
15
- @argv = argv.dup
16
-
17
- @options = {
18
- :amqp_server_uri => URI.parse('amqp://guest:guest@localhost/'),
19
- :log_file => nil,
20
- :pid_file => nil,
21
- :daemonize => true
22
- }
23
-
24
- parser.parse! @argv
25
- end
26
-
27
-
28
- def parser
29
- @parser ||= OptionParser.new do |opts|
30
- opts.banner = "Usage: agent [options]"
31
-
32
- opts.separator ""
33
- opts.separator "Agent options:"
34
- opts.on( "-i", "--id ID", "Manually specify the Agent ID" ) {|str| @options[:agent_id] = str }
35
- opts.on( "-p", "--pid PIDFILE", "pid file path" ) {|str| @options[:pid_file] = str }
36
- opts.on( "-s", "--server AMQP_URI", "amqp broker server to connect" ) {|str|
37
- begin
38
- @options[:amqp_server_uri] = URI.parse(str)
39
- rescue URI::InvalidURIError => e
40
- abort "#{e}"
41
- end
42
- }
43
- opts.on("-X", "Run in foreground" ) { @options[:daemonize] = false }
44
- end
45
- end
46
-
47
-
48
- def run(manifest_path=nil)
49
- #%w(QUIT INT TERM).each { |i|
50
- %w(EXIT).each { |i|
51
- Signal.trap(i) { Isono::Agent.stop{ remove_pidfile if @options[:daemonize]} }
52
- }
53
-
54
-
55
- # load manifest file
56
- manifest = Manifest.load_file(manifest_path.nil? ? @options[:manifest_path] : manifest_path)
57
-
58
- if @options[:node_id]
59
- # force overwrite node_id if the command line arg was given.
60
- manifest.node_id(@options[:node_id])
61
- elsif manifest.node_id.nil?
62
- # nobody specified the node_id then set the ID in the
63
- # default manner.
64
- manifest.node_id(default_node_id)
65
- end
66
-
67
- @options[:log_file] ||= "/var/log/%s.log" % [manifest.node_name]
68
- @options[:pid_file] ||= "/var/run/%s.pid" % [manifest.node_name]
69
-
70
- if @options[:daemonize]
71
- daemonize(@options[:log_file])
72
- end
73
-
74
- EventMachine.epoll
75
- EventMachine.run {
76
- Isono::Agent.start(manifest, @options)
77
- }
78
- end
79
-
80
- private
81
- def default_node_id
82
- # use the ip address for the default routeas key value
83
- Digest::SHA1.hexdigest(`/sbin/ip route get 8.8.8.8`.split("\n")[0].split.last)[0, 10]
84
- end
85
-
86
- end
87
-
88
- end
89
- end