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.
Files changed (120) hide show
  1. data/Manifest.txt +201 -0
  2. data/PostInstall.txt +17 -0
  3. data/Rakefile +22 -1
  4. data/bin/cloud-add-keypair +0 -0
  5. data/bin/cloud-osxcopy +22 -0
  6. data/bin/cloud-provision +1 -0
  7. data/bin/cloud-start +17 -15
  8. data/bin/cloud-terminate +23 -0
  9. data/bin/pool-start +14 -14
  10. data/bin/pool-start-monitor +1 -0
  11. data/config/hoe.rb +114 -0
  12. data/config/requirements.rb +15 -0
  13. data/lib/poolparty.rb +1 -0
  14. data/lib/poolparty/base_packages/haproxy.rb +32 -31
  15. data/lib/poolparty/base_packages/heartbeat.rb +2 -2
  16. data/lib/poolparty/base_packages/poolparty.rb +9 -3
  17. data/lib/poolparty/base_packages/ruby.rb +10 -0
  18. data/lib/poolparty/core/proc.rb +5 -0
  19. data/lib/poolparty/core/string.rb +1 -1
  20. data/lib/poolparty/helpers/binary.rb +6 -5
  21. data/lib/poolparty/helpers/display.rb +11 -2
  22. data/lib/poolparty/helpers/optioner.rb +6 -3
  23. data/lib/poolparty/helpers/provisioner_base.rb +9 -7
  24. data/lib/poolparty/helpers/provisioners/master.rb +38 -4
  25. data/lib/poolparty/helpers/provisioners/slave.rb +2 -2
  26. data/lib/poolparty/modules/cloud_resourcer.rb +20 -3
  27. data/lib/poolparty/modules/definable_resource.rb +1 -1
  28. data/lib/poolparty/modules/method_missing_sugar.rb +12 -4
  29. data/lib/poolparty/modules/pretty_printer.rb +2 -1
  30. data/lib/poolparty/net/remote.rb +1 -1
  31. data/lib/poolparty/net/remote_bases/ec2.rb +13 -10
  32. data/lib/poolparty/net/remote_instance.rb +3 -2
  33. data/lib/poolparty/net/remoter.rb +33 -18
  34. data/lib/poolparty/net/remoter_base.rb +3 -3
  35. data/lib/poolparty/plugins/gem_package.rb +6 -29
  36. data/lib/poolparty/plugins/git.rb +22 -0
  37. data/lib/poolparty/pool/base.rb +7 -6
  38. data/lib/poolparty/pool/cloud.rb +34 -5
  39. data/lib/poolparty/pool/custom_resource.rb +4 -4
  40. data/lib/poolparty/pool/plugin.rb +13 -14
  41. data/lib/poolparty/pool/resource.rb +19 -10
  42. data/lib/poolparty/pool/resources/class_package.rb +10 -6
  43. data/lib/poolparty/pool/resources/conditional.rb +41 -0
  44. data/lib/poolparty/pool/resources/gem.rb +2 -2
  45. data/lib/poolparty/pool/script.rb +25 -2
  46. data/lib/poolparty/templates/haproxy.conf +1 -1
  47. data/lib/poolparty/templates/puppet.conf +4 -2
  48. data/lib/poolparty/version.rb +1 -1
  49. data/poolparty.gemspec +60 -0
  50. data/setup.rb +1585 -0
  51. data/spec/poolparty/base_packages/haproxy_spec.rb +13 -0
  52. data/spec/poolparty/base_packages/heartbeat_spec.rb +30 -0
  53. data/spec/poolparty/bin/console_spec.rb +80 -0
  54. data/spec/poolparty/core/array_spec.rb +26 -0
  55. data/spec/poolparty/core/float.rb +13 -0
  56. data/spec/poolparty/core/hash_spec.rb +63 -0
  57. data/spec/poolparty/core/kernel_spec.rb +24 -0
  58. data/spec/poolparty/core/module_spec.rb +15 -0
  59. data/spec/poolparty/core/object_spec.rb +40 -0
  60. data/spec/poolparty/core/string_spec.rb +152 -0
  61. data/spec/poolparty/core/time_spec.rb +52 -0
  62. data/spec/poolparty/helpers/binary_spec.rb +26 -0
  63. data/spec/poolparty/helpers/display_spec.rb +13 -0
  64. data/spec/poolparty/helpers/optioner_spec.rb +39 -0
  65. data/spec/poolparty/helpers/provisioner_base_spec.rb +121 -0
  66. data/spec/poolparty/helpers/provisioners/master_spec.rb +54 -0
  67. data/spec/poolparty/helpers/provisioners/slave_spec.rb +28 -0
  68. data/spec/poolparty/modules/cloud_resourcer_spec.rb +135 -0
  69. data/spec/poolparty/modules/configurable_spec.rb +26 -0
  70. data/spec/poolparty/modules/definable_resource.rb +9 -0
  71. data/spec/poolparty/modules/file_writer_spec.rb +49 -0
  72. data/spec/poolparty/modules/s3_string_spec.rb +15 -0
  73. data/spec/poolparty/net/remote_bases/ec2_spec.rb +92 -0
  74. data/spec/poolparty/net/remote_instance_spec.rb +70 -0
  75. data/spec/poolparty/net/remote_spec.rb +286 -0
  76. data/spec/poolparty/net/remoter_base_spec.rb +80 -0
  77. data/spec/poolparty/net/remoter_spec.rb +191 -0
  78. data/spec/poolparty/plugins/git_spec.rb +19 -0
  79. data/spec/poolparty/plugins/line_spec.rb +16 -0
  80. data/spec/poolparty/plugins/svn_spec.rb +16 -0
  81. data/spec/poolparty/pool/base_spec.rb +108 -0
  82. data/spec/poolparty/pool/cloud_spec.rb +299 -0
  83. data/spec/poolparty/pool/configurers/files/ruby_basic.rb +17 -0
  84. data/spec/poolparty/pool/configurers/files/ruby_plugins.rb +16 -0
  85. data/spec/poolparty/pool/configurers/ruby_spec.rb +58 -0
  86. data/spec/poolparty/pool/custom_resource_spec.rb +115 -0
  87. data/spec/poolparty/pool/example_spec.rb +112 -0
  88. data/spec/poolparty/pool/plugin_model_spec.rb +63 -0
  89. data/spec/poolparty/pool/plugin_spec.rb +85 -0
  90. data/spec/poolparty/pool/pool_spec.rb +83 -0
  91. data/spec/poolparty/pool/resource_spec.rb +224 -0
  92. data/spec/poolparty/pool/resources/class_package_spec.rb +84 -0
  93. data/spec/poolparty/pool/resources/conditional_spec.rb +38 -0
  94. data/spec/poolparty/pool/resources/cron_spec.rb +49 -0
  95. data/spec/poolparty/pool/resources/directory_spec.rb +40 -0
  96. data/spec/poolparty/pool/resources/exec_spec.rb +37 -0
  97. data/spec/poolparty/pool/resources/file_spec.rb +40 -0
  98. data/spec/poolparty/pool/resources/gem_spec.rb +16 -0
  99. data/spec/poolparty/pool/resources/host_spec.rb +28 -0
  100. data/spec/poolparty/pool/resources/package_spec.rb +44 -0
  101. data/spec/poolparty/pool/resources/remote_file_spec.rb +40 -0
  102. data/spec/poolparty/pool/resources/service_spec.rb +45 -0
  103. data/spec/poolparty/pool/resources/sshkey_spec.rb +48 -0
  104. data/spec/poolparty/pool/resources/variable_spec.rb +20 -0
  105. data/spec/poolparty/pool/script_spec.rb +51 -0
  106. data/spec/poolparty/pool/test_plugins/sshkey_test +2 -0
  107. data/spec/poolparty/pool/test_plugins/virtual_host_template.erb +0 -0
  108. data/spec/poolparty/pool/test_plugins/webserver.rb +46 -0
  109. data/spec/poolparty/poolparty_spec.rb +33 -0
  110. data/spec/poolparty/spec_helper.rb +120 -0
  111. data/test/test_generator_helper.rb +29 -0
  112. data/test/test_helper.rb +2 -0
  113. data/test/test_pool_spec_generator.rb +47 -0
  114. data/test/test_poolparty.rb +11 -0
  115. data/website/index.html +81 -0
  116. data/website/index.txt +72 -0
  117. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  118. data/website/stylesheets/screen.css +138 -0
  119. data/website/template.html.erb +48 -0
  120. 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
@@ -5,6 +5,7 @@ require 'active_support'
5
5
  require 'open4'
6
6
  require "ftools"
7
7
  require "logging"
8
+ require "ruby2ruby"
8
9
 
9
10
  # Use active supports auto load mechanism
10
11
  ActiveSupport::Dependencies.load_paths << File.dirname(__FILE__)
@@ -3,39 +3,40 @@ module PoolParty
3
3
  plugin :haproxy do
4
4
 
5
5
  def enable
6
- package({:name => "haproxy"})
7
-
8
- # Startup haproxy and enable it
9
- has_line_in_file("ENABLED=1", "/etc/default/haproxy")
10
- has_line_in_file("SYSLOGD=\"-r\"", "/etc/default/syslogd")
11
- has_line_in_file("local0.* /var/log/haproxy.log", "/etc/syslog.conf", {:notify => 'Service["sysklogd"]'})
12
-
13
- # Restart sysklogd after we update the haproxy.log
14
- has_service(:name => "sysklogd") do
15
- ensures "running"
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 || Base.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
- has_gem_package(:name => "auser-poolparty", :source => "http://gems.github.com")
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?(:remote_instances_list) ? self : parent).remote_instances_list.each do |ri|
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
@@ -1,2 +1,7 @@
1
+ require 'ruby2ruby'
2
+
1
3
  class Proc
4
+ def to_ruby(opts={})
5
+ Ruby2Ruby.new.process(self.to_sexp).gsub(/proc \{/, "do \n#{opts.map {|k,v| "#{k} \"#{v}\""}.join("\n")}\n").sub(/\}/, "\nend")
6
+ end
2
7
  end
@@ -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
- "pool.spec",
19
- "#{Base.remote_storage_directory}/pool.spec",
20
- "#{Base.storage_directory}/pool.spec",
21
- ENV["POOL_SPEC"]
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.each do |k,v|
6
- print v.pretty_print
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
- attr_reader :options
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
- "export AWS_ACCESS_KEY_ID=#{@cloud.access_key}",
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 get_puppet_packages_for(os)
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(name)
186
- self.class.installers[name.to_sym]
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(@os)} #{get_puppet_packages_for(@os)}"
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
- "puppetmasterd && puppetd --listen"
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 # && puppetrun --host 127.0.0.1
116
- # "puppetd --listen"
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(@os)} #{get_puppet_packages_for(@os)}
22
- echo 'DAEMON_OPTS="-w 120 server puppet"' > /etc/default/puppet
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
- # This is included in the poolparty-apache-plugin
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? ? options[m] : options[m] = (args.is_a?(Array) && args.size > 1) ? args : args[0]
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