auser-poolparty 0.2.60 → 0.2.61
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.
- data/Manifest.txt +2 -0
- data/README.txt +2 -0
- data/bin/cloud-ensure-provisioning +8 -2
- data/bin/cloud-provision +1 -0
- data/bin/pool-list +10 -2
- data/bin/server-send-command +18 -0
- data/bin/server-update-hosts +47 -0
- data/lib/poolparty.rb +1 -1
- data/lib/poolparty/aska/aska.rb +1 -1
- data/lib/poolparty/base_packages/haproxy.rb +2 -2
- data/lib/poolparty/base_packages/poolparty.rb +14 -19
- data/lib/poolparty/core/object.rb +7 -4
- data/lib/poolparty/helpers/console.rb +4 -0
- data/lib/poolparty/helpers/optioner.rb +3 -0
- data/lib/poolparty/helpers/provisioners/master.rb +18 -15
- data/lib/poolparty/helpers/provisioners/slave.rb +2 -1
- data/lib/poolparty/modules/cloud_resourcer.rb +27 -8
- data/lib/poolparty/modules/method_missing_sugar.rb +1 -1
- data/lib/poolparty/net/remote.rb +3 -0
- data/lib/poolparty/net/remote_bases/ec2.rb +6 -3
- data/lib/poolparty/net/remote_instance.rb +9 -3
- data/lib/poolparty/net/remoter.rb +8 -39
- data/lib/poolparty/net/remoter_base.rb +4 -9
- data/lib/poolparty/pool/base.rb +4 -3
- data/lib/poolparty/pool/cloud.rb +19 -23
- data/lib/poolparty/pool/plugin.rb +3 -27
- data/lib/poolparty/pool/plugin_model.rb +6 -8
- data/lib/poolparty/pool/pool.rb +15 -4
- data/lib/poolparty/pool/resource.rb +5 -10
- data/lib/poolparty/pool/resources/class_package.rb +6 -4
- data/lib/poolparty/pool/resources/conditional.rb +2 -3
- data/lib/poolparty/templates/puppetrerun +1 -13
- data/lib/poolparty/templates/puppetrunner +1 -12
- data/lib/poolparty/version.rb +1 -1
- data/poolparty.gemspec +6 -2
- data/spec/poolparty/aska/aska_spec.rb +0 -8
- data/spec/poolparty/helpers/provisioner_base_spec.rb +2 -0
- data/spec/poolparty/modules/cloud_resourcer_spec.rb +2 -2
- data/spec/poolparty/net/remoter_spec.rb +0 -106
- data/spec/poolparty/pool/base_spec.rb +0 -3
- data/spec/poolparty/pool/cloud_spec.rb +10 -19
- data/spec/poolparty/pool/plugin_spec.rb +2 -2
- data/spec/poolparty/pool/pool_spec.rb +16 -1
- data/spec/poolparty/pool/resource_spec.rb +1 -1
- metadata +6 -2
@@ -16,7 +16,7 @@ module PoolParty
|
|
16
16
|
# See get_from_options for more information
|
17
17
|
def method_missing(m, *args, &block)
|
18
18
|
if block_given?
|
19
|
-
(args[0].class == self.class) ? args[0].
|
19
|
+
(args[0].class == self.class) ? args[0].run_in_context(&block) : super
|
20
20
|
else
|
21
21
|
get_from_options(m, *args, &block)
|
22
22
|
end
|
data/lib/poolparty/net/remote.rb
CHANGED
@@ -7,9 +7,11 @@ module PoolParty
|
|
7
7
|
include PoolParty::Remote::Remoter
|
8
8
|
|
9
9
|
def using(t)
|
10
|
+
@cloud = self
|
10
11
|
if available_bases.include?(t.to_sym)
|
11
12
|
unless using_remoter? || t.nil?
|
12
13
|
self.class.send :attr_reader, :remote_base
|
14
|
+
self.class.send :attr_reader, :parent_cloud
|
13
15
|
mod = "#{t}".preserved_module_constant
|
14
16
|
|
15
17
|
# mod.send :include, PoolParty::Remote::RemoterBase
|
@@ -17,6 +19,7 @@ module PoolParty
|
|
17
19
|
self.extend mod
|
18
20
|
|
19
21
|
@remote_base = "#{t}".preserved_module_constant
|
22
|
+
@parent_cloud = @cloud
|
20
23
|
end
|
21
24
|
else
|
22
25
|
puts "Unknown remote base"
|
@@ -11,6 +11,8 @@ begin
|
|
11
11
|
end
|
12
12
|
module PoolParty
|
13
13
|
module Ec2
|
14
|
+
include PoolParty::Remote::RemoterBase
|
15
|
+
|
14
16
|
def launch_new_instance!(num=1)
|
15
17
|
instance = ec2.run_instances(
|
16
18
|
:image_id => (ami || Base.ami),
|
@@ -40,13 +42,13 @@ begin
|
|
40
42
|
@id = 0
|
41
43
|
get_instances_description.each_with_index do |h,i|
|
42
44
|
if h[:status] == "running"
|
43
|
-
|
45
|
+
inst_name = @id == 0 ? "master" : "node#{@id}"
|
44
46
|
@id += 1
|
45
47
|
else
|
46
|
-
|
48
|
+
inst_name = "#{h[:status]}_node#{i}"
|
47
49
|
end
|
48
50
|
h.merge!({
|
49
|
-
:name =>
|
51
|
+
:name => inst_name,
|
50
52
|
:hostname => h[:ip],
|
51
53
|
:ip => h[:ip].convert_from_ec2_to_ip,
|
52
54
|
:index => i,
|
@@ -160,6 +162,7 @@ begin
|
|
160
162
|
:ip => resp.dnsName || "not-assigned",
|
161
163
|
:status => resp.instanceState.name,
|
162
164
|
:launching_time => resp.launchTime.parse_datetime,
|
165
|
+
:internal_ip => resp.privateDnsName,
|
163
166
|
:keypair => resp.keyName
|
164
167
|
}
|
165
168
|
rescue Exception => e
|
@@ -7,11 +7,13 @@ module PoolParty
|
|
7
7
|
include Remote
|
8
8
|
include Configurable
|
9
9
|
include CloudResourcer
|
10
|
-
|
11
|
-
def initialize(opts, parent=
|
12
|
-
|
10
|
+
|
11
|
+
def initialize(opts, parent=nil)
|
12
|
+
run_setup(parent)
|
13
|
+
|
13
14
|
set_vars_from_options(parent.options) if parent && parent.respond_to?(:options)
|
14
15
|
set_vars_from_options(opts) unless opts.nil? || opts.empty?
|
16
|
+
|
15
17
|
on_init
|
16
18
|
end
|
17
19
|
|
@@ -77,6 +79,10 @@ module PoolParty
|
|
77
79
|
def self.puppet_rerun_commad
|
78
80
|
puppet_runner_command
|
79
81
|
end
|
82
|
+
def hosts_file_listing_for(cl)
|
83
|
+
string = (cl.name == parent.name) ? "#{name}.#{parent.name}\t#{name}" : "#{name}.#{parent.name}"
|
84
|
+
"#{internal_ip}\t#{string}"
|
85
|
+
end
|
80
86
|
end
|
81
87
|
|
82
88
|
end
|
@@ -40,30 +40,6 @@ module PoolParty
|
|
40
40
|
def remote_rsync_command
|
41
41
|
"rsync -azP --exclude cache -e '#{remote_ssh_string}'"
|
42
42
|
end
|
43
|
-
# Open the cached local copy of the instances list and
|
44
|
-
# create a new RemoteInstance from each line
|
45
|
-
def list_from_local
|
46
|
-
list_file = get_working_listing_file
|
47
|
-
if list_file
|
48
|
-
out = returning Array.new do |instances|
|
49
|
-
open(list_file).read.split("\n").each do |line|
|
50
|
-
instances << RemoteInstance.new(line)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
else
|
54
|
-
out = list_from_remote(:cache => true)
|
55
|
-
end
|
56
|
-
return out
|
57
|
-
end
|
58
|
-
# List the instances that are known from the remoter_base
|
59
|
-
# Create a RemoteInstance for each of the instances from the hash
|
60
|
-
# returned by the list of instances, write them to the cached file
|
61
|
-
# and then return the array of instances
|
62
|
-
def list_from_remote(options={})
|
63
|
-
out_array = get_remote_nodes
|
64
|
-
write_to_file( local_instances_list_file_locations.first, out_array.map{|a| a.to_s }.join("\n")) if options[:cache]
|
65
|
-
out_array
|
66
|
-
end
|
67
43
|
# Get the names of the nodes. Mainly used for puppet templating
|
68
44
|
def list_of_node_names(options={})
|
69
45
|
list_of_running_instances.collect {|ri| ri.name }
|
@@ -72,13 +48,7 @@ module PoolParty
|
|
72
48
|
def list_of_node_ips(options={})
|
73
49
|
list_of_running_instances.collect {|ri| ri.ip }
|
74
50
|
end
|
75
|
-
|
76
|
-
returning Array.new do |instances|
|
77
|
-
list_of_instances(respond_to?(:keypair) ? keypair : nil).each do |h|
|
78
|
-
instances << PoolParty::Remote::RemoteInstance.new(h)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
51
|
+
|
82
52
|
# Get the instance first instance file that exists on the system from the expected places
|
83
53
|
# denoted in the local_instances_list_file_locations
|
84
54
|
def get_working_listing_file
|
@@ -210,15 +180,16 @@ module PoolParty
|
|
210
180
|
logger.debug "Launching master"
|
211
181
|
request_launch_master_instance if list_of_pending_instances.size.zero? && can_start_a_new_instance? && !is_master_running?
|
212
182
|
reset!
|
213
|
-
|
183
|
+
vputs ""
|
214
184
|
vputs "Waiting for there to be no pending instances..."
|
215
185
|
when_no_pending_instances do
|
216
186
|
wait "20.seconds"
|
217
187
|
vputs ""
|
218
188
|
vputs "Provisioning master..."
|
219
|
-
|
220
|
-
|
221
|
-
|
189
|
+
|
190
|
+
verbose ? Provisioner.provision_master(self, testing) : hide_output { Provisioner.provision_master(self, testing) }
|
191
|
+
verbose ? Provisioner.clear_master_ssl_certs(self, testing) : hide_output { Provisioner.clear_master_ssl_certs(self, testing) }
|
192
|
+
|
222
193
|
after_launched
|
223
194
|
end
|
224
195
|
end
|
@@ -258,7 +229,7 @@ module PoolParty
|
|
258
229
|
def contract_cloud_if_necessary(force=false)
|
259
230
|
if can_shutdown_an_instance?
|
260
231
|
if should_contract_cloud?(force)
|
261
|
-
|
232
|
+
vputs "Shrinking the cloud by 1"
|
262
233
|
before_shutdown
|
263
234
|
request_termination_of_non_master_instance
|
264
235
|
end
|
@@ -279,9 +250,7 @@ module PoolParty
|
|
279
250
|
|
280
251
|
# Rsync command to the instance
|
281
252
|
def rsync_storage_files_to(instance=nil)
|
282
|
-
hide_output
|
283
|
-
Kernel.system "#{rsync_storage_files_to_command(instance)}" if instance
|
284
|
-
end
|
253
|
+
hide_output {Kernel.system "#{rsync_storage_files_to_command(instance)}" if instance}
|
285
254
|
end
|
286
255
|
# Take the rsync command and execute it on the system
|
287
256
|
# if there is an instance given
|
@@ -71,7 +71,9 @@ module PoolParty
|
|
71
71
|
list.select {|i| i.name == name }.first
|
72
72
|
end
|
73
73
|
def remote_instances_list
|
74
|
-
|
74
|
+
# puts "> #{@containing_cloud.name} - #{@containing_cloud.class}"
|
75
|
+
@containing_cloud = self
|
76
|
+
@remote_instances_list ||= list_of_instances(keypair).collect {|h| PoolParty::Remote::RemoteInstance.new(h, @containing_cloud) }
|
75
77
|
end
|
76
78
|
# List the instances for the current key pair, regardless of their states
|
77
79
|
# If no keypair is passed, select them all
|
@@ -79,7 +81,7 @@ module PoolParty
|
|
79
81
|
key = keyp ? keyp : keypair
|
80
82
|
unless @describe_instances
|
81
83
|
tmpInstanceList = describe_instances.select {|a| key ? a[:keypair] == key : true }
|
82
|
-
has_master = !tmpInstanceList.select {|a| a[:name] == "master" }.empty?
|
84
|
+
has_master = !tmpInstanceList.select {|a| a[:name] == "master" }.empty?
|
83
85
|
if has_master
|
84
86
|
@describe_instances = tmpInstanceList
|
85
87
|
else
|
@@ -103,13 +105,6 @@ module PoolParty
|
|
103
105
|
def select_from_instances_on_status(status=/running/, list=[])
|
104
106
|
list.select {|a| a[:status] =~ status}
|
105
107
|
end
|
106
|
-
# Instances
|
107
|
-
# Get the master from the cloud
|
108
|
-
def master
|
109
|
-
# remote_instances_list.select {|a| a.master }.first
|
110
|
-
@list = list_from_remote
|
111
|
-
@list.reject {|a| a unless a.name =~ /master/ }.first if @list.class != String
|
112
|
-
end
|
113
108
|
# Helpers
|
114
109
|
def create_keypair
|
115
110
|
end
|
data/lib/poolparty/pool/base.rb
CHANGED
@@ -10,7 +10,6 @@ module PoolParty
|
|
10
10
|
extend MethodMissingSugar
|
11
11
|
|
12
12
|
default_options({
|
13
|
-
:environment => "production",
|
14
13
|
:user => "root", # This should change here
|
15
14
|
:base_keypair_path => "#{ENV["HOME"]}/.ec2",
|
16
15
|
:tmp_path => "/tmp/poolparty",
|
@@ -25,9 +24,11 @@ module PoolParty
|
|
25
24
|
:default_project_specfile_name => "spec/pool.spec",
|
26
25
|
:port => "80",
|
27
26
|
:forwarding_port => "8080",
|
28
|
-
:proxy_mode => "http",
|
27
|
+
:proxy_mode => "http",
|
29
28
|
# EC2 Options
|
30
|
-
:ami => "ami-1cd73375"
|
29
|
+
:ami => "ami-1cd73375",
|
30
|
+
# Options that should not be touched pretty much ever
|
31
|
+
:manifest_path => "/etc/puppet/manifests"
|
31
32
|
})
|
32
33
|
|
33
34
|
# Class methods
|
data/lib/poolparty/pool/cloud.rb
CHANGED
@@ -3,8 +3,8 @@ require File.dirname(__FILE__) + "/resource"
|
|
3
3
|
|
4
4
|
module PoolParty
|
5
5
|
module Cloud
|
6
|
-
def cloud(name=:app, &block)
|
7
|
-
clouds.has_key?(name) ? clouds[name] : (clouds[name] = Cloud.new(name,
|
6
|
+
def cloud(name=:app, parent=self, &block)
|
7
|
+
clouds.has_key?(name) ? clouds[name] : (clouds[name] = Cloud.new(name, parent, &block))
|
8
8
|
end
|
9
9
|
|
10
10
|
def clouds
|
@@ -14,7 +14,7 @@ module PoolParty
|
|
14
14
|
def with_cloud(cl, opts={}, &block)
|
15
15
|
raise CloudNotFoundException.new("Cloud not found") unless cl
|
16
16
|
cl.options.merge!(opts) if opts
|
17
|
-
cl.
|
17
|
+
cl.run_in_context &block if block
|
18
18
|
end
|
19
19
|
|
20
20
|
class Cloud
|
@@ -25,8 +25,7 @@ module PoolParty
|
|
25
25
|
include Configurable
|
26
26
|
include CloudResourcer
|
27
27
|
# extend CloudResourcer
|
28
|
-
# Net methods
|
29
|
-
include PoolParty::Remote::RemoterBase
|
28
|
+
# Net methods
|
30
29
|
include Remote
|
31
30
|
include PoolParty::CloudDsl
|
32
31
|
|
@@ -43,15 +42,17 @@ module PoolParty
|
|
43
42
|
:polling_time => "30.seconds"
|
44
43
|
})
|
45
44
|
|
46
|
-
def initialize(name, parent, &block)
|
47
|
-
@name = name
|
45
|
+
def initialize(name, parent=self, &block)
|
46
|
+
@cloud_name = @name = name
|
48
47
|
|
48
|
+
setup_defaults
|
49
49
|
plugin_directory "#{::Dir.pwd}/plugins"
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
p = parent if parent.is_a?(PoolParty::Pool::Pool)
|
52
|
+
run_setup(p, &block)
|
53
53
|
|
54
|
-
|
54
|
+
# set_parent(parent) if parent && !@parent
|
55
|
+
# self.run_in_context parent, &block if block
|
55
56
|
end
|
56
57
|
|
57
58
|
def setup_defaults
|
@@ -126,7 +127,6 @@ module PoolParty
|
|
126
127
|
@build_manifest ||= build_from_existing_file
|
127
128
|
unless @build_manifest
|
128
129
|
|
129
|
-
# reset_resources!
|
130
130
|
add_poolparty_base_requirements
|
131
131
|
|
132
132
|
@build_manifest = "class poolparty {\n #{build_short_manifest}\n}"
|
@@ -177,23 +177,19 @@ module PoolParty
|
|
177
177
|
# Also note that there is no block associated. This is because we have written
|
178
178
|
# all that is necessary in a method called enable
|
179
179
|
# which is called when there is no block
|
180
|
-
def add_poolparty_base_requirements
|
180
|
+
def add_poolparty_base_requirements
|
181
181
|
heartbeat
|
182
182
|
haproxy
|
183
183
|
ruby
|
184
|
-
|
185
|
-
end
|
186
|
-
|
187
|
-
def provisioning?
|
188
|
-
@provisioning_in_progress == true
|
184
|
+
poolparty_base_packages
|
189
185
|
end
|
190
186
|
|
191
|
-
def
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
187
|
+
def other_clouds
|
188
|
+
returning Array.new do |arr|
|
189
|
+
clouds.each do |name, cl|
|
190
|
+
arr << cl if name != self.name
|
191
|
+
end
|
192
|
+
end
|
197
193
|
end
|
198
194
|
|
199
195
|
def reset!
|
@@ -7,43 +7,19 @@ module PoolParty
|
|
7
7
|
include CloudResourcer
|
8
8
|
include Resources
|
9
9
|
|
10
|
-
attr_accessor :parent
|
11
10
|
class_inheritable_accessor :name
|
12
11
|
|
13
12
|
default_options({})
|
14
13
|
|
15
|
-
def initialize(
|
16
|
-
|
17
|
-
|
14
|
+
def initialize(p=self, opts={}, &block)
|
15
|
+
run_setup(p, &block)
|
16
|
+
enable unless block
|
18
17
|
end
|
19
18
|
|
20
19
|
# Overwrite this method
|
21
20
|
def enable
|
22
21
|
end
|
23
22
|
|
24
|
-
# Call the cloud from within the plugin
|
25
|
-
def cloud
|
26
|
-
@p = parent
|
27
|
-
while !@p.is_a?(PoolParty::Cloud)
|
28
|
-
@p = @p.parent
|
29
|
-
end
|
30
|
-
@p
|
31
|
-
end
|
32
|
-
|
33
|
-
# def method_missing(m, *args, &block)
|
34
|
-
# if block_given?
|
35
|
-
# (args[0].class == self.class) ? args[0].instance_eval(&block) : super
|
36
|
-
# elsif parent && parent.respond_to?(m)
|
37
|
-
# parent.send m, *args, &block
|
38
|
-
# else
|
39
|
-
# get_from_options(m, *args)
|
40
|
-
# end
|
41
|
-
# end
|
42
|
-
#
|
43
|
-
# def get_from_options(m, *args)
|
44
|
-
# args.empty? ? options[m] : options[m] = args[0]
|
45
|
-
# end
|
46
|
-
|
47
23
|
end
|
48
24
|
|
49
25
|
end
|
@@ -14,28 +14,26 @@ module PoolParty
|
|
14
14
|
|
15
15
|
class PluginModel
|
16
16
|
attr_accessor :name, :klass
|
17
|
-
attr_reader :parent
|
18
17
|
include MethodMissingSugar
|
19
18
|
include Configurable
|
20
19
|
include PrettyPrinter
|
21
20
|
|
22
21
|
def initialize(name,cld,&block)
|
23
22
|
@name = name
|
24
|
-
@parent = cld
|
23
|
+
# @parent = cld
|
25
24
|
class_string_name = "#{name}"
|
26
25
|
|
27
26
|
# Create the class to evaluate the plugin on the implemented call
|
28
27
|
klass = class_string_name.class_constant(PoolParty::Plugin::Plugin)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
klass.module_eval &block if block
|
28
|
+
mod = class_string_name.module_constant(&block)
|
29
|
+
|
30
|
+
# klass.extend PoolParty::Resources
|
31
|
+
klass.send :include, mod
|
34
32
|
|
35
33
|
# Store the name of the class for pretty printing later
|
36
34
|
klass.name = name
|
37
35
|
# Add the plugin definition to the cloud as an instance method
|
38
|
-
Cloud::Cloud.
|
36
|
+
Cloud::Cloud.class_eval <<-EOE
|
39
37
|
def #{name}(parent=self, &block)
|
40
38
|
@#{class_string_name.downcase} ||= #{class_string_name.class_constant}.new(parent, &block)
|
41
39
|
end
|
data/lib/poolparty/pool/pool.rb
CHANGED
@@ -9,9 +9,10 @@ module PoolParty
|
|
9
9
|
$pools ||= {}
|
10
10
|
end
|
11
11
|
|
12
|
-
def with_pool(
|
13
|
-
|
14
|
-
|
12
|
+
def with_pool(pl, opts={}, &block)
|
13
|
+
raise CloudNotFoundException.new("Pool not found") unless pl
|
14
|
+
pl.options.merge!(opts) if pl.options
|
15
|
+
pl.run_in_context &block if block
|
15
16
|
end
|
16
17
|
|
17
18
|
def reset!
|
@@ -37,7 +38,8 @@ module PoolParty
|
|
37
38
|
setup_defaults
|
38
39
|
|
39
40
|
@name = name
|
40
|
-
|
41
|
+
# run_in_context &block if block
|
42
|
+
run_setup(self, &block)
|
41
43
|
end
|
42
44
|
|
43
45
|
def setup_defaults
|
@@ -47,6 +49,15 @@ module PoolParty
|
|
47
49
|
# This is where the entire process starts
|
48
50
|
def inflate
|
49
51
|
end
|
52
|
+
|
53
|
+
def pool_clouds
|
54
|
+
@pool_clouds ||= returning Array.new do |arr|
|
55
|
+
clouds.each do |name, cl|
|
56
|
+
arr << cl if cl.parent.name == self.name
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
50
61
|
end
|
51
62
|
|
52
63
|
# Helpers
|