auser-poolparty 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +201 -0
- data/PostInstall.txt +17 -0
- data/Rakefile +22 -1
- data/bin/cloud-add-keypair +0 -0
- data/bin/cloud-osxcopy +22 -0
- data/bin/cloud-provision +1 -0
- data/bin/cloud-start +17 -15
- data/bin/cloud-terminate +23 -0
- data/bin/pool-start +14 -14
- data/bin/pool-start-monitor +1 -0
- data/config/hoe.rb +114 -0
- data/config/requirements.rb +15 -0
- data/lib/poolparty.rb +1 -0
- data/lib/poolparty/base_packages/haproxy.rb +32 -31
- data/lib/poolparty/base_packages/heartbeat.rb +2 -2
- data/lib/poolparty/base_packages/poolparty.rb +9 -3
- data/lib/poolparty/base_packages/ruby.rb +10 -0
- data/lib/poolparty/core/proc.rb +5 -0
- data/lib/poolparty/core/string.rb +1 -1
- data/lib/poolparty/helpers/binary.rb +6 -5
- data/lib/poolparty/helpers/display.rb +11 -2
- data/lib/poolparty/helpers/optioner.rb +6 -3
- data/lib/poolparty/helpers/provisioner_base.rb +9 -7
- data/lib/poolparty/helpers/provisioners/master.rb +38 -4
- data/lib/poolparty/helpers/provisioners/slave.rb +2 -2
- data/lib/poolparty/modules/cloud_resourcer.rb +20 -3
- data/lib/poolparty/modules/definable_resource.rb +1 -1
- data/lib/poolparty/modules/method_missing_sugar.rb +12 -4
- data/lib/poolparty/modules/pretty_printer.rb +2 -1
- data/lib/poolparty/net/remote.rb +1 -1
- data/lib/poolparty/net/remote_bases/ec2.rb +13 -10
- data/lib/poolparty/net/remote_instance.rb +3 -2
- data/lib/poolparty/net/remoter.rb +33 -18
- data/lib/poolparty/net/remoter_base.rb +3 -3
- data/lib/poolparty/plugins/gem_package.rb +6 -29
- data/lib/poolparty/plugins/git.rb +22 -0
- data/lib/poolparty/pool/base.rb +7 -6
- data/lib/poolparty/pool/cloud.rb +34 -5
- data/lib/poolparty/pool/custom_resource.rb +4 -4
- data/lib/poolparty/pool/plugin.rb +13 -14
- data/lib/poolparty/pool/resource.rb +19 -10
- data/lib/poolparty/pool/resources/class_package.rb +10 -6
- data/lib/poolparty/pool/resources/conditional.rb +41 -0
- data/lib/poolparty/pool/resources/gem.rb +2 -2
- data/lib/poolparty/pool/script.rb +25 -2
- data/lib/poolparty/templates/haproxy.conf +1 -1
- data/lib/poolparty/templates/puppet.conf +4 -2
- data/lib/poolparty/version.rb +1 -1
- data/poolparty.gemspec +60 -0
- data/setup.rb +1585 -0
- data/spec/poolparty/base_packages/haproxy_spec.rb +13 -0
- data/spec/poolparty/base_packages/heartbeat_spec.rb +30 -0
- data/spec/poolparty/bin/console_spec.rb +80 -0
- data/spec/poolparty/core/array_spec.rb +26 -0
- data/spec/poolparty/core/float.rb +13 -0
- data/spec/poolparty/core/hash_spec.rb +63 -0
- data/spec/poolparty/core/kernel_spec.rb +24 -0
- data/spec/poolparty/core/module_spec.rb +15 -0
- data/spec/poolparty/core/object_spec.rb +40 -0
- data/spec/poolparty/core/string_spec.rb +152 -0
- data/spec/poolparty/core/time_spec.rb +52 -0
- data/spec/poolparty/helpers/binary_spec.rb +26 -0
- data/spec/poolparty/helpers/display_spec.rb +13 -0
- data/spec/poolparty/helpers/optioner_spec.rb +39 -0
- data/spec/poolparty/helpers/provisioner_base_spec.rb +121 -0
- data/spec/poolparty/helpers/provisioners/master_spec.rb +54 -0
- data/spec/poolparty/helpers/provisioners/slave_spec.rb +28 -0
- data/spec/poolparty/modules/cloud_resourcer_spec.rb +135 -0
- data/spec/poolparty/modules/configurable_spec.rb +26 -0
- data/spec/poolparty/modules/definable_resource.rb +9 -0
- data/spec/poolparty/modules/file_writer_spec.rb +49 -0
- data/spec/poolparty/modules/s3_string_spec.rb +15 -0
- data/spec/poolparty/net/remote_bases/ec2_spec.rb +92 -0
- data/spec/poolparty/net/remote_instance_spec.rb +70 -0
- data/spec/poolparty/net/remote_spec.rb +286 -0
- data/spec/poolparty/net/remoter_base_spec.rb +80 -0
- data/spec/poolparty/net/remoter_spec.rb +191 -0
- data/spec/poolparty/plugins/git_spec.rb +19 -0
- data/spec/poolparty/plugins/line_spec.rb +16 -0
- data/spec/poolparty/plugins/svn_spec.rb +16 -0
- data/spec/poolparty/pool/base_spec.rb +108 -0
- data/spec/poolparty/pool/cloud_spec.rb +299 -0
- data/spec/poolparty/pool/configurers/files/ruby_basic.rb +17 -0
- data/spec/poolparty/pool/configurers/files/ruby_plugins.rb +16 -0
- data/spec/poolparty/pool/configurers/ruby_spec.rb +58 -0
- data/spec/poolparty/pool/custom_resource_spec.rb +115 -0
- data/spec/poolparty/pool/example_spec.rb +112 -0
- data/spec/poolparty/pool/plugin_model_spec.rb +63 -0
- data/spec/poolparty/pool/plugin_spec.rb +85 -0
- data/spec/poolparty/pool/pool_spec.rb +83 -0
- data/spec/poolparty/pool/resource_spec.rb +224 -0
- data/spec/poolparty/pool/resources/class_package_spec.rb +84 -0
- data/spec/poolparty/pool/resources/conditional_spec.rb +38 -0
- data/spec/poolparty/pool/resources/cron_spec.rb +49 -0
- data/spec/poolparty/pool/resources/directory_spec.rb +40 -0
- data/spec/poolparty/pool/resources/exec_spec.rb +37 -0
- data/spec/poolparty/pool/resources/file_spec.rb +40 -0
- data/spec/poolparty/pool/resources/gem_spec.rb +16 -0
- data/spec/poolparty/pool/resources/host_spec.rb +28 -0
- data/spec/poolparty/pool/resources/package_spec.rb +44 -0
- data/spec/poolparty/pool/resources/remote_file_spec.rb +40 -0
- data/spec/poolparty/pool/resources/service_spec.rb +45 -0
- data/spec/poolparty/pool/resources/sshkey_spec.rb +48 -0
- data/spec/poolparty/pool/resources/variable_spec.rb +20 -0
- data/spec/poolparty/pool/script_spec.rb +51 -0
- data/spec/poolparty/pool/test_plugins/sshkey_test +2 -0
- data/spec/poolparty/pool/test_plugins/virtual_host_template.erb +0 -0
- data/spec/poolparty/pool/test_plugins/webserver.rb +46 -0
- data/spec/poolparty/poolparty_spec.rb +33 -0
- data/spec/poolparty/spec_helper.rb +120 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +2 -0
- data/test/test_pool_spec_generator.rb +47 -0
- data/test/test_poolparty.rb +11 -0
- data/website/index.html +81 -0
- data/website/index.txt +72 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +178 -60
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
data/lib/poolparty.rb
CHANGED
@@ -3,39 +3,40 @@ module PoolParty
|
|
3
3
|
plugin :haproxy do
|
4
4
|
|
5
5
|
def enable
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
execute_if("$hostname", "master") do
|
7
|
+
package({:name => "haproxy"})
|
8
|
+
|
9
|
+
# Startup haproxy and enable it
|
10
|
+
has_line_in_file("ENABLED=1", "/etc/default/haproxy")
|
11
|
+
has_line_in_file("SYSLOGD=\"-r\"", "/etc/default/syslogd")
|
12
|
+
has_line_in_file("local0.* /var/log/haproxy.log", "/etc/syslog.conf", {:notify => 'Service["sysklogd"]'})
|
13
|
+
|
14
|
+
# Restart sysklogd after we update the haproxy.log
|
15
|
+
has_service(:name => "sysklogd") do
|
16
|
+
ensures "running"
|
17
|
+
end
|
18
|
+
|
19
|
+
# Service is required
|
20
|
+
has_service(:name => "haproxy")
|
21
|
+
|
22
|
+
# Tempalte variables
|
23
|
+
variable(:name => "name", :value => "#{@parent.name}")
|
24
|
+
variable(:name => "nodenames", :value => list_of_node_names)
|
25
|
+
variable(:name => "node_ips", :value => list_of_node_ips)
|
26
|
+
variable(:name => "ports", :value => ([(self.respond_to?(:port) ? port : Base.port)].flatten))
|
27
|
+
variable(:name => "forwarding_port", :value => (respond_to?(:forwarding_port) ? forwarding_port : Base.forwarding_port))
|
28
|
+
variable(:name => "proxy_mode", :value => (respond_to?(:proxy_mode) ? proxy_mode : Base.proxy_mode))
|
29
|
+
|
30
|
+
# These can also be passed in via hash
|
31
|
+
has_remotefile(:name => "/etc/haproxy.cfg") do
|
32
|
+
mode 644
|
33
|
+
# onlyif '$hostname == "master"'
|
34
|
+
requires 'Package["haproxy"]'
|
35
|
+
notify 'Service["haproxy"]'
|
36
|
+
template File.join(File.dirname(__FILE__), "..", "templates/haproxy.conf")
|
37
|
+
end
|
16
38
|
end
|
17
|
-
|
18
|
-
# Service is required
|
19
|
-
has_service(:name => "#{name}")
|
20
|
-
|
21
|
-
# Tempalte variables
|
22
|
-
variable(:name => "name", :value => "#{name}")
|
23
|
-
variable(:name => "nodenames", :value => list_of_node_names)
|
24
|
-
variable(:name => "node_ips", :value => list_of_node_ips)
|
25
|
-
variable(:name => "ports", :value => ([port].flatten || [Base.port].flatten))
|
26
|
-
variable(:name => "forwarding_port", :value => (forwarding_port || Base.forwarding_port))
|
27
|
-
variable(:name => "proxy_mode", :value => (proxy_mode || Base.proxy_mode))
|
28
|
-
|
29
|
-
# These can also be passed in via hash
|
30
|
-
has_remotefile(:name => "/etc/haproxy.cfg") do
|
31
|
-
mode 644
|
32
|
-
requires 'Package["haproxy"]'
|
33
|
-
notify 'Service["haproxy"]'
|
34
|
-
template File.join(File.dirname(__FILE__), "..", "templates/haproxy.conf")
|
35
|
-
end
|
36
|
-
|
37
39
|
end
|
38
|
-
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
@@ -2,7 +2,7 @@ module PoolParty
|
|
2
2
|
class Base
|
3
3
|
plugin :heartbeat do
|
4
4
|
|
5
|
-
def enable
|
5
|
+
def enable
|
6
6
|
has_package(:name => "heartbeat-2", :ensure => "installed")
|
7
7
|
has_service(:name => "heartbeat", :hasstatus => true) do
|
8
8
|
ensures "running"
|
@@ -13,7 +13,7 @@ module PoolParty
|
|
13
13
|
# variables for the templates
|
14
14
|
has_variable({:name => "nodenames", :value => list_of_node_names})
|
15
15
|
has_variable({:name => "node_ips", :value => list_of_node_ips})
|
16
|
-
has_variable({:name => "port", :value => (port
|
16
|
+
has_variable({:name => "port", :value => (self.respond_to?(:port) ? port : Base.port)})
|
17
17
|
|
18
18
|
# These can also be passed in via hash
|
19
19
|
has_remotefile(:name => "/etc/ha.d/ha.cf") do
|
@@ -2,13 +2,19 @@ module PoolParty
|
|
2
2
|
class Base
|
3
3
|
plugin :poolparty do
|
4
4
|
|
5
|
-
def enable
|
5
|
+
def enable
|
6
6
|
has_package(:name => "erlang")
|
7
|
-
|
7
|
+
# These should be installed automagically by poolparty, but just in case
|
8
|
+
has_gempackage(:name => "open4")
|
9
|
+
has_gempackage(:name => "activesupport")
|
10
|
+
has_gempackage(:name => "logging")
|
11
|
+
|
12
|
+
has_gempackage(:name => "grempe-amazon-ec2", :source => "http://gems.github.com")
|
13
|
+
has_gempackage(:name => "auser-poolparty", :source => "http://gems.github.com")
|
8
14
|
|
9
15
|
# Build hostsfile
|
10
16
|
# TODO: COME BACK AND CLEAN THIS UP
|
11
|
-
(self.respond_to?(:
|
17
|
+
(self.respond_to?(:list_of_running_instances) ? self : parent).list_of_running_instances.each do |ri|
|
12
18
|
has_host({:name => "#{ri.name}", :ip => ri.ip })
|
13
19
|
end
|
14
20
|
end
|
@@ -8,6 +8,16 @@ module PoolParty
|
|
8
8
|
has_package(:name => "ruby1.8-dev")
|
9
9
|
has_package(:name => "ruby1.8")
|
10
10
|
has_package(:name => "rubygems")
|
11
|
+
|
12
|
+
# exec(:name => "update-rubygems") do
|
13
|
+
# command "gem update --system"
|
14
|
+
# ifnot "gem -v | grep 1."
|
15
|
+
# notify "Exec[fix-updated-rubygems]"
|
16
|
+
# end
|
17
|
+
# exec(:name => "fix-updated-rubygems") do
|
18
|
+
# command "awk \'{print} NR == 9 {print \"require \"rubygems/gem_runner\"\"}\' /usr/bin/gem"
|
19
|
+
# ifnot "awk \'/gem_runner/\' /usr/bin/gem"
|
20
|
+
# end
|
11
21
|
end
|
12
22
|
|
13
23
|
def enable_ri
|
data/lib/poolparty/core/proc.rb
CHANGED
@@ -39,7 +39,7 @@ class String
|
|
39
39
|
# although, it doesn't really matter as ruby will just reopen the class
|
40
40
|
def class_constant(superclass=nil, opts={}, &block)
|
41
41
|
symc = ((opts && opts[:preserve]) ? ("#{self.classify}Classs") : "PoolParty#{self.classify}Classs").classify
|
42
|
-
|
42
|
+
|
43
43
|
kla=<<-EOE
|
44
44
|
class #{symc} #{"< #{superclass}" if superclass}
|
45
45
|
end
|
@@ -14,11 +14,12 @@ module PoolParty
|
|
14
14
|
"#{::File.dirname(__FILE__)}/../../../bin"
|
15
15
|
end
|
16
16
|
def get_existing_spec_location
|
17
|
-
[
|
18
|
-
"
|
19
|
-
"#{Base.
|
20
|
-
"
|
21
|
-
|
17
|
+
[
|
18
|
+
"#{Base.base_config_directory}/#{Base.default_specfile_name}",
|
19
|
+
"#{Base.remote_storage_path}/#{Base.default_specfile_name}",
|
20
|
+
ENV["POOL_SPEC"],
|
21
|
+
"#{Base.default_specfile_name}",
|
22
|
+
"#{Base.storage_directory}/#{Base.default_specfile_name}",
|
22
23
|
].reject {|a| a.nil?}.reject do |f|
|
23
24
|
f unless ::File.file?(f)
|
24
25
|
end.first
|
@@ -2,9 +2,18 @@ module PoolParty
|
|
2
2
|
module Display
|
3
3
|
|
4
4
|
def pool_describe(options={})
|
5
|
-
pools.
|
6
|
-
|
5
|
+
if pools.size > 0
|
6
|
+
pools.each do |k,v|
|
7
|
+
print v.pretty_print
|
8
|
+
end
|
9
|
+
else
|
10
|
+
prev = "\t"
|
11
|
+
clouds.each do |name, cl|
|
12
|
+
puts cl.pretty_name(prev*2, cl)
|
13
|
+
puts cl.pretty_options(prev*2, cl) #cl.pretty_print("#{prev}\t")
|
14
|
+
end
|
7
15
|
end
|
16
|
+
|
8
17
|
puts ""
|
9
18
|
pools.size
|
10
19
|
end
|
@@ -6,9 +6,8 @@ require 'date'
|
|
6
6
|
module PoolParty
|
7
7
|
class Optioner
|
8
8
|
include Configurable
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
include MethodMissingSugar
|
10
|
+
|
12
11
|
def initialize(args=[], opts={}, &block)
|
13
12
|
@arguments = args
|
14
13
|
@parse_options = opts[:parse_options] ? opts[:parse_options] : true
|
@@ -18,6 +17,10 @@ module PoolParty
|
|
18
17
|
self
|
19
18
|
end
|
20
19
|
|
20
|
+
def parent
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
21
24
|
def set_default_options
|
22
25
|
@options = {}
|
23
26
|
@options[:verbose] = false
|
@@ -46,7 +46,7 @@ module PoolParty
|
|
46
46
|
@cloud = cloud
|
47
47
|
|
48
48
|
options(cloud.options) if cloud && cloud.respond_to?(:options)
|
49
|
-
set_vars_from_options(instance.options) unless instance.options.empty?
|
49
|
+
set_vars_from_options(instance.options) unless instance.nil? || instance.options.empty?
|
50
50
|
options(instance.options) if instance.respond_to?(:options)
|
51
51
|
|
52
52
|
@os = os.to_s.downcase.to_sym
|
@@ -61,6 +61,7 @@ module PoolParty
|
|
61
61
|
end
|
62
62
|
def write_install_file
|
63
63
|
error unless valid?
|
64
|
+
::FileUtils.mkdir_p Base.storage_directory unless ::File.exists?(Base.storage_directory)
|
64
65
|
provisioner_file = ::File.join(Base.storage_directory, "install_#{name}.sh")
|
65
66
|
::File.open(provisioner_file, "w+") {|f| f << install }
|
66
67
|
end
|
@@ -134,8 +135,7 @@ module PoolParty
|
|
134
135
|
# These are run on all the provisioners, master or slave
|
135
136
|
def default_install_tasks
|
136
137
|
[
|
137
|
-
|
138
|
-
"export AWS_SECRET_ACCESS_ID=#{@cloud.secret_access_key}"
|
138
|
+
|
139
139
|
] << install_tasks
|
140
140
|
end
|
141
141
|
# Tasks with default configuration tasks
|
@@ -165,8 +165,8 @@ module PoolParty
|
|
165
165
|
end
|
166
166
|
|
167
167
|
# Get the packages associated with each os
|
168
|
-
def
|
169
|
-
case os
|
168
|
+
def puppet_packages
|
169
|
+
case @os
|
170
170
|
when :fedora
|
171
171
|
"puppet-server puppet factor"
|
172
172
|
else
|
@@ -182,9 +182,11 @@ module PoolParty
|
|
182
182
|
}
|
183
183
|
end
|
184
184
|
# Convenience method to grab the installer
|
185
|
-
def installer_for(
|
186
|
-
|
185
|
+
def installer_for(names=[])
|
186
|
+
packages = names.is_a?(Array) ? names.join(" ") : names
|
187
|
+
"#{self.class.installers[@os]} #{packages}"
|
187
188
|
end
|
189
|
+
|
188
190
|
# Install from the class-level
|
189
191
|
def self.install(instance, cl=self)
|
190
192
|
new(instance, cl).install
|
@@ -16,7 +16,10 @@ module PoolParty
|
|
16
16
|
|
17
17
|
def install_tasks
|
18
18
|
[
|
19
|
+
upgrade_system,
|
19
20
|
install_puppet_master,
|
21
|
+
install_haproxy,
|
22
|
+
install_heartbeat,
|
20
23
|
create_local_hosts_entry,
|
21
24
|
setup_basic_structure,
|
22
25
|
setup_configs,
|
@@ -34,9 +37,30 @@ module PoolParty
|
|
34
37
|
restart_puppetd
|
35
38
|
]
|
36
39
|
end
|
40
|
+
|
41
|
+
def upgrade_system
|
42
|
+
case @os
|
43
|
+
when :ubuntu
|
44
|
+
"
|
45
|
+
touch /etc/apt/sources.list
|
46
|
+
echo 'deb http://mirrors.kernel.org/ubuntu hardy main universe' >> /etc/apt/sources.list
|
47
|
+
apt-get update --fix-missing -y
|
48
|
+
apt-get upgrade -y"
|
49
|
+
else
|
50
|
+
"# No system upgrade needed"
|
51
|
+
end
|
52
|
+
end
|
37
53
|
|
38
54
|
def install_puppet_master
|
39
|
-
"#{installer_for(
|
55
|
+
"#{installer_for( puppet_packages )}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def install_haproxy
|
59
|
+
"#{installer_for( "haproxy" )}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def install_heartbeat
|
63
|
+
"#{installer_for( "heartbeat-2" )}"
|
40
64
|
end
|
41
65
|
|
42
66
|
def create_local_hosts_entry
|
@@ -105,15 +129,25 @@ mv #{Base.remote_storage_path}/#{Base.template_directory}/* #{Base.template_path
|
|
105
129
|
def create_poolparty_manifest
|
106
130
|
<<-EOS
|
107
131
|
mv #{Base.remote_storage_path}/#{Base.tmp_path}/poolparty.pp /etc/puppet/manifests/classes/poolparty.pp
|
132
|
+
mv #{Base.remote_storage_path}/#{Base.tmp_path}/#{Base.key_file_locations.first} "#{Base.base_config_directory}/.ppkeys"
|
133
|
+
mv #{Base.remote_storage_path}/#{Base.tmp_path}/#{Base.default_specfile_name} #{Base.base_config_directory}/#{Base.default_specfile_name}
|
134
|
+
mv #{Base.remote_storage_path}/#{Base.tmp_path}/#{@cloud.full_keypair_name} #{@cloud.remote_keypair_path}
|
108
135
|
EOS
|
109
136
|
end
|
110
137
|
|
111
138
|
def start_puppetmaster
|
112
|
-
|
139
|
+
<<-EOS
|
140
|
+
ps aux | grep puppetmasterd | awk '{print $2}' | xargs kill
|
141
|
+
rm -rf /etc/puppet/ssl
|
142
|
+
puppetmasterd
|
143
|
+
EOS
|
113
144
|
end
|
114
145
|
|
115
|
-
def restart_puppetd
|
116
|
-
|
146
|
+
def restart_puppetd
|
147
|
+
<<-EOS
|
148
|
+
puppetd --test
|
149
|
+
puppetd --listen
|
150
|
+
EOS
|
117
151
|
end
|
118
152
|
end
|
119
153
|
end
|
@@ -18,8 +18,8 @@ module PoolParty
|
|
18
18
|
|
19
19
|
def install_puppet
|
20
20
|
<<-EOE
|
21
|
-
#{installer_for(
|
22
|
-
echo 'DAEMON_OPTS="-w 120
|
21
|
+
#{installer_for( puppet_packages )}
|
22
|
+
echo 'DAEMON_OPTS="-w 120 --server puppet"' > /etc/default/puppet
|
23
23
|
EOE
|
24
24
|
end
|
25
25
|
|
@@ -3,6 +3,10 @@ require "ftools"
|
|
3
3
|
module PoolParty
|
4
4
|
module CloudResourcer
|
5
5
|
|
6
|
+
# Store block
|
7
|
+
def store_block(&block)
|
8
|
+
@store_block ||= block
|
9
|
+
end
|
6
10
|
# Set instances with a range
|
7
11
|
def instances(arg)
|
8
12
|
if arg.is_a?(Range)
|
@@ -29,6 +33,19 @@ module PoolParty
|
|
29
33
|
return nil
|
30
34
|
end
|
31
35
|
|
36
|
+
def full_keypair_name
|
37
|
+
keypair_paths.each do |path|
|
38
|
+
possible_keypair_basenames.each do |base|
|
39
|
+
full_path = ::File.join( File.expand_path(path), "#{base}#{keypair}")
|
40
|
+
return "#{base}#{keypair}" if ::File.exists?(full_path)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
return nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def remote_keypair_path
|
47
|
+
::File.join( keypair_paths.last, "#{possible_keypair_basenames.first}#{keypair}" )
|
48
|
+
end
|
32
49
|
def new_keypair_path
|
33
50
|
::File.join( keypair_paths.first, "#{possible_keypair_basenames.first}#{keypair}" )
|
34
51
|
end
|
@@ -49,12 +66,12 @@ module PoolParty
|
|
49
66
|
end
|
50
67
|
|
51
68
|
# Set the parent on the resource
|
52
|
-
def set_parent(pare)
|
53
|
-
@parent = pare
|
69
|
+
def set_parent(pare, sink_options=true)
|
70
|
+
@parent = pare
|
54
71
|
# Add self as a service on the parent
|
55
72
|
pare.add_service(self) if pare.respond_to?(:add_service)
|
56
73
|
# Take the options of the parents
|
57
|
-
configure(pare.options) if pare.respond_to?(:options)
|
74
|
+
configure(pare.options) if pare.respond_to?(:options) && sink_options
|
58
75
|
end
|
59
76
|
|
60
77
|
def number_of_resources
|
@@ -42,7 +42,7 @@ module PoolParty
|
|
42
42
|
#
|
43
43
|
# Which sets the virtual host's name as xnot.org
|
44
44
|
#
|
45
|
-
#
|
45
|
+
# An example is included in the poolparty-apache-plugin
|
46
46
|
def virtual_resource(name=:virtual_resource, opts={}, &block)
|
47
47
|
symc = "#{name}".classify
|
48
48
|
eval <<-EOE
|
@@ -4,13 +4,21 @@ module PoolParty
|
|
4
4
|
def method_missing(m, *args, &block)
|
5
5
|
if block_given?
|
6
6
|
(args[0].class == self.class) ? args[0].instance_eval(&block) : super
|
7
|
-
else
|
8
|
-
get_from_options(m, *args)
|
7
|
+
else
|
8
|
+
get_from_options(m, *args, &block)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def get_from_options(m, *args)
|
13
|
-
args.empty?
|
12
|
+
def get_from_options(m, *args, &block)
|
13
|
+
if args.empty?
|
14
|
+
if options.has_key?(m)
|
15
|
+
options[m]
|
16
|
+
else
|
17
|
+
(parent.nil? || parent.class == self.class || !parent.respond_to?(:options) || parent.options.has_key?(m)) ? nil : parent.send(m, *args, &block)
|
18
|
+
end
|
19
|
+
else
|
20
|
+
options[m] = (args.is_a?(Array) && args.size > 1) ? args : args[0]
|
21
|
+
end
|
14
22
|
end
|
15
23
|
|
16
24
|
end
|