auser-poolparty 0.2.63 → 0.2.64
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 +0 -1
- data/bin/pool-list +1 -1
- data/bin/server-update-hosts +10 -2
- data/examples/plugin_without_plugin_directory.rb +1 -2
- data/lib/poolparty/base_packages/haproxy.rb +1 -1
- data/lib/poolparty/base_packages/poolparty.rb +3 -3
- data/lib/poolparty/dependency_resolutions/puppet.rb +0 -3
- data/lib/poolparty/helpers/console.rb +2 -2
- data/lib/poolparty/helpers/provisioners/master.rb +2 -4
- data/lib/poolparty/modules/cloud_resourcer.rb +21 -4
- data/lib/poolparty/net/remote_bases/ec2/ec2_response_object.rb +23 -9
- data/lib/poolparty/net/remote_bases/ec2.rb +7 -7
- data/lib/poolparty/net/remoter_base.rb +4 -5
- data/lib/poolparty/plugins/deploydirectory.rb +2 -2
- data/lib/poolparty/pool/base.rb +3 -2
- data/lib/poolparty/pool/cloud.rb +27 -22
- data/lib/poolparty/pool/plugin.rb +14 -4
- data/lib/poolparty/pool/plugin_model.rb +4 -2
- data/lib/poolparty/pool/pool.rb +6 -2
- data/lib/poolparty/pool/resource.rb +9 -1
- data/lib/poolparty/pool/resources/class_package.rb +15 -7
- data/lib/poolparty/pool/resources/conditional.rb +5 -5
- data/lib/poolparty/pool/script.rb +10 -5
- data/lib/poolparty/templates/puppetrerun +6 -1
- data/lib/poolparty/version.rb +1 -1
- data/poolparty.gemspec +2 -3
- data/spec/poolparty/pool/cloud_spec.rb +7 -3
- data/spec/poolparty/pool/example_spec.rb +0 -84
- data/spec/poolparty/pool/plugin_model_spec.rb +1 -0
- data/spec/poolparty/pool/plugin_spec.rb +14 -1
- data/spec/poolparty/pool/resource_spec.rb +15 -0
- data/spec/poolparty/pool/resources/conditional_spec.rb +12 -5
- data/spec/poolparty/pool/script_spec.rb +0 -4
- data/spec/poolparty/pool/test_plugins/webserver.rb +1 -0
- metadata +2 -3
- data/examples/with_apache_plugin.rb +0 -22
data/Manifest.txt
CHANGED
@@ -49,7 +49,6 @@ config/requirements.rb
|
|
49
49
|
examples/basic.rb
|
50
50
|
examples/plugin_without_plugin_directory.rb
|
51
51
|
examples/poolparty.rb
|
52
|
-
examples/with_apache_plugin.rb
|
53
52
|
generators/poolspec/USAGE
|
54
53
|
generators/poolspec/poolspec_generator.rb
|
55
54
|
generators/poolspec/templates/pool_spec_template.erb
|
data/bin/pool-list
CHANGED
@@ -14,7 +14,7 @@ o.loaded_pools.each do |pool|
|
|
14
14
|
with_pool(pool) do
|
15
15
|
puts header("Listing pool #{name}")
|
16
16
|
clouds.each do |name, cloud|
|
17
|
-
puts subheader("Cloud: #{name}")
|
17
|
+
puts subheader("Cloud: #{name} (#{cloud.keypair})")
|
18
18
|
with_cloud(cloud) do
|
19
19
|
puts header("Listing cloud #{name}")
|
20
20
|
puts subheader("Active instances")
|
data/bin/server-update-hosts
CHANGED
@@ -7,11 +7,17 @@ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
|
|
7
7
|
opts.on('-n name', '--name name', 'Update hosts for local pool named [name]') { |p| optioner.poolname p }
|
8
8
|
end
|
9
9
|
|
10
|
-
o.loaded_pools.each do |pool|
|
10
|
+
o.loaded_pools.each do |pool|
|
11
11
|
with_pool(pool) do
|
12
|
+
puts "Pool: #{name}"
|
12
13
|
pool_clouds.each do |cl|
|
13
14
|
|
15
|
+
vputs "Cloud: #{cl.name}"
|
16
|
+
|
14
17
|
new_hosts_listing = returning Array.new do |arr|
|
18
|
+
|
19
|
+
puts cl.list_of_running_instances
|
20
|
+
|
15
21
|
cl.list_of_running_instances.each do |ri|
|
16
22
|
vputs ri.hosts_file_listing_for(cl)
|
17
23
|
arr << ri.hosts_file_listing_for(cl)
|
@@ -24,6 +30,8 @@ o.loaded_pools.each do |pool|
|
|
24
30
|
end
|
25
31
|
end.join("\n")
|
26
32
|
|
33
|
+
puts new_hosts_listing
|
34
|
+
|
27
35
|
if testing
|
28
36
|
puts new_hosts_listing
|
29
37
|
else
|
@@ -33,7 +41,7 @@ o.loaded_pools.each do |pool|
|
|
33
41
|
new_hosts_listing.split(/\n/).each do |line|
|
34
42
|
parts = line.split(/\t/).map {|a| a.chomp }
|
35
43
|
ip,hostname,aliases = parts[0], parts[1], parts[2..-1]
|
36
|
-
|
44
|
+
puts "ip: #{ip} for #{hostname}"
|
37
45
|
arr << PoolParty::Resources::Host.new(:ip => ip, :name => Resolv::DNS.new.getaddress(hostname), :alias => aliases).to_string
|
38
46
|
end
|
39
47
|
end
|
@@ -42,7 +42,7 @@ module PoolParty
|
|
42
42
|
|
43
43
|
has_exec(:name => "build_messenger", :command => ". /etc/profile && server-build-messenger")
|
44
44
|
has_exec(:name => "start_node", :command => ". /etc/profile && server-start-node")
|
45
|
-
has_exec(:name => "update_hosts", :command => ". /etc/profile && server-update-hosts")
|
45
|
+
has_exec(:name => "update_hosts", :command => ". /etc/profile && server-update-hosts -n #{cloud.name}")
|
46
46
|
|
47
47
|
# execute_on_node do
|
48
48
|
has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/5") do
|
@@ -76,11 +76,11 @@ module PoolParty
|
|
76
76
|
end
|
77
77
|
has_cron(:name => "Load handler", :user => Base.user, :minute => "*/4") do
|
78
78
|
requires get_gempackage("poolparty")
|
79
|
-
command(". /etc/profile && cloud-handle-load")
|
79
|
+
command(". /etc/profile && cloud-handle-load -n #{cloud.name}")
|
80
80
|
end
|
81
81
|
has_cron(:name => "provisioning ensurer", :user => Base.user, :minute => "*/2") do
|
82
82
|
requires get_gempackage("poolparty")
|
83
|
-
command ". /etc/profile && cloud-ensure-provisioning"
|
83
|
+
command ". /etc/profile && cloud-ensure-provisioning -n #{cloud.name}"
|
84
84
|
end
|
85
85
|
# has_runit_service("client_server", "pm_client", File.join(File.dirname(__FILE__), "..", "templates/messenger/client/"))
|
86
86
|
# has_runit_service("master_server", "pm_master", File.join(File.dirname(__FILE__), "..", "templates/messenger/master/"))
|
@@ -23,9 +23,6 @@ module PoolParty
|
|
23
23
|
output << @prestring || ""
|
24
24
|
|
25
25
|
if resources && !resources.empty?
|
26
|
-
# @cp = classpackage_with_self(self)
|
27
|
-
# output << @cp.to_string
|
28
|
-
# output << "include #{@cp.name.downcase.sanitize}"
|
29
26
|
output << resources_string_from_resources(resources, pre)
|
30
27
|
end
|
31
28
|
|
@@ -17,11 +17,11 @@ module PoolParty
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def extract_cloud_from_options(o)
|
20
|
-
o.cloudname ? [cloud(o.cloudname.downcase.to_sym)] :
|
20
|
+
o.cloudname ? [cloud(o.cloudname.downcase.to_sym)] : clouds.collect {|n,cl| cl}
|
21
21
|
end
|
22
22
|
|
23
23
|
def extract_pool_from_options(o)
|
24
|
-
o.poolname ? [pool(o.poolname.downcase.to_sym)] :
|
24
|
+
o.poolname ? [pool(o.poolname.downcase.to_sym)] : pools.collect {|n,pl| pl}
|
25
25
|
end
|
26
26
|
|
27
27
|
# Clear all the pools and reload the console
|
@@ -135,9 +135,7 @@ wget http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty.gem?raw=tru
|
|
135
135
|
echo "(Re)starting poolparty"
|
136
136
|
. /etc/profile
|
137
137
|
# /etc/init.d/puppetmaster stop #{unix_hide_string}
|
138
|
-
ps aux | grep puppetmaster | awk '{print $2}' | xargs kill;rm -rf /etc/puppet/ssl;puppetmasterd --verbose
|
139
|
-
# # Start it back up
|
140
|
-
/etc/init.d/puppetmaster start
|
138
|
+
ps aux | grep puppetmaster | awk '{print $2}' | xargs kill;rm -rf /etc/puppet/ssl;puppetmasterd --verbose;/etc/init.d/puppetmaster start
|
141
139
|
EOS
|
142
140
|
end
|
143
141
|
|
@@ -194,7 +192,7 @@ cp #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolpa
|
|
194
192
|
def restart_puppetd
|
195
193
|
<<-EOS
|
196
194
|
echo "Running puppet manifest"
|
197
|
-
/bin/sh /usr/bin/
|
195
|
+
/bin/sh /usr/bin/puppetrerun
|
198
196
|
EOS
|
199
197
|
end
|
200
198
|
end
|
@@ -10,12 +10,16 @@ module PoolParty
|
|
10
10
|
|
11
11
|
# Store block
|
12
12
|
def store_block(&block)
|
13
|
-
@stored_block ||= block
|
13
|
+
@stored_block ||= block ? block : nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def stored_block
|
17
|
+
@stored_block
|
14
18
|
end
|
15
19
|
|
16
20
|
# This will run the blocks after they are stored if there is a block
|
17
21
|
# associated
|
18
|
-
def run_stored_block
|
22
|
+
def run_stored_block
|
19
23
|
self.run_in_context @stored_block if @stored_block
|
20
24
|
end
|
21
25
|
|
@@ -80,6 +84,7 @@ module PoolParty
|
|
80
84
|
def context_stack
|
81
85
|
@@context_stack ||= []
|
82
86
|
end
|
87
|
+
|
83
88
|
def run_setup(parent, should_set_parent=true, &block)
|
84
89
|
context_stack.push parent
|
85
90
|
|
@@ -91,13 +96,13 @@ module PoolParty
|
|
91
96
|
|
92
97
|
# Set the parent on the resource
|
93
98
|
def set_parent(sink_options=true)
|
94
|
-
|
99
|
+
unless context_stack.last.nil?
|
95
100
|
@parent = context_stack.last
|
96
101
|
# Add self as a service on the parent
|
97
102
|
parent.add_service(self) if parent.respond_to?(:add_service)
|
98
103
|
# Take the options of the parents
|
99
104
|
configure(parent.options) if parent && parent.respond_to?(:options) && sink_options
|
100
|
-
|
105
|
+
end
|
101
106
|
end
|
102
107
|
|
103
108
|
def number_of_resources
|
@@ -111,5 +116,17 @@ module PoolParty
|
|
111
116
|
@parent ||= nil
|
112
117
|
end
|
113
118
|
|
119
|
+
def plugin_store
|
120
|
+
@plugin_store ||= []
|
121
|
+
end
|
122
|
+
|
123
|
+
def realize_plugins!
|
124
|
+
plugin_store.each {|plugin| plugin.realize! }
|
125
|
+
end
|
126
|
+
|
127
|
+
def plugin_store
|
128
|
+
@plugins ||= []
|
129
|
+
end
|
130
|
+
|
114
131
|
end
|
115
132
|
end
|
@@ -1,17 +1,18 @@
|
|
1
1
|
class EC2ResponseObject
|
2
2
|
def self.get_descriptions(resp)
|
3
|
-
rs =
|
4
|
-
|
3
|
+
rs = get_instance_from_response(resp)
|
4
|
+
group = get_group_from_response(resp)
|
5
|
+
|
5
6
|
# puts rs.methods.sort - rs.ancestors.methods
|
6
7
|
out = begin
|
7
8
|
if rs.respond_to?(:instancesSet)
|
8
|
-
[EC2ResponseObject.get_hash_from_response(rs.instancesSet.item)]
|
9
|
+
[EC2ResponseObject.get_hash_from_response(rs.instancesSet.item, group)]
|
9
10
|
else
|
10
11
|
rs.collect {|r|
|
11
12
|
if r.instancesSet.item.class == Array
|
12
|
-
r.instancesSet.item.map {|t| EC2ResponseObject.get_hash_from_response(t)}
|
13
|
+
r.instancesSet.item.map {|t| EC2ResponseObject.get_hash_from_response(t, group)}
|
13
14
|
else
|
14
|
-
[EC2ResponseObject.get_hash_from_response(r.instancesSet.item)]
|
15
|
+
[EC2ResponseObject.get_hash_from_response(r.instancesSet.item, group)]
|
15
16
|
end
|
16
17
|
}.flatten.reject {|a| a.nil? }
|
17
18
|
end
|
@@ -22,7 +23,7 @@ class EC2ResponseObject
|
|
22
23
|
|
23
24
|
out
|
24
25
|
end
|
25
|
-
def self.
|
26
|
+
def self.get_instance_from_response(resp)
|
26
27
|
begin
|
27
28
|
rs = resp.reservationSet.item unless resp.reservationSet.nil?
|
28
29
|
rs ||= resp.DescribeInstancesResponse.reservationSet.item
|
@@ -33,7 +34,20 @@ class EC2ResponseObject
|
|
33
34
|
end
|
34
35
|
rs
|
35
36
|
end
|
36
|
-
def self.
|
37
|
+
def self.get_group_from_response(resp)
|
38
|
+
begin
|
39
|
+
resp = resp.reservationSet.item.first if resp.reservationSet.item.is_a?(Array)
|
40
|
+
group = resp.reservationSet.item.groupSet.item.groupId unless resp.reservationSet.nil?
|
41
|
+
group ||= resp.groupSet.item[0].groupId rescue nil
|
42
|
+
group ||= resp.DescribeInstancesResponse.reservationSet.item.groupSet.item.groupId
|
43
|
+
#rs ||= rs.respond_to?(:instancesSet) ? rs.instancesSet : rs
|
44
|
+
#rs.reject! {|a| a.nil? || a.empty? }
|
45
|
+
rescue Exception => e
|
46
|
+
resp
|
47
|
+
end
|
48
|
+
group
|
49
|
+
end
|
50
|
+
def self.get_hash_from_response(resp, group = 'default')
|
37
51
|
begin
|
38
52
|
{
|
39
53
|
:instance_id => resp.instanceId,
|
@@ -42,8 +56,8 @@ class EC2ResponseObject
|
|
42
56
|
:status => resp.instanceState.name,
|
43
57
|
:launching_time => resp.launchTime.parse_datetime,
|
44
58
|
:internal_ip => resp.privateDnsName,
|
45
|
-
:keypair => resp.keyName
|
46
|
-
|
59
|
+
:keypair => resp.keyName,
|
60
|
+
:security_group => group
|
47
61
|
}
|
48
62
|
rescue Exception => e
|
49
63
|
nil
|
@@ -24,11 +24,11 @@ begin
|
|
24
24
|
:maxCount => num,
|
25
25
|
:key_name => (keypair || Base.keypair),
|
26
26
|
:availability_zone => nil,
|
27
|
-
:
|
28
|
-
:group_id => ["#{security_group ||
|
27
|
+
:instance_type => "#{size || Base.size}",
|
28
|
+
:group_id => ["#{security_group || Base.security_group}"])
|
29
29
|
begin
|
30
30
|
h = EC2ResponseObject.get_hash_from_response(instance)
|
31
|
-
h = instance.instancesSet.item.first
|
31
|
+
#h = instance.instancesSet.item.first
|
32
32
|
rescue Exception => e
|
33
33
|
h = instance
|
34
34
|
end
|
@@ -43,11 +43,11 @@ begin
|
|
43
43
|
describe_instances.select {|a| a[:name] == id}[0] rescue nil
|
44
44
|
end
|
45
45
|
def describe_instances
|
46
|
-
|
46
|
+
id = 0
|
47
47
|
get_instances_description.each_with_index do |h,i|
|
48
48
|
if h[:status] == "running"
|
49
|
-
inst_name =
|
50
|
-
|
49
|
+
inst_name = id == 0 ? "master" : "node#{id}"
|
50
|
+
id += 1
|
51
51
|
else
|
52
52
|
inst_name = "#{h[:status]}_node#{i}"
|
53
53
|
end
|
@@ -58,7 +58,7 @@ begin
|
|
58
58
|
:index => i,
|
59
59
|
:launching_time => (h[:launching_time])
|
60
60
|
})
|
61
|
-
end.
|
61
|
+
end.sort {|a,b| a[:index] <=> b[:index] }
|
62
62
|
end
|
63
63
|
# Get the s3 description for the response in a hash format
|
64
64
|
def get_instances_description
|
@@ -70,17 +70,17 @@ module PoolParty
|
|
70
70
|
name = (i.zero? ? "master" : "node#{i}")
|
71
71
|
list.select {|i| i.name == name }.first
|
72
72
|
end
|
73
|
-
def remote_instances_list
|
74
|
-
# puts "> #{@containing_cloud.name} - #{@containing_cloud.class}"
|
73
|
+
def remote_instances_list
|
75
74
|
@containing_cloud = self
|
75
|
+
# puts "> #{@containing_cloud} #{@describe_instances.nil?}"
|
76
76
|
list_of_instances(keypair).collect {|h| PoolParty::Remote::RemoteInstance.new(h, @containing_cloud) }
|
77
77
|
end
|
78
78
|
# List the instances for the current key pair, regardless of their states
|
79
79
|
# If no keypair is passed, select them all
|
80
80
|
def list_of_instances(keyp=nil)
|
81
|
-
|
81
|
+
tmp_key = (keyp ? keyp : keypair).to_s
|
82
82
|
unless @describe_instances
|
83
|
-
tmpInstanceList = describe_instances.select {|a|
|
83
|
+
tmpInstanceList = describe_instances.select {|a| a if tmp_key ? a[:keypair] == tmp_key : true }
|
84
84
|
has_master = !tmpInstanceList.select {|a| a[:name] == "master" }.empty?
|
85
85
|
if has_master
|
86
86
|
@describe_instances = tmpInstanceList
|
@@ -111,7 +111,6 @@ module PoolParty
|
|
111
111
|
# Reset the cache of descriptions
|
112
112
|
def reset_remoter_base!
|
113
113
|
@describe_instances = nil
|
114
|
-
reset_base!
|
115
114
|
end
|
116
115
|
def self.included(other)
|
117
116
|
PoolParty.register_remote_base(self.class.to_s.downcase.to_sym)
|
data/lib/poolparty/pool/base.rb
CHANGED
@@ -27,9 +27,10 @@ module PoolParty
|
|
27
27
|
:proxy_mode => "http",
|
28
28
|
# EC2 Options
|
29
29
|
:ami => "ami-1cd73375",
|
30
|
+
:size => 'm1.small', # must be 'm1.small', 'm1.large', 'm1.xlarge', 'c1.medium', or 'c1.xlarge'
|
31
|
+
:security_group => ["default"],
|
30
32
|
# Options that should not be touched pretty much ever
|
31
|
-
:manifest_path => "/etc/puppet/manifests"
|
32
|
-
:security_group => ["default"]
|
33
|
+
:manifest_path => "/etc/puppet/manifests"
|
33
34
|
})
|
34
35
|
|
35
36
|
# Class methods
|
data/lib/poolparty/pool/cloud.rb
CHANGED
@@ -18,7 +18,7 @@ module PoolParty
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class Cloud
|
21
|
-
attr_reader :
|
21
|
+
attr_reader :templates
|
22
22
|
include PoolParty::PluginModel
|
23
23
|
include PoolParty::Resources
|
24
24
|
include PrettyPrinter
|
@@ -42,38 +42,41 @@ module PoolParty
|
|
42
42
|
:polling_time => "30.seconds"
|
43
43
|
})
|
44
44
|
|
45
|
-
def initialize(name,
|
46
|
-
@cloud_name =
|
47
|
-
|
48
|
-
|
45
|
+
def initialize(name, pare=self, &block)
|
46
|
+
@cloud_name = name
|
47
|
+
@cloud_name.freeze
|
48
|
+
|
49
49
|
plugin_directory "#{::Dir.pwd}/plugins"
|
50
|
-
|
51
|
-
p =
|
50
|
+
|
51
|
+
p = pare.is_a?(PoolParty::Pool::Pool) ? pare : nil
|
52
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
|
+
# self.run_in_context parent, &block if block
|
56
|
+
setup_defaults
|
57
|
+
reset_remoter_base!
|
58
|
+
realize_plugins!
|
56
59
|
end
|
57
60
|
|
58
61
|
def setup_defaults
|
59
62
|
# this can be overridden in the spec, but ec2 is the default
|
60
|
-
self.using :ec2
|
63
|
+
self.using :ec2
|
64
|
+
generate_keypair unless has_keypair?
|
61
65
|
end
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
# pool_name and the cloud_name
|
66
|
-
def keypair(*args)
|
67
|
-
has_keypair? ? options[:keypair] : generate_keypair(*args)
|
66
|
+
|
67
|
+
def name
|
68
|
+
@cloud_name
|
68
69
|
end
|
70
|
+
|
71
|
+
# Keypairs
|
69
72
|
# Let's just make sure that the keypair exists on the options
|
70
73
|
def has_keypair?
|
71
|
-
options.has_key?(:keypair) && options[:keypair]
|
74
|
+
options.has_key?(:keypair) && options[:keypair] && !options[:keypair].empty?
|
72
75
|
end
|
73
76
|
# Generate a keypair based on the parent's name (if there is a parent)
|
74
77
|
# and the cloud's name
|
75
78
|
def generate_keypair(*args)
|
76
|
-
options[:keypair] =
|
79
|
+
options[:keypair] = "#{parent && parent.is_a?(PoolParty::Pool::Pool) ? parent.name : "poolparty"}_#{name}" unless has_keypair?
|
77
80
|
end
|
78
81
|
|
79
82
|
# Prepare to send the new configuration to the instances
|
@@ -149,14 +152,16 @@ module PoolParty
|
|
149
152
|
classpackage_with_self(service)
|
150
153
|
end
|
151
154
|
|
155
|
+
options.merge!(:name => "user")
|
156
|
+
classpackage_with_self
|
157
|
+
# resources.each do |type, res|
|
158
|
+
# str << "# #{type.to_s.pluralize}"
|
159
|
+
# str << res.to_string
|
160
|
+
# end
|
161
|
+
|
152
162
|
global_classpackages.each do |cls|
|
153
163
|
str << cls.to_string
|
154
164
|
end
|
155
|
-
|
156
|
-
resources.each do |type, res|
|
157
|
-
str << "# #{type.to_s.pluralize}"
|
158
|
-
str << res.to_string
|
159
|
-
end
|
160
165
|
|
161
166
|
str << "# Custom functions"
|
162
167
|
str << Resources::CustomResource.custom_functions_to_string
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module PoolParty
|
2
2
|
|
3
3
|
module Plugin
|
4
|
-
|
4
|
+
|
5
5
|
class Plugin
|
6
6
|
include Configurable
|
7
7
|
include CloudResourcer
|
@@ -11,9 +11,19 @@ module PoolParty
|
|
11
11
|
|
12
12
|
default_options({})
|
13
13
|
|
14
|
-
def initialize(p=self, opts={}, &block)
|
15
|
-
|
16
|
-
|
14
|
+
def initialize(p=self, opts={}, &block)
|
15
|
+
store_block &block
|
16
|
+
run_setup(p)
|
17
|
+
realize! unless block
|
18
|
+
end
|
19
|
+
|
20
|
+
def realize!(force=false)
|
21
|
+
force ? force_realize! : (@realized ? nil : force_realize!)
|
22
|
+
end
|
23
|
+
|
24
|
+
def force_realize!
|
25
|
+
run_setup(parent, false, &stored_block)
|
26
|
+
enable unless stored_block
|
17
27
|
end
|
18
28
|
|
19
29
|
# Overwrite this method
|
@@ -27,7 +27,6 @@ module PoolParty
|
|
27
27
|
klass = class_string_name.class_constant(PoolParty::Plugin::Plugin)
|
28
28
|
mod = class_string_name.module_constant(&block)
|
29
29
|
|
30
|
-
# klass.extend PoolParty::Resources
|
31
30
|
klass.send :include, mod
|
32
31
|
|
33
32
|
# Store the name of the class for pretty printing later
|
@@ -35,7 +34,10 @@ module PoolParty
|
|
35
34
|
# Add the plugin definition to the cloud as an instance method
|
36
35
|
Cloud::Cloud.class_eval <<-EOE
|
37
36
|
def #{name}(parent=self, &block)
|
38
|
-
|
37
|
+
@pa = parent
|
38
|
+
@#{class_string_name.downcase} ||= returning #{class_string_name.class_constant}.new(parent, &block) do |pl|
|
39
|
+
@pa.plugin_store << pl
|
40
|
+
end
|
39
41
|
end
|
40
42
|
EOE
|
41
43
|
end
|
data/lib/poolparty/pool/pool.rb
CHANGED
@@ -20,7 +20,6 @@ module PoolParty
|
|
20
20
|
end
|
21
21
|
|
22
22
|
class Pool
|
23
|
-
attr_accessor :name
|
24
23
|
include PoolParty::Cloud
|
25
24
|
include MethodMissingSugar
|
26
25
|
# include PluginModel
|
@@ -37,11 +36,16 @@ module PoolParty
|
|
37
36
|
def initialize(name,&block)
|
38
37
|
setup_defaults
|
39
38
|
|
40
|
-
@
|
39
|
+
@pool_name = name
|
40
|
+
@pool_name.freeze
|
41
41
|
# run_in_context &block if block
|
42
42
|
run_setup(self, &block)
|
43
43
|
end
|
44
44
|
|
45
|
+
def name
|
46
|
+
@pool_name
|
47
|
+
end
|
48
|
+
|
45
49
|
def setup_defaults
|
46
50
|
plugin_directory "#{::Dir.pwd}/plugins"
|
47
51
|
end
|
@@ -60,7 +60,7 @@ module PoolParty
|
|
60
60
|
def custom_file(path, str)
|
61
61
|
write_to_file_in_storage_directory(path, str)
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
class Resource
|
65
65
|
attr_accessor :prestring, :poststring
|
66
66
|
|
@@ -137,6 +137,14 @@ module PoolParty
|
|
137
137
|
def loaded(opts={}, parent=self)
|
138
138
|
end
|
139
139
|
|
140
|
+
def cloud
|
141
|
+
@pa = parent
|
142
|
+
while !(@pa.is_a?(PoolParty::Cloud::Cloud) || @pa.nil? || @pa == self)
|
143
|
+
@pa = @pa.parent
|
144
|
+
end
|
145
|
+
@pa
|
146
|
+
end
|
147
|
+
|
140
148
|
# DSL Overriders
|
141
149
|
include PoolParty::ResourcingDsl
|
142
150
|
|
@@ -24,7 +24,6 @@ module PoolParty
|
|
24
24
|
def classpackage_with_self(parent=self, &block)
|
25
25
|
name = (parent.options.name || Classpackage.name(parent).to_s).sanitize
|
26
26
|
if in_global_classpackages?(name)
|
27
|
-
puts "#{name} already a class in the global storage"
|
28
27
|
returning get_from_global_classpackage_store(name) do |cls|
|
29
28
|
cls.run_in_context(parent, &block) if block
|
30
29
|
end
|
@@ -66,12 +65,21 @@ module PoolParty
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def to_string(pre="")
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
68
|
+
if resources.size > 0 && not_printed?
|
69
|
+
returning Array.new do |output|
|
70
|
+
output << "#{pre}class #{name.sanitize.downcase} {"
|
71
|
+
output << "#{pre}#{resources_string_from_resources(resources)}"
|
72
|
+
output << "#{pre}}"
|
73
|
+
output << include_string
|
74
|
+
@not_printed = false
|
75
|
+
end.join("\n")
|
76
|
+
else
|
77
|
+
""
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def not_printed?
|
82
|
+
@not_printed ||= true
|
75
83
|
end
|
76
84
|
|
77
85
|
def include_string
|
@@ -2,16 +2,16 @@ module PoolParty
|
|
2
2
|
module Resources
|
3
3
|
|
4
4
|
def execute_on_master(parent=self, &block)
|
5
|
-
execute_if("$hostname", "
|
5
|
+
execute_if("$hostname", "master", {}, parent, &block)
|
6
6
|
end
|
7
7
|
|
8
8
|
def execute_on_node(parent=self, &block)
|
9
|
-
execute_if("$hostname", "
|
9
|
+
execute_if("$hostname", "master", {:notequal => true}, parent, &block)
|
10
10
|
end
|
11
11
|
|
12
|
-
def execute_if(attr_s="$hostname",
|
12
|
+
def execute_if(attr_s="$hostname", str="", cust_opts={}, parent=self, &block)
|
13
13
|
# parent = parent.is_a?(PoolParty::Cloud::Cloud) ? parent : parent.parent
|
14
|
-
opts = {:attribute => attr_s, :equal => str
|
14
|
+
opts = {:attribute => attr_s, :equal => str}.merge(cust_opts)
|
15
15
|
options = (parent.respond_to?(:options) && parent && parent != self) ? parent.options.merge!(opts) : opts
|
16
16
|
# @c = PoolParty::Resources::Conditional.new(options, parent, &block)
|
17
17
|
# conditional(options, parent, &block)
|
@@ -21,7 +21,7 @@ module PoolParty
|
|
21
21
|
class Conditional < Resource
|
22
22
|
|
23
23
|
def initialize(opts={}, parent=self, &block)
|
24
|
-
name "#{opts[:name] ? opts[:name] : opts[:attribute]} #{opts[:
|
24
|
+
name "#{opts[:name] ? opts[:name] : opts[:attribute]} #{opts[:equal]}"
|
25
25
|
attribute opts[:attribute]
|
26
26
|
equal opts[:equal]
|
27
27
|
notequal opts.has_key?(:notequal) ? opts[:notequal] : false
|
@@ -22,12 +22,17 @@ module PoolParty
|
|
22
22
|
|
23
23
|
def self.for_save_string(in_cloud=nil)
|
24
24
|
returning Array.new do |out|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
pools.collect {|n,pl| pl}.each do |pl|
|
26
|
+
|
27
|
+
(in_cloud ? [in_cloud] : clouds.collect {|n,cl| cl }).each do |cl|
|
28
|
+
out << <<-EOE
|
29
|
+
pool :#{pl.name} do
|
30
|
+
cloud :#{cl.name} do
|
31
|
+
#{cl.minimum_runnable_options.map {|o| "#{o} #{cl.send(o).respec_string}"}.join("\n")}
|
32
|
+
end
|
29
33
|
end
|
30
|
-
|
34
|
+
EOE
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end.join("\n")
|
33
38
|
end
|
@@ -1,4 +1,9 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
3
|
. /etc/profile
|
4
|
-
/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
|
4
|
+
if [ $(/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master)]; then
|
5
|
+
echo "Run successfully"
|
6
|
+
else
|
7
|
+
ps aux | grep puppetmaster | awk '{print $2}' | xargs kill;rm -rf /etc/puppet/ssl;puppetmasterd --verbose;/etc/init.d/puppetmaster start
|
8
|
+
/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
|
9
|
+
fi
|
data/lib/poolparty/version.rb
CHANGED
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.64
|
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-11-
|
12
|
+
date: 2008-11-19 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -159,7 +159,6 @@ files:
|
|
159
159
|
- examples/basic.rb
|
160
160
|
- examples/plugin_without_plugin_directory.rb
|
161
161
|
- examples/poolparty.rb
|
162
|
-
- examples/with_apache_plugin.rb
|
163
162
|
- generators/poolspec/USAGE
|
164
163
|
- generators/poolspec/poolspec_generator.rb
|
165
164
|
- generators/poolspec/templates/pool_spec_template.erb
|
@@ -80,6 +80,13 @@ describe "Cloud" do
|
|
80
80
|
it "should be able to pull the pool from the cloud" do
|
81
81
|
@cloud.parent == @pool
|
82
82
|
end
|
83
|
+
it "should have the outer pool listed as the parent of the inner cloud" do
|
84
|
+
@pool = pool :knick_knack do
|
85
|
+
cloud :paddy_wack do
|
86
|
+
end
|
87
|
+
end
|
88
|
+
cloud(:paddy_wack).parent.should == pool(:knick_knack)
|
89
|
+
end
|
83
90
|
it "should have services in an array" do
|
84
91
|
@cloud.services.class.should == Array
|
85
92
|
end
|
@@ -289,9 +296,6 @@ describe "Cloud" do
|
|
289
296
|
|
290
297
|
File.open("test_manifest.pp", "w+") {|f| f << @manifest}
|
291
298
|
end
|
292
|
-
it "should include the hosts for all the listed local instances" do
|
293
|
-
@manifest.should =~ /master \{/
|
294
|
-
end
|
295
299
|
end
|
296
300
|
describe "building with an existing manifest" do
|
297
301
|
before(:each) do
|
@@ -24,89 +24,5 @@ describe "basic" do
|
|
24
24
|
end
|
25
25
|
it "should set the minimum_instances on the db cloud to 3" do
|
26
26
|
pool(:app).cloud(:db).minimum_instances.should == 3
|
27
|
-
end
|
28
|
-
describe "with_apache_plugin" do
|
29
|
-
before(:each) do
|
30
|
-
reset!
|
31
|
-
PoolParty::Script.inflate(open(@example_dir + "/with_apache_plugin.rb").read, File.dirname(__FILE__))
|
32
|
-
end
|
33
|
-
it "should have one pool called :app" do
|
34
|
-
pool(:app).should_not be_nil
|
35
|
-
end
|
36
|
-
it "should have a cloud called :app" do
|
37
|
-
pool(:app).cloud(:app).should_not be_nil
|
38
|
-
end
|
39
|
-
it "should have a cloud called :db" do
|
40
|
-
pool(:app).cloud(:db).should_not be_nil
|
41
|
-
end
|
42
|
-
it "should set the minimum_instances on the cloud to 2 (overriding the pool options)" do
|
43
|
-
pool(:app).cloud(:app).minimum_instances.should == 2
|
44
|
-
end
|
45
|
-
it "should set the maximum_instances on the cloud to 10" do
|
46
|
-
pool(:app).cloud(:app).maximum_instances.should == 10
|
47
|
-
end
|
48
|
-
it "should set the minimum_instances on the db cloud to 2" do
|
49
|
-
pool(:app).cloud(:db).minimum_instances.should == 2
|
50
|
-
end
|
51
|
-
it "should have included the apache plugin and given the class a method by the name of the plugin" do
|
52
|
-
pool(:app).cloud(:app).methods.include?("apache").should == true
|
53
|
-
end
|
54
|
-
describe "apache plugin" do
|
55
|
-
before(:each) do
|
56
|
-
@c = pool(:app).cloud(:app)
|
57
|
-
end
|
58
|
-
it "should have apache as the ApacheClass" do
|
59
|
-
@c.apache.class.should == PoolPartyApacheClass
|
60
|
-
end
|
61
|
-
it "should set php == true on the apache plugin" do
|
62
|
-
@c.apache.php.should == true
|
63
|
-
end
|
64
|
-
it "should store the method in options if it's not defined on the plugin" do
|
65
|
-
@c.enable_asp true
|
66
|
-
@c.options[:enable_asp].should == true
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
describe "plugin_without_plugin_directory" do
|
71
|
-
before(:each) do
|
72
|
-
reset!
|
73
|
-
PoolParty::Script.inflate(open(@example_dir + "/plugin_without_plugin_directory.rb").read, File.dirname(__FILE__))
|
74
|
-
end
|
75
|
-
it "should have one pool called :app" do
|
76
|
-
pool(:app).should_not be_nil
|
77
|
-
end
|
78
|
-
it "should have a cloud called :app" do
|
79
|
-
pool(:app).cloud(:app).should_not be_nil
|
80
|
-
end
|
81
|
-
it "should have a cloud called :db" do
|
82
|
-
pool(:app).cloud(:db).should_not be_nil
|
83
|
-
end
|
84
|
-
it "should set the minimum_instances on the cloud to 2 (overriding the pool options)" do
|
85
|
-
pool(:app).cloud(:app).minimum_instances.should == 2
|
86
|
-
end
|
87
|
-
it "should set the maximum_instances on the cloud to 10" do
|
88
|
-
pool(:app).cloud(:app).maximum_instances.should == 10
|
89
|
-
end
|
90
|
-
it "should set the minimum_instances on the db cloud to 2" do
|
91
|
-
pool(:app).cloud(:db).minimum_instances.should == 2
|
92
|
-
end
|
93
|
-
it "should have included the apache plugin and given the class a method by the name of the plugin" do
|
94
|
-
pool(:app).cloud(:app).methods.include?("apache").should == true
|
95
|
-
end
|
96
|
-
describe "apache plugin" do
|
97
|
-
before(:each) do
|
98
|
-
@c = pool(:app).cloud(:app)
|
99
|
-
end
|
100
|
-
it "should have apache as the ApacheClass" do
|
101
|
-
@c.apache.class.should == PoolPartyApacheClass
|
102
|
-
end
|
103
|
-
it "should set php == true on the apache plugin" do
|
104
|
-
@c.apache.php.should == true
|
105
|
-
end
|
106
|
-
it "should store the method in options if it's not defined on the plugin" do
|
107
|
-
@c.enable_asp true
|
108
|
-
@c.options[:enable_asp].should == true
|
109
|
-
end
|
110
|
-
end
|
111
27
|
end
|
112
28
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/test_plugins/webserver'
|
3
2
|
|
4
3
|
include PoolParty::Resources
|
4
|
+
require File.dirname(__FILE__) + '/test_plugins/webserver'
|
5
5
|
|
6
6
|
describe "Plugin" do
|
7
7
|
before(:each) do
|
@@ -93,6 +93,19 @@ describe "Plugin" do
|
|
93
93
|
it "should get a hold of the containing cloud" do
|
94
94
|
@plugin.cloud.should == @c
|
95
95
|
end
|
96
|
+
describe "enable" do
|
97
|
+
before(:each) do
|
98
|
+
reset!
|
99
|
+
@plugin = PoolParty::Plugin::Plugin.new
|
100
|
+
Kernel::PoolPartyApacheClass.stub!(:new).and_return @plugin
|
101
|
+
end
|
102
|
+
it "should call enable on calling realize! when there is no block included" do
|
103
|
+
@plugin.should_receive(:enable).and_return true
|
104
|
+
@cloud = cloud :app do
|
105
|
+
apache
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
96
109
|
end
|
97
110
|
end
|
98
111
|
end
|
@@ -363,6 +363,21 @@ describe "Resource" do
|
|
363
363
|
end
|
364
364
|
end
|
365
365
|
end
|
366
|
+
describe "same_resources_of" do
|
367
|
+
it "should say that two resources are the same" do
|
368
|
+
has_file(:name => "tanks")
|
369
|
+
has_file(:name => "tanks").same_resources_of(:file, "tanks").should == true
|
370
|
+
end
|
371
|
+
it "should say that two resources are the same regardless of their context" do
|
372
|
+
@cloud2.instance_eval do
|
373
|
+
has_file(:name => "mighty_mighty_bosstones")
|
374
|
+
end
|
375
|
+
@cloud2.resource(:file).first.same_resources_of(:file, "mighty_mighty_bosstones").should == true
|
376
|
+
end
|
377
|
+
it "should say that two resources are not the same if they are not the same" do
|
378
|
+
has_file(:name => "trees").same_resources_of(:file, "timber").should == false
|
379
|
+
end
|
380
|
+
end
|
366
381
|
it "should grab the resource when called in in a block"# do
|
367
382
|
# @cloud2.resources_string_from_resources(@cloud2.resources).should =~ /\[ Package\['apache2'\], Package\['boxers'\] \]/
|
368
383
|
# end
|
@@ -9,17 +9,17 @@ describe "Conditional" do
|
|
9
9
|
describe "wrapped" do
|
10
10
|
before(:each) do
|
11
11
|
@cloud = cloud :conditional_cloud_spec do
|
12
|
-
execute_if("$hostname",
|
12
|
+
execute_if("$hostname","'master'", {}, self) do
|
13
13
|
has_file({:name => "/etc/apache2/puppetmaster2.conf"})
|
14
14
|
end
|
15
15
|
end
|
16
|
-
@cond = @cloud.get_resource(:conditional, "$hostname
|
16
|
+
@cond = @cloud.get_resource(:conditional, "$hostname 'master'")
|
17
17
|
end
|
18
18
|
it "should add the block of resources on the parent" do
|
19
19
|
@cloud.resources.size.should == 1
|
20
20
|
end
|
21
21
|
it "should have a conditional in the resources" do
|
22
|
-
@cond.name.should == "$hostname
|
22
|
+
@cond.name.should == "$hostname 'master'"
|
23
23
|
end
|
24
24
|
it "should push the resources onto the conditional resource" do
|
25
25
|
@cond.resources.size.should == 1
|
@@ -34,12 +34,12 @@ describe "Conditional" do
|
|
34
34
|
it "should have execute_on_master with the string $hostname == 'master'" do
|
35
35
|
str = execute_on_master do
|
36
36
|
has_file(:name => "/etc/vars")
|
37
|
-
end.to_string.should =~ /\$
|
37
|
+
end.to_string.should =~ /\$hostnamemaster/
|
38
38
|
end
|
39
39
|
it "should have execute_on_node with the string $hostname != 'master'" do
|
40
40
|
str = execute_on_node do
|
41
41
|
has_file(:name => "/etc/vars")
|
42
|
-
end.to_string.should =~ /\$
|
42
|
+
end.to_string.should =~ /\$hostnamemaster/
|
43
43
|
end
|
44
44
|
end
|
45
45
|
describe "to_string" do
|
@@ -65,6 +65,13 @@ describe "Conditional" do
|
|
65
65
|
@cloud.resource(:conditional).size.should == 2
|
66
66
|
end
|
67
67
|
end
|
68
|
+
describe "execute on node" do
|
69
|
+
it "should place the node in the default section" do
|
70
|
+
str = execute_on_node do
|
71
|
+
has_file(:name => "/etc/vars")
|
72
|
+
end.to_string.should =~ /default : \{/
|
73
|
+
end
|
74
|
+
end
|
68
75
|
end
|
69
76
|
end
|
70
77
|
end
|
@@ -49,7 +49,6 @@ describe "Script" do
|
|
49
49
|
ami "ami-123456"
|
50
50
|
|
51
51
|
cloud :app do
|
52
|
-
security_group "app"
|
53
52
|
expand_when "cpu > 90", "memory > 80"
|
54
53
|
contract_when "cpu < 10", "memory < 10"
|
55
54
|
|
@@ -64,9 +63,6 @@ describe "Script" do
|
|
64
63
|
it "should save the ami" do
|
65
64
|
@saved.should =~ /ami 'ami-123456'/
|
66
65
|
end
|
67
|
-
it "should save the security group" do
|
68
|
-
@saved.should =~ /security_group 'app'/
|
69
|
-
end
|
70
66
|
it "should save the expansions" do
|
71
67
|
@saved.should =~ /expand_when 'cpu>90', 'memory>80'/
|
72
68
|
end
|
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.64
|
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-11-
|
12
|
+
date: 2008-11-19 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -159,7 +159,6 @@ files:
|
|
159
159
|
- examples/basic.rb
|
160
160
|
- examples/plugin_without_plugin_directory.rb
|
161
161
|
- examples/poolparty.rb
|
162
|
-
- examples/with_apache_plugin.rb
|
163
162
|
- generators/poolspec/USAGE
|
164
163
|
- generators/poolspec/poolspec_generator.rb
|
165
164
|
- generators/poolspec/templates/pool_spec_template.erb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
pool :app do
|
4
|
-
|
5
|
-
plugin_directory File.join(File.dirname(__FILE__), "pool", "test_plugins")
|
6
|
-
instances 2..10
|
7
|
-
|
8
|
-
cloud :app do
|
9
|
-
# minimum 2 instances
|
10
|
-
# maximum 10 instances
|
11
|
-
apache do
|
12
|
-
enable_php
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
cloud :db do
|
17
|
-
# minimum 2 instances
|
18
|
-
# maximum 10 instances
|
19
|
-
mysql # default mysql setup
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|