auser-poolparty 0.2.41 → 0.2.42

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.
@@ -27,7 +27,7 @@ module PoolParty
27
27
 
28
28
  has_gempackage(:name => "rake", :download_url => "http://rubyforge.org/frs/download.php/43954/rake-0.8.3.gem")
29
29
  has_gempackage(:name => "xml-simple", :download_url => "http://rubyforge.org/frs/download.php/18366/xml-simple-1.0.11.gem")
30
- has_gempackage(:name => "grempe-amazon-ec2", :download_url => "http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem", :requires => get_gempackage("xml-simple"))
30
+ has_gempackage(:name => "amazon-ec2", :download_url => "http://rubyforge.org/frs/download.php/43666/amazon-ec2-0.3.1.gem", :requires => get_gempackage("xml-simple"))
31
31
 
32
32
  has_gempackage(:name => "sexp_processor", :download_url => "http://rubyforge.org/frs/download.php/45589/sexp_processor-3.0.0.gem")
33
33
  has_gempackage(:name => "ParseTree", :download_url => "http://rubyforge.org/frs/download.php/45600/ParseTree-3.0.1.gem", :requires => [get_gempackage("sexp_processor"), get_gempackage("ZenTest")])
@@ -2,7 +2,6 @@ require 'thread'
2
2
  begin
3
3
  require 'fasttread'
4
4
  rescue LoadError
5
- $stderr.puts "Using the ruby-core thread implementation"
6
5
  end
7
6
 
8
7
  class ThreadPool
@@ -15,7 +15,7 @@ module PoolParty
15
15
  mod.send :include, PoolParty::Remote::RemoterBase
16
16
  self.class.send :include, mod
17
17
  self.extend mod
18
-
18
+
19
19
  @remote_base = "#{t}".preserved_module_constant
20
20
  end
21
21
  else
@@ -19,10 +19,10 @@ module PoolParty
19
19
  :size => "#{size || Base.size}")
20
20
  begin
21
21
  item = instance#.instancesSet.item
22
- EC2ResponseObject.get_hash_from_response(item)
22
+ inst = EC2ResponseObject.get_hash_from_response(item)
23
23
  rescue Exception => e
24
24
  end
25
- instance
25
+ inst
26
26
  end
27
27
  # Terminate an instance by id
28
28
  def terminate_instance!(instance_id=nil)
@@ -52,6 +52,10 @@ module PoolParty
52
52
  def get_instances_description
53
53
  EC2ResponseObject.get_descriptions(ec2.describe_instances).sort_by {|a| a[:launching_time]}
54
54
  end
55
+
56
+ def after_launch_master(instance=nil)
57
+ ec2.associate_address(:instance_id => instance.instance_id, :public_ip => set_master_ip_to) if set_master_ip_to && instance
58
+ end
55
59
 
56
60
  # Help create a keypair for the cloud
57
61
  # This is a helper to create the keypair and add them to the cloud for you
@@ -104,6 +104,11 @@ module PoolParty
104
104
  num.times {out << launch_new_instance!}
105
105
  out
106
106
  end
107
+ def request_launch_master_instance
108
+ after_launch_master(launch_new_instance!)
109
+ end
110
+ def after_launch_master(h={})
111
+ end
107
112
  # Let's terminate an instance that is not the master instance
108
113
  def request_termination_of_non_master_instance
109
114
  inst = nonmaster_nonterminated_instances.last
@@ -142,7 +147,24 @@ module PoolParty
142
147
  if can_start_a_new_instance? && !minimum_number_of_instances_are_running?
143
148
  list_of_pending_instances.size == 0 ? request_launch_one_instance_at_a_time : wait("5.seconds")
144
149
  reset!
145
- launch_minimum_number_of_instances unless minimum_number_of_instances_are_running?
150
+ launch_minimum_number_of_instances
151
+ provision_slaves_from_n(minimum_instances.to_i)
152
+ after_launched
153
+ end
154
+ end
155
+
156
+ def provision_slaves_from_n(num=1)
157
+ reset!
158
+ when_no_pending_instances do
159
+ wait "10.seconds" # Give some time for ssh to startup
160
+ @num_instances = list_of_running_instances.size
161
+ last_instances = nonmaster_nonterminated_instances[(@num_instances - (num))..(@num_instances)]
162
+ last_instances.each do |inst|
163
+ PoolParty::Provisioner.provision_slave(inst, self, false) unless inst.master?
164
+ cmd = ". /etc/profile && cloud-provision -i #{inst.name.gsub(/node/, '')} #{unix_hide_string} &"
165
+ Kernel.system cmd
166
+ end
167
+ PoolParty::Provisioner.reconfigure_master(self, force)
146
168
  end
147
169
  end
148
170
  # Launch the master and let the master handle the starting of the cloud
@@ -153,7 +175,7 @@ module PoolParty
153
175
  def launch_and_configure_master!(testing=false)
154
176
  vputs "Requesting to launch new instance"
155
177
  logger.debug "Launching master"
156
- request_launch_new_instances(1) if list_of_pending_instances.size.zero? && can_start_a_new_instance? && !is_master_running?
178
+ request_launch_master_instance if list_of_pending_instances.size.zero? && can_start_a_new_instance? && !is_master_running?
157
179
 
158
180
  vputs "Waiting for there to be no pending instances..."
159
181
  when_no_pending_instances do
@@ -189,18 +211,8 @@ module PoolParty
189
211
  @num = 1
190
212
  request_launch_new_instances(@num)
191
213
 
192
- reset!
193
- when_no_pending_instances do
194
- reset!
195
- wait "20.seconds" # Give some time for ssh to startup
196
- @num_instances = nonmaster_nonterminated_instances.size
197
- last_instances = nonmaster_nonterminated_instances[(@num_instances - (@num + 1))..(@num_instances)]
198
- last_instances.each do |inst|
199
- PoolParty::Provisioner.provision_slave(inst, self, false)
200
- end
201
- PoolParty::Provisioner.reconfigure_master(self, force)
202
- after_launched
203
- end
214
+ vputs "request_launch_new_instances: #{@num}"
215
+ provision_slaves_from_n(@num)
204
216
  end
205
217
  end
206
218
  # Contract the cloud
@@ -2,7 +2,7 @@ module PoolParty
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 41
5
+ TINY = 42
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poolparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.41
4
+ version: 0.2.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Lerner
@@ -80,7 +80,7 @@ describe "Remoter" do
80
80
  @tc.should_receive(:is_master_running?).and_return false
81
81
  end
82
82
  it "should ask to request_launch_new_instances when the master is not running and we can start a new instance" do
83
- @tc.should_receive(:request_launch_new_instances).with(1)
83
+ @tc.should_receive(:request_launch_master_instance)
84
84
  @tc.stub!(:can_start_a_new_instance?).and_return true
85
85
  @tc.stub!(:is_master_running?).and_return false
86
86
  end
@@ -34,7 +34,7 @@
34
34
  <h1>PoolParty</h1>
35
35
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/poolparty"; return false'>
36
36
  <p>Get Version</p>
37
- <a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.40</a>
37
+ <a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.42</a>
38
38
  </div>
39
39
  <h1>&#8216;Easy cloud computing&#8217;</h1>
40
40
  <h2>What</h2>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auser-poolparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.41
4
+ version: 0.2.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Lerner