auser-poolparty 0.2.80 → 0.2.81
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/PostInstall.txt +1 -1
- data/generators/poolspec/USAGE +2 -2
- data/generators/poolspec/poolspec_generator.rb +1 -1
- data/lib/poolparty.rb +1 -1
- data/lib/poolparty/helpers/binary.rb +1 -1
- data/lib/poolparty/helpers/optioner.rb +1 -2
- data/lib/poolparty/modules/cloud_resourcer.rb +0 -1
- data/lib/poolparty/modules/configurable.rb +2 -0
- data/lib/poolparty/monitors/monitors/cpu_monitor.rb +2 -2
- data/lib/poolparty/net/remote_instance.rb +6 -2
- data/lib/poolparty/net/remoter.rb +8 -1
- data/lib/poolparty/poolparty/base.rb +3 -2
- data/lib/poolparty/poolparty/cloud.rb +2 -1
- data/lib/poolparty/provisioners/provisioner_base.rb +5 -1
- data/lib/poolparty/provisioners/provisioners/become_master.rb +166 -0
- data/lib/poolparty/provisioners/provisioners/master.rb +1 -1
- data/poolparty.gemspec +4 -3
- data/spec/poolparty/helpers/binary_spec.rb +1 -1
- data/spec/poolparty/helpers/provisioners/master_spec.rb +2 -2
- data/spec/poolparty/helpers/provisioners/slave_spec.rb +1 -1
- data/spec/poolparty/modules/cloud_resourcer_spec.rb +14 -2
- data/spec/poolparty/net/remote_instance_spec.rb +5 -0
- data/spec/poolparty/net/remote_spec.rb +5 -2
- data/spec/poolparty/net/remoter_spec.rb +17 -0
- data/spec/poolparty/spec_helper.rb +17 -5
- data/website/index.html +1 -1
- metadata +4 -3
data/Manifest.txt
CHANGED
@@ -262,6 +262,7 @@ lib/poolparty/poolparty/resources/symlink.rb
|
|
262
262
|
lib/poolparty/poolparty/resources/variable.rb
|
263
263
|
lib/poolparty/poolparty/script.rb
|
264
264
|
lib/poolparty/provisioners/provisioner_base.rb
|
265
|
+
lib/poolparty/provisioners/provisioners/become_master.rb
|
265
266
|
lib/poolparty/provisioners/provisioners/master.rb
|
266
267
|
lib/poolparty/provisioners/provisioners/slave.rb
|
267
268
|
lib/poolparty/spec/core/string.rb
|
data/PostInstall.txt
CHANGED
data/generators/poolspec/USAGE
CHANGED
@@ -21,7 +21,7 @@ class PoolspecGenerator < RubiGen::Base
|
|
21
21
|
m.directory ''
|
22
22
|
BASEDIRS.each { |path| m.directory path }
|
23
23
|
|
24
|
-
m.template "pool_spec_template.erb", "pool
|
24
|
+
m.template "pool_spec_template.erb", "#{@name}.pool"
|
25
25
|
# Create stubs
|
26
26
|
# m.template "template.rb", "some_file_after_erb.rb"
|
27
27
|
# m.template_copy_each ["template.rb", "template2.rb"]
|
data/lib/poolparty.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
# Load required gems
|
4
4
|
@required_software = Array.new
|
5
|
-
%w(activesupport ftools logging resolv ruby2ruby digest/sha2).each do |lib|
|
5
|
+
%w(activesupport ftools logging resolv ruby2ruby digest/sha2 open3).each do |lib|
|
6
6
|
begin
|
7
7
|
require lib
|
8
8
|
rescue Exception => e
|
@@ -5,7 +5,7 @@ module PoolParty
|
|
5
5
|
def load_pool(filename)
|
6
6
|
|
7
7
|
unless filename && ::File.readable?(filename)
|
8
|
-
puts "Please specify your cloud with -s, move it to ./pool
|
8
|
+
puts "Please specify your cloud with -s, move it to ./clouds.pool or in your POOL_SPEC environment variable"
|
9
9
|
exit(1)
|
10
10
|
else
|
11
11
|
$pool_specfile = filename
|
@@ -10,7 +10,6 @@ module PoolParty
|
|
10
10
|
include Configurable
|
11
11
|
include MethodMissingSugar
|
12
12
|
|
13
|
-
|
14
13
|
def initialize(args=[], opts={}, &block)
|
15
14
|
boolean_args << opts[:boolean_args] if opts.has_key?(:boolean_args)
|
16
15
|
|
@@ -109,7 +108,7 @@ module PoolParty
|
|
109
108
|
self.loaded_pools extract_pool_from_options(self)
|
110
109
|
|
111
110
|
reject_junk_options!
|
112
|
-
raise CloudNotFoundException.new("Please specify your cloud with -s, move it to ./pool
|
111
|
+
raise CloudNotFoundException.new("Please specify your cloud with -s, move it to ./clouds.pool or in your POOL_SPEC environment variable") unless loaded_clouds && !loaded_clouds.empty?
|
113
112
|
loaded_pools.each do |pl|
|
114
113
|
pl.configure(self.options)
|
115
114
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
#TODO: rdoc: this defines methods on poolparty objects from a passed hash of options.
|
2
|
+
# For example, this is how instance.minimum_runtime is set. See base.rb line 12 for example of default options that are added as methods in this way.
|
1
3
|
module PoolParty
|
2
4
|
module Configurable
|
3
5
|
module ClassMethods
|
@@ -10,15 +10,19 @@ module PoolParty
|
|
10
10
|
|
11
11
|
def initialize(opts, parent=self)
|
12
12
|
run_setup(parent)
|
13
|
-
|
13
|
+
|
14
14
|
set_vars_from_options(parent.options) if parent && parent.respond_to?(:options)
|
15
15
|
set_vars_from_options(opts) unless opts.nil? || opts.empty?
|
16
16
|
|
17
17
|
on_init
|
18
18
|
end
|
19
19
|
|
20
|
+
def elapsed_runtime
|
21
|
+
Time.now.to_i - launching_time.to_time.to_i
|
22
|
+
end
|
23
|
+
|
20
24
|
# Callback
|
21
|
-
def on_init
|
25
|
+
def on_init
|
22
26
|
end
|
23
27
|
|
24
28
|
# Is this remote instance the master?
|
@@ -221,6 +221,12 @@ module PoolParty
|
|
221
221
|
end
|
222
222
|
end
|
223
223
|
end
|
224
|
+
def list_of_nodes_exceeding_minimum_runtime
|
225
|
+
list_of_running_instances.reject{|i| i.elapsed_runtime < minimum_runtime}
|
226
|
+
end
|
227
|
+
def are_any_nodes_exceeding_minimum_runtime?
|
228
|
+
!list_of_nodes_exceeding_minimum_runtime.blank?
|
229
|
+
end
|
224
230
|
def is_master_running?
|
225
231
|
!list_of_running_instances.select {|a| a.name == "master"}.first.nil?
|
226
232
|
end
|
@@ -233,7 +239,8 @@ module PoolParty
|
|
233
239
|
end
|
234
240
|
# Stub method for the time being to handle the contraction of the cloud
|
235
241
|
def should_contract_cloud?(force=false)
|
236
|
-
|
242
|
+
return true if force
|
243
|
+
((are_any_nodes_exceeding_minimum_runtime? and are_too_many_instances_running?) || are_contraction_rules_valid?) || false
|
237
244
|
end
|
238
245
|
def are_contraction_rules_valid?
|
239
246
|
valid_rules?(:contract_when)
|
@@ -20,12 +20,13 @@ module PoolParty
|
|
20
20
|
:template_directory => "templates",
|
21
21
|
:template_path => "/var/lib/puppet/templates",
|
22
22
|
:module_path => "/etc/puppet/modules/poolparty",
|
23
|
-
:default_specfile_name => "pool
|
24
|
-
:default_project_specfile_name => "spec/pool
|
23
|
+
:default_specfile_name => "clouds.pool",
|
24
|
+
:default_project_specfile_name => "spec/clouds.pool",
|
25
25
|
:port => "80",
|
26
26
|
:forwarding_port => "8080",
|
27
27
|
:proxy_mode => "http",
|
28
28
|
:messenger_client_port => 7050,
|
29
|
+
:minimum_runtime => 3000, #50.minutes in seconds
|
29
30
|
# EC2 Options
|
30
31
|
:ami => "ami-1cd73375",
|
31
32
|
:size => 'm1.small', # must be 'm1.small', 'm1.large', 'm1.xlarge', 'c1.medium', or 'c1.xlarge'
|
@@ -38,6 +38,7 @@ module PoolParty
|
|
38
38
|
:secret_access_key => Base.secret_access_key,
|
39
39
|
:ec2_dir => ENV["EC2_HOME"],
|
40
40
|
:keypair => (ENV["KEYPAIR_NAME"].nil? || ENV["KEYPAIR_NAME"].empty?) ? nil : ENV["KEYPAIR_NAME"],
|
41
|
+
:minimum_runtime => Base.minimum_runtime,
|
41
42
|
:ami => 'ami-44bd592d'
|
42
43
|
})
|
43
44
|
|
@@ -144,7 +145,7 @@ module PoolParty
|
|
144
145
|
end
|
145
146
|
|
146
147
|
def copy_misc_templates
|
147
|
-
["namespaceauth.conf"].each do |f|
|
148
|
+
["namespaceauth.conf", "puppet.conf"].each do |f|
|
148
149
|
copy_file_to_storage_directory(::File.join(::File.dirname(__FILE__), "..", "templates", f))
|
149
150
|
end
|
150
151
|
end
|
@@ -40,6 +40,10 @@ module PoolParty
|
|
40
40
|
Provisioner::Slave.new(instance, cloud).process_configure!(testing)
|
41
41
|
end
|
42
42
|
|
43
|
+
def self.become_master(cloud, testing=false)
|
44
|
+
Provisioner::BecomeMaster.new(cloud).process_install!(testing)
|
45
|
+
end
|
46
|
+
|
43
47
|
def self.process_clean_reconfigure_for!(instance, cloud, testing=false)
|
44
48
|
Provisioner::Master.new(cloud).process_clean_reconfigure_for!(instance, testing)
|
45
49
|
end
|
@@ -154,7 +158,7 @@ module PoolParty
|
|
154
158
|
s << "puppetca --clean #{instance.name}.compute-1.internal 2>&1 > /dev/null;"
|
155
159
|
s << "puppetca --clean #{instance.name}.ec2.internal 2>&1 > /dev/null"
|
156
160
|
end
|
157
|
-
@cloud.run_command_on(str, @cloud.master)
|
161
|
+
# @cloud.run_command_on(str, @cloud.master)
|
158
162
|
end
|
159
163
|
end
|
160
164
|
def clear_master_ssl_certs
|
@@ -0,0 +1,166 @@
|
|
1
|
+
module PoolParty
|
2
|
+
module Provisioner
|
3
|
+
class BecomeMaster < ProvisionerBase
|
4
|
+
|
5
|
+
def initialize(cl=self, os=:ubuntu)
|
6
|
+
raise MasterException.new(:no_ip) unless cl.master && cl.master.ip
|
7
|
+
super(cl.master, cl, os)
|
8
|
+
@master_ip = cl.master.ip
|
9
|
+
end
|
10
|
+
|
11
|
+
def valid?
|
12
|
+
!(@cloud.nil? || @cloud.master.nil?)
|
13
|
+
end
|
14
|
+
|
15
|
+
def error
|
16
|
+
raise RemoteException.new(:could_not_install, "Your cloud does not have a master")
|
17
|
+
end
|
18
|
+
|
19
|
+
def first_install_tasks
|
20
|
+
[
|
21
|
+
create_local_hosts_entry
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
def install_tasks
|
26
|
+
[
|
27
|
+
setup_basic_structure,
|
28
|
+
setup_configs,
|
29
|
+
setup_fileserver,
|
30
|
+
setup_autosigning,
|
31
|
+
restart_puppetmaster,
|
32
|
+
run_first_time,
|
33
|
+
create_local_node,
|
34
|
+
] << configure_tasks
|
35
|
+
end
|
36
|
+
|
37
|
+
def configure_tasks
|
38
|
+
[
|
39
|
+
create_local_node,
|
40
|
+
move_templates,
|
41
|
+
setup_poolparty,
|
42
|
+
create_poolparty_manifest,
|
43
|
+
restart_puppetd
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
47
|
+
# If the master is not in the hosts file, then add it to the hosts file
|
48
|
+
def create_local_hosts_entry
|
49
|
+
<<-EOS
|
50
|
+
echo "Creating local host entry"
|
51
|
+
if [ -z \"$(grep -v '#' /etc/hosts | grep 'puppet')" ]; then echo '#{@master_ip} master puppet localhost' >> /etc/hosts; fi
|
52
|
+
hostname master
|
53
|
+
EOS
|
54
|
+
end
|
55
|
+
|
56
|
+
def setup_basic_structure
|
57
|
+
<<-EOS
|
58
|
+
echo "Creating basic structure for poolparty"
|
59
|
+
mkdir -p /etc/puppet/manifests/nodes
|
60
|
+
mkdir -p /etc/puppet/manifests/classes
|
61
|
+
echo "import 'nodes/*.pp'" > /etc/puppet/manifests/site.pp
|
62
|
+
echo "import 'classes/*.pp'" >> /etc/puppet/manifests/site.pp
|
63
|
+
cp #{Base.remote_storage_path}/namespaceauth.conf /etc/puppet/namespaceauth.conf
|
64
|
+
EOS
|
65
|
+
end
|
66
|
+
|
67
|
+
def setup_configs
|
68
|
+
<<-EOS
|
69
|
+
echo "Setting up configuration"
|
70
|
+
cp #{Base.remote_storage_path}/puppet.conf /etc/puppet/puppet.conf
|
71
|
+
EOS
|
72
|
+
end
|
73
|
+
|
74
|
+
def setup_fileserver
|
75
|
+
<<-EOS
|
76
|
+
echo "Setting up the master fileserver"
|
77
|
+
echo "
|
78
|
+
[files]
|
79
|
+
path #{Base.remote_storage_path}
|
80
|
+
allow *" > /etc/puppet/fileserver.conf
|
81
|
+
mkdir -p /var/poolparty/facts
|
82
|
+
mkdir -p /var/poolparty/files
|
83
|
+
mkdir -p /etc/poolparty
|
84
|
+
EOS
|
85
|
+
end
|
86
|
+
# Change this eventually for better security supportsetup_fileserver
|
87
|
+
def setup_autosigning
|
88
|
+
<<-EOS
|
89
|
+
echo "Creating accessibility for the nodes"
|
90
|
+
echo "*" > /etc/puppet/autosign.conf
|
91
|
+
EOS
|
92
|
+
end
|
93
|
+
|
94
|
+
def setup_poolparty
|
95
|
+
<<-EOS
|
96
|
+
echo "Setting the poolparty configuration"
|
97
|
+
cp #{Base.remote_storage_path}/#{Base.key_file_locations.first} "#{Base.base_config_directory}/.ppkeys"
|
98
|
+
mv #{Base.remote_storage_path}/#{Base.default_specfile_name} #{Base.base_config_directory}/
|
99
|
+
EOS
|
100
|
+
end
|
101
|
+
|
102
|
+
def copy_ssh_app
|
103
|
+
"cp #{Base.remote_storage_path}/#{@cloud.full_keypair_name} #{@cloud.remote_keypair_path}" if @cloud.remote_keypair_path != "#{Base.remote_storage_path}/#{@cloud.full_keypair_name}"
|
104
|
+
end
|
105
|
+
|
106
|
+
# /etc/init.d/puppetmaster stop; rm -rf /etc/puppet/ssl; /etc/init.d/puppetmaster start
|
107
|
+
# ps aux | grep puppetmaster | grep -v grep | awk '{print $2}' | xargs kill;
|
108
|
+
def restart_puppetmaster
|
109
|
+
<<-EOS
|
110
|
+
echo "(Re)starting poolparty"
|
111
|
+
. /etc/profile
|
112
|
+
/etc/init.d/puppetmaster stop;rm -rf /etc/poolparty/ssl;puppetmasterd --verbose;/etc/init.d/puppetmaster start
|
113
|
+
EOS
|
114
|
+
end
|
115
|
+
|
116
|
+
def run_first_time
|
117
|
+
<<-EOE
|
118
|
+
echo "Running first time run"
|
119
|
+
cp #{Base.remote_storage_path}/#{Base.template_directory}/puppetrunner /usr/bin/puppetrunner
|
120
|
+
chmod +x /usr/bin/puppetrunner
|
121
|
+
EOE
|
122
|
+
end
|
123
|
+
|
124
|
+
# TODO:
|
125
|
+
# Consider this method in the manifest
|
126
|
+
def create_local_node
|
127
|
+
str = <<-EOS
|
128
|
+
node default {
|
129
|
+
include poolparty
|
130
|
+
}
|
131
|
+
EOS
|
132
|
+
@cloud.list_of_running_instances.each do |ri|
|
133
|
+
str << <<-EOS
|
134
|
+
node "#{ri.name}" inherits default {}
|
135
|
+
EOS
|
136
|
+
end
|
137
|
+
"echo '#{str}' > #{Base.manifest_path}/nodes/nodes.pp"
|
138
|
+
end
|
139
|
+
|
140
|
+
def move_templates
|
141
|
+
<<-EOS
|
142
|
+
echo "Moving templates into place"
|
143
|
+
mkdir -p #{Base.template_path}
|
144
|
+
cp -R #{Base.remote_storage_path}/#{Base.template_directory}/* #{Base.template_path}
|
145
|
+
EOS
|
146
|
+
end
|
147
|
+
|
148
|
+
def create_poolparty_manifest
|
149
|
+
<<-EOS
|
150
|
+
echo "Creating the manifest"
|
151
|
+
cp #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolparty.pp
|
152
|
+
#{copy_ssh_app}
|
153
|
+
EOS
|
154
|
+
end
|
155
|
+
|
156
|
+
def restart_puppetd
|
157
|
+
# /usr/bin/puppetrerun
|
158
|
+
# /usr/bin/puppetcleaner master
|
159
|
+
<<-EOS
|
160
|
+
echo "Running puppet manifest"
|
161
|
+
/usr/bin/puppetrerun
|
162
|
+
EOS
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
@@ -49,7 +49,7 @@ module PoolParty
|
|
49
49
|
def create_local_hosts_entry
|
50
50
|
<<-EOS
|
51
51
|
echo "Creating local host entry"
|
52
|
-
if [ -z \"$(grep -v '#' /etc/hosts | grep 'puppet')" ]; then echo '#{@master_ip}
|
52
|
+
if [ -z \"$(grep -v '#' /etc/hosts | grep 'puppet')" ]; then echo '#{@master_ip} master puppet localhost' >> /etc/hosts; fi
|
53
53
|
hostname master
|
54
54
|
EOS
|
55
55
|
end
|
data/poolparty.gemspec
CHANGED
@@ -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.
|
4
|
+
version: 0.2.81
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Lerner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-10 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -375,6 +375,7 @@ files:
|
|
375
375
|
- lib/poolparty/poolparty/resources/variable.rb
|
376
376
|
- lib/poolparty/poolparty/script.rb
|
377
377
|
- lib/poolparty/provisioners/provisioner_base.rb
|
378
|
+
- lib/poolparty/provisioners/provisioners/become_master.rb
|
378
379
|
- lib/poolparty/provisioners/provisioners/master.rb
|
379
380
|
- lib/poolparty/provisioners/provisioners/slave.rb
|
380
381
|
- lib/poolparty/spec/core/string.rb
|
@@ -520,7 +521,7 @@ files:
|
|
520
521
|
has_rdoc: true
|
521
522
|
homepage: http://poolparty.rubyforge.org
|
522
523
|
post_install_message: |-
|
523
|
-
Get ready to jump in the pool, you just installed PoolParty! (Updated at
|
524
|
+
Get ready to jump in the pool, you just installed PoolParty! (Updated at 13:44 12/10/08)
|
524
525
|
|
525
526
|
To get started, run the generator:
|
526
527
|
|
@@ -17,7 +17,7 @@ describe "Binary" do
|
|
17
17
|
describe "get_existing_spec_location" do
|
18
18
|
before(:each) do
|
19
19
|
::File.stub!(:readable?).and_return false
|
20
|
-
::File.stub!(:readable?).with("#{Base.storage_directory}/pool
|
20
|
+
::File.stub!(:readable?).with("#{Base.storage_directory}/clouds.pool").and_return true
|
21
21
|
end
|
22
22
|
it "should be a String" do
|
23
23
|
Binary.get_existing_spec_location.class.should == String
|
@@ -8,12 +8,12 @@ describe "Master provisioner" do
|
|
8
8
|
stub_list_from_remote_for(@cloud)
|
9
9
|
@remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
|
10
10
|
|
11
|
-
@cloud.stub!(:master).and_return
|
11
|
+
@cloud.stub!(:master).and_return sample_instances.first
|
12
12
|
@master = Master.new(@cloud, :ubuntu)
|
13
13
|
end
|
14
14
|
describe "install_tasks" do
|
15
15
|
before(:each) do
|
16
|
-
@cloud.stub!(:master).and_return
|
16
|
+
@cloud.stub!(:master).and_return sample_instances.first
|
17
17
|
@master.stub!(:cloud).and_return @cloud
|
18
18
|
end
|
19
19
|
it "should call install_puppet_master" do
|
@@ -9,7 +9,7 @@ describe "Slave provisioner" do
|
|
9
9
|
@remote_instance = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :status => "running", :name => "master"}, @cloud)
|
10
10
|
stub_list_from_remote_for(@cloud)
|
11
11
|
|
12
|
-
@cloud.stub!(:master).and_return
|
12
|
+
@cloud.stub!(:master).and_return sample_instances.first
|
13
13
|
|
14
14
|
@slave = Slave.new(@remote_instance, @cloud, :ubuntu)
|
15
15
|
end
|
@@ -2,7 +2,11 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
2
|
|
3
3
|
class ResourcerTestClass
|
4
4
|
include CloudResourcer
|
5
|
-
include Configurable
|
5
|
+
include Configurable
|
6
|
+
|
7
|
+
default_options({
|
8
|
+
:minimum_runtime => 50.minutes
|
9
|
+
})
|
6
10
|
|
7
11
|
def initialize(&block)
|
8
12
|
store_block(&block) if block
|
@@ -40,10 +44,18 @@ describe "CloudResourcer" do
|
|
40
44
|
@tc.minimum_instances.should == 1
|
41
45
|
@tc.maximum_instances.should == 1
|
42
46
|
end
|
43
|
-
it "should set the max to the maximum instances to the last" do
|
47
|
+
it "should set the max to the maximum instances to the last in a given range" do
|
44
48
|
@tc.instances 4..10
|
45
49
|
@tc.maximum_instances.should == 10
|
46
50
|
end
|
51
|
+
it "should have default minimum_runtime of 50 minutes (3000 seconds)" do
|
52
|
+
Base.stub!(:minimum_runtime).and_return 50.minutes
|
53
|
+
@tc.minimum_runtime.should == 50.minutes
|
54
|
+
end
|
55
|
+
it "should have minimum_runtime" do
|
56
|
+
@tc.minimum_runtime 40.minutes
|
57
|
+
@tc.minimum_runtime.should == 40.minutes
|
58
|
+
end
|
47
59
|
describe "keypair_path" do
|
48
60
|
before(:each) do
|
49
61
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
include Remote
|
4
|
+
include Aska
|
4
5
|
|
5
6
|
describe "Remote Instance" do
|
6
7
|
before(:each) do
|
@@ -58,6 +59,10 @@ describe "Remote Instance" do
|
|
58
59
|
before(:each) do
|
59
60
|
@ri = RemoteInstance.new(@valid_hash, nil)
|
60
61
|
end
|
62
|
+
it "should give the elapsed time" do
|
63
|
+
@ri.stub!(:launching_time).and_return(30.minutes.ago)
|
64
|
+
@ri.elapsed_runtime.should be >= 1800
|
65
|
+
end
|
61
66
|
it "should be say that it is the master if the name is master" do
|
62
67
|
@ri.name.should == "master"
|
63
68
|
@ri.master?.should == true
|
@@ -101,6 +101,8 @@ describe "Remote" do
|
|
101
101
|
end
|
102
102
|
it "should be true if there are" do
|
103
103
|
add_stub_instance_to(@tc, 8)
|
104
|
+
add_stub_instance_to(@tc, 9)
|
105
|
+
add_stub_instance_to(@tc, 10)
|
104
106
|
@tc.minimum_number_of_instances_are_running?.should == true
|
105
107
|
end
|
106
108
|
end
|
@@ -239,9 +241,10 @@ describe "Remote" do
|
|
239
241
|
describe "contract_cloud_if_necessary" do
|
240
242
|
before(:each) do
|
241
243
|
@tc.stub!(:request_termination_of_non_master_instance).and_return true
|
242
|
-
@tc.stub!(:
|
244
|
+
@tc.stub!(:are_any_nodes_exceeding_minimum_runtime?).and_return true
|
243
245
|
@tc.stub!(:wait).and_return true
|
244
246
|
@tc.stub!(:valid_rules?).and_return false
|
247
|
+
@tc.stub!(:can_shutdown_an_instance?).and_return true
|
245
248
|
end
|
246
249
|
it "should receive can_shutdown_an_instance?" do
|
247
250
|
@tc.should_receive(:can_shutdown_an_instance?).once
|
@@ -250,7 +253,7 @@ describe "Remote" do
|
|
250
253
|
@tc.should_receive(:should_contract_cloud?).once.and_return false
|
251
254
|
end
|
252
255
|
it "should call request_termination_of_non_master_instance if we should_contract_cloud?" do
|
253
|
-
@tc.
|
256
|
+
@tc.stub!(:should_contract_cloud?).and_return true
|
254
257
|
@tc.should_receive(:request_termination_of_non_master_instance).once.and_return true
|
255
258
|
end
|
256
259
|
after(:each) do
|
@@ -81,6 +81,23 @@ describe "Remoter" do
|
|
81
81
|
@tc = TestClass.new
|
82
82
|
stub_list_from_remote_for @tc # sets the list of instances to 2
|
83
83
|
end
|
84
|
+
describe "list_of_nodes_exceeding_minimum_runtime" do
|
85
|
+
before(:each) do
|
86
|
+
@tc.stub!(:minimum_runtime).and_return 3000
|
87
|
+
end
|
88
|
+
it "should not be empty" do
|
89
|
+
@tc.list_of_running_instances.size.should == 2
|
90
|
+
@tc.list_of_running_instances.first.elapsed_runtime.should be > 3000
|
91
|
+
@tc.list_of_nodes_exceeding_minimum_runtime.size.should be > 0
|
92
|
+
end
|
93
|
+
it "should return a RemoteInstance" do
|
94
|
+
@tc.list_of_nodes_exceeding_minimum_runtime.first.should be_instance_of(PoolParty::Remote::RemoteInstance)
|
95
|
+
end
|
96
|
+
it "are_any_nodes_exceeding_minimum_runtime? should be true" do
|
97
|
+
@tc.are_any_nodes_exceeding_minimum_runtime?.should == true
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
84
101
|
describe "are_too_few_instances_running?" do
|
85
102
|
it "should be false if the number of running instances is larger than the minimum instances" do
|
86
103
|
@tc.stub!(:minimum_instances).and_return 1
|
@@ -18,6 +18,8 @@ extend PoolParty
|
|
18
18
|
|
19
19
|
def are_too_many_instances_running?
|
20
20
|
end
|
21
|
+
def are_any_nodes_exceeding_minimum_runtime?
|
22
|
+
end
|
21
23
|
def are_too_few_instances_running?
|
22
24
|
end
|
23
25
|
|
@@ -67,7 +69,16 @@ def read_file(path)
|
|
67
69
|
require "open-uri"
|
68
70
|
open(path).read
|
69
71
|
end
|
72
|
+
def sample_instances_list
|
73
|
+
@sample_instances_lister ||= [
|
74
|
+
{:ip => "127.0.0.1", :name => "master", :launching_time => 2.days.ago},
|
75
|
+
{:ip => "127.0.0.2", :name => "node1", :launching_time => 2.days.ago}
|
76
|
+
]
|
77
|
+
end
|
70
78
|
|
79
|
+
def sample_instances
|
80
|
+
sample_instances_list.map {|h| PoolParty::Remote::RemoteInstance.new(h) }
|
81
|
+
end
|
71
82
|
def stub_list_from_local_for(o)
|
72
83
|
@list =<<-EOS
|
73
84
|
master 192.168.0.1
|
@@ -77,22 +88,21 @@ def stub_list_from_local_for(o)
|
|
77
88
|
@file.stub!(:read).and_return @list
|
78
89
|
o.stub!(:get_working_listing_file).and_return @file
|
79
90
|
o.stub!(:open).and_return @file
|
80
|
-
|
91
|
+
|
81
92
|
@ris = @list.split(/\n/).map {|line| PoolParty::Remote::RemoteInstance.new(line) }
|
82
93
|
end
|
83
94
|
def stub_remoter_for(o)
|
84
|
-
o.stub!(:ec2).and_return EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "even more not a key")
|
95
|
+
o.stub!(:ec2).and_return EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "even more not a key")
|
96
|
+
o.stub!(:list_of_running_instances).and_return sample_instances
|
85
97
|
end
|
86
98
|
def stub_list_from_remote_for(o, launch_stub=true)
|
87
99
|
stub_remoter_for(o)
|
88
|
-
@sample_instances_list = [{:ip => "127.0.0.1", :name => "master"}, {:ip => "127.0.0.2", :name => "node1"}]
|
89
|
-
@ris = @sample_instances_list.map {|h| PoolParty::Remote::RemoteInstance.new(h) }
|
90
100
|
o.stub!(:access_key).and_return "NOT A KEY"
|
91
101
|
o.stub!(:secret_access_key).and_return "NOT A SECRET"
|
92
102
|
# o.stub!(:list_from_remote).and_return ris
|
93
103
|
# o.stub!(:remote_instances_list).once.and_return ris
|
94
104
|
# o.stub!(:master).and_return @ris[0]
|
95
|
-
o.stub!(:launch_new_instance!).and_return
|
105
|
+
o.stub!(:launch_new_instance!).and_return sample_instances.first if launch_stub
|
96
106
|
stub_list_of_instances_for(o)
|
97
107
|
end
|
98
108
|
|
@@ -125,7 +135,9 @@ end
|
|
125
135
|
def add_stub_instance_to(o, num, status="running")
|
126
136
|
reset_response!
|
127
137
|
response_list_of_instances << stub_instance(num, status)
|
138
|
+
sample_instances_list << stub_instance(num, status)
|
128
139
|
stub_list_of_instances_for o
|
140
|
+
stub_remoter_for(o)
|
129
141
|
end
|
130
142
|
def ris
|
131
143
|
@ris ||= response_list_of_instances.collect {|h| PoolParty::Remote::RemoteInstance.new(h) }
|
data/website/index.html
CHANGED
@@ -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.
|
37
|
+
<a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.81</a>
|
38
38
|
</div>
|
39
39
|
<h1>‘Easy cloud computing’</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.
|
4
|
+
version: 0.2.81
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Lerner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-10 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -375,6 +375,7 @@ files:
|
|
375
375
|
- lib/poolparty/poolparty/resources/variable.rb
|
376
376
|
- lib/poolparty/poolparty/script.rb
|
377
377
|
- lib/poolparty/provisioners/provisioner_base.rb
|
378
|
+
- lib/poolparty/provisioners/provisioners/become_master.rb
|
378
379
|
- lib/poolparty/provisioners/provisioners/master.rb
|
379
380
|
- lib/poolparty/provisioners/provisioners/slave.rb
|
380
381
|
- lib/poolparty/spec/core/string.rb
|
@@ -520,7 +521,7 @@ files:
|
|
520
521
|
has_rdoc: true
|
521
522
|
homepage: http://poolparty.rubyforge.org
|
522
523
|
post_install_message: |-
|
523
|
-
Get ready to jump in the pool, you just installed PoolParty! (Updated at
|
524
|
+
Get ready to jump in the pool, you just installed PoolParty! (Updated at 13:44 12/10/08)
|
524
525
|
|
525
526
|
To get started, run the generator:
|
526
527
|
|