auser-poolparty 1.1.1 → 1.1.3

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.
Files changed (33) hide show
  1. data/VERSION.yml +1 -1
  2. data/bin/cloud-show +27 -0
  3. data/lib/poolparty/base_packages/haproxy.rb +4 -3
  4. data/lib/poolparty/dependency_resolver/chef_resolver.rb +14 -2
  5. data/lib/poolparty/helpers/binary.rb +8 -7
  6. data/lib/poolparty/lite.rb +1 -1
  7. data/lib/poolparty/monitors/base_monitor.rb +81 -81
  8. data/lib/poolparty/monitors/monitor_rack.rb +8 -1
  9. data/lib/poolparty/monitors/stats_monitor.rb +11 -12
  10. data/lib/poolparty/poolparty/cloud.rb +22 -136
  11. data/lib/poolparty/poolparty/template.rb +10 -1
  12. data/lib/poolparty/provision/boot_strapper.rb +2 -1
  13. data/lib/poolparty/resources/file.rb +4 -4
  14. data/spec/poolparty/dependency_resolver/dependency_resolver_cloud_extensions_spec.rb +1 -1
  15. data/spec/poolparty/net/remote_spec.rb +0 -1
  16. data/spec/poolparty/poolparty/cloud_spec.rb +2 -36
  17. data/spec/poolparty/resources/file_spec.rb +1 -0
  18. data/test/fixtures/test_template.erb +1 -0
  19. data/test/poolparty/poolparty/template_test.rb +31 -0
  20. data/test/poolparty/provision/boot_strapper_test.rb +6 -0
  21. data/test/poolparty/provision/dr_configure_test.rb +6 -0
  22. data/test/test_helper.rb +2 -0
  23. metadata +12 -17
  24. data/lib/poolparty/provisioners/capistrano/capistrano.rb +0 -158
  25. data/lib/poolparty/provisioners/capistrano/capistrano_configurer.rb +0 -69
  26. data/lib/poolparty/provisioners/capistrano/recipes/aws.rb +0 -21
  27. data/lib/poolparty/provisioners/capistrano/recipes/base.rb +0 -164
  28. data/lib/poolparty/provisioners/capistrano/recipes/master.rb +0 -66
  29. data/lib/poolparty/provisioners/capistrano/recipes/puppet.rb +0 -101
  30. data/lib/poolparty/provisioners/capistrano/recipes/slave.rb +0 -36
  31. data/lib/poolparty/provisioners/provisioner_base.rb +0 -222
  32. data/spec/poolparty/provisioners/capistrano/capistrano_spec.rb +0 -40
  33. data/spec/poolparty/provisioners/provisioner_base_spec.rb +0 -129
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 1
2
+ :patch: 3
3
3
  :major: 1
4
4
  :minor: 1
data/bin/cloud-show ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
3
+ require "poolparty"
4
+
5
+ o = PoolParty::Optioner.new(ARGV) do |opts, optioner|
6
+ opts.on('-n name', '--name name', 'Listing for cloud name') { |c| optioner.cloudname c }
7
+ end
8
+
9
+ o.loaded_clouds.each do |cld|
10
+
11
+ print_with_nice_printer "Cloud: #{cld.name}", [
12
+ "instances #{cld.minimum_instances}..#{cld.maximum_instances}",
13
+ "keypair #{cld.keypair}"
14
+ ] do |printer|
15
+ if cld.list_of_running_instances.size > 0
16
+ printer.empty
17
+ printer.center("Active instances")
18
+ printer << cld.list_of_running_instances.map{|a| a.ip.strip }.join("\n")
19
+ end
20
+ if cld.list_of_pending_instances.size > 0
21
+ printer.empty
22
+ printer.center "Pending instances"
23
+ printer << cld.list_of_pending_instances.map{|a| a.to_s}.join("\n")
24
+ end
25
+ printer.empty
26
+ end
27
+ end
@@ -29,15 +29,16 @@ module PoolParty
29
29
  :requires => get_package("haproxy")
30
30
 
31
31
  # Service is required
32
- has_service("haproxy", :ensures => "running")
32
+ has_service("haproxy", :ensures => "running") do
33
+ stops get_service("apache2"), :immediately
34
+ starts get_service("apache2")
35
+ end
33
36
 
34
37
  has_directory "/var/run/haproxy"
35
38
 
36
39
  has_file "/etc/haproxy/haproxy.cfg" do
37
40
  template "#{::File.dirname(__FILE__)}/../templates/haproxy.conf"
38
41
  calls get_exec("reloadhaproxy")
39
- stops get_service("apache2")
40
- starts get_service("apache2")
41
42
  end
42
43
  end
43
44
  end
@@ -138,19 +138,23 @@ module PoolParty
138
138
  end
139
139
  end
140
140
 
141
+ # Check if the hash has content and that the content exists here. This is used
142
+ # to provide a check
141
143
  def before_filter_check_on_hash(hsh, nm)
142
144
  if hsh.has_key?(:content)
143
145
  cont = hsh.delete(:content)
144
146
  temp_file = "#{base_dir}/templates/default/#{nm}.erb"
145
147
  ::FileUtils.mkdir_p(::File.dirname(temp_file)) unless ::File.directory? temp_file
146
148
  ::File.open(temp_file, "w+") {|f| f.print cont }
147
- hsh.merge!({:source => "#{nm}.erb", :variables => hsh.dup})
149
+ hsh.merge!({:source => "#{nm}.erb"})
148
150
  end
149
151
  #
150
152
  hsh.delete(:require) if hsh.has_key?(:require)
151
153
  hsh
152
154
  end
153
155
 
156
+ # Turn the services into strings using the handle_print_service method
157
+ # Here we can strip out non-meaningful chef services
154
158
  def services_to_string(opts,tabs=0)
155
159
  if opts
156
160
  str = ""
@@ -164,6 +168,8 @@ module PoolParty
164
168
  end
165
169
  end
166
170
 
171
+ # Take the keys from the resource hash and turn them into chef-like
172
+ # meaningful keys. This is how helpers are created for chef
167
173
  def to_chef_key(key)
168
174
  case key
169
175
  when :ensures
@@ -185,6 +191,8 @@ module PoolParty
185
191
  end
186
192
  end
187
193
 
194
+ # Resolve the value of the resource hash into a meaningful chef
195
+ # value. Resources are turned into resource strings here
188
196
  def to_option_string(obj)
189
197
  case obj
190
198
  when PoolParty::Resources::Resource
@@ -194,7 +202,11 @@ module PoolParty
194
202
  when String
195
203
  "\"#{obj}\""
196
204
  when Array
197
- "[ #{obj.map {|e| to_option_string(e) }.reject {|a| a.nil? || a.empty? }.join(", ")} ]"
205
+ if obj[1] && [:immediately, :delayed].include?(obj[1])
206
+ "#{to_option_string(obj[0])}, :#{obj[1]}"
207
+ else
208
+ "[ #{obj.map {|e| to_option_string(e) }.reject {|a| a.nil? || a.empty? }.join(", ")} ]"
209
+ end
198
210
  when nil
199
211
  nil
200
212
  when Hash
@@ -15,13 +15,14 @@ module PoolParty
15
15
  end
16
16
  end
17
17
 
18
- def print_with_nice_printer(header=nil, strs=[])
19
- returning NicePrinter.new do |printer|
20
- printer.header
21
- printer.center(header) if header
22
- strs.each {|st| printer << st if st}
23
- printer.footer
24
- end.print
18
+ def print_with_nice_printer(header=nil, strs=[], &block)
19
+ printer = NicePrinter.new
20
+ printer.header
21
+ printer.center(header) if header
22
+ yield(printer)
23
+ strs.each {|st| printer << st if st}
24
+ printer.footer
25
+ printer.print
25
26
  end
26
27
 
27
28
  def pool_specfile
@@ -1,6 +1,6 @@
1
1
  require "rubygems"
2
2
  require "json"
3
- require 'dslify' rescue require("#{::File.dirname(__FILE__)}/../../vendor/gems/dslify/lib/dslify")
3
+ require("#{::File.dirname(__FILE__)}/../../vendor/gems/dslify/lib/dslify")
4
4
  require "#{::File.dirname(__FILE__)}/poolparty/default"
5
5
  require "#{::File.dirname(__FILE__)}/schema"
6
6
  require "#{::File.dirname(__FILE__)}/net/init"
@@ -1,81 +1,81 @@
1
- =begin rdoc
2
- Monitor class
3
-
4
- Monitors are the basis for PoolParty scaling. Your cloud will expand and
5
- contract against these monitors. You can set your cloud to be monitored by these
6
- monitors simply by using them in the contract_when and the expand_when macros
7
- on your cloud like so:
8
-
9
- expand_when "cpu > 1.2", "memory > 0.94"
10
- contract_when "cpu < 0.4", "memory < 0.3"
11
-
12
- You can also add your own monitors simply by creating a directory in the same
13
- directory as the pool spec (the same directory as the plugin directory exists) and
14
- placing your monitor file (format: [monitorname]_monitor.rb) there.
15
-
16
- Monitors are simply classes of the name of the monitor. They subclass the BaseMonitor
17
- class from PoolParty. A sample monitor would look similar to:
18
-
19
- class SampleMonitor < PoolParty::Monitors::BaseMonitor
20
- def run
21
- end
22
- end
23
- register_monitor :sample
24
-
25
- The monitor class must have an instance level method called run. This method is called when
26
- the cloud is checking the monitor. The output of this method should be the output of
27
- the monitor.
28
-
29
- Notice that at the end, you must call register_monitor :monitorname. This will tell your cloud
30
- that it can monitor it with this monitor.
31
- =end
32
- require "#{::File.dirname(__FILE__)}/../poolparty/default"
33
-
34
- module PoolParty
35
- module Monitors
36
-
37
- module ClassMethods
38
- end
39
-
40
- module InstanceMethods
41
- def expand_when(*arr)
42
- @expand_when ||= ((arr && arr.empty?) ? options[:expand_when] : configure(:expand_when => self.class.send(:rules,:expand_when,arr,false)))
43
- end
44
-
45
- def contract_when(*arr)
46
- @contract_when ||= ((arr&&arr.empty?) ? options[:contract_when] : configure(:contract_when => self.class.send(:rules,:contract_when,arr,false)))
47
- end
48
- end
49
-
50
- def self.register_monitor(*args)
51
- args.each do |arg|
52
- (available_monitors << "#{arg}".downcase.to_sym unless available_monitors.include?("#{arg}".downcase.to_sym))
53
-
54
- InstanceMethods.module_eval "def #{arg}; @#{arg} ||= get_live_#{arg}; end"
55
- InstanceMethods.module_eval "def get_live_#{arg}; messenger_send!(\"get_current_load #{arg}\").to_f rescue -1.0; end"
56
- end
57
- end
58
-
59
- def self.available_monitors
60
- $available_monitors ||= []
61
- end
62
-
63
- class BaseMonitor
64
- def self.run
65
- new.run
66
- end
67
- end
68
-
69
- def self.included(receiver)
70
- receiver.extend PoolParty::Monitors::ClassMethods
71
- receiver.send :include, PoolParty::Monitors::InstanceMethods
72
- receiver.send :include, Aska
73
- end
74
-
75
- end
76
- end
77
-
78
- # Require included monitors
79
- Dir["#{File.dirname(__FILE__)}/monitors/*.rb"].each {|f| require f}
80
- # Require custom monitors
81
- Dir["#{PoolParty::Default.custom_monitor_directories}/*.rb"].each {|f| require f}
1
+ # =begin rdoc
2
+ # Monitor class
3
+ #
4
+ # Monitors are the basis for PoolParty scaling. Your cloud will expand and
5
+ # contract against these monitors. You can set your cloud to be monitored by these
6
+ # monitors simply by using them in the contract_when and the expand_when macros
7
+ # on your cloud like so:
8
+ #
9
+ # expand_when "cpu > 1.2", "memory > 0.94"
10
+ # contract_when "cpu < 0.4", "memory < 0.3"
11
+ #
12
+ # You can also add your own monitors simply by creating a directory in the same
13
+ # directory as the pool spec (the same directory as the plugin directory exists) and
14
+ # placing your monitor file (format: [monitorname]_monitor.rb) there.
15
+ #
16
+ # Monitors are simply classes of the name of the monitor. They subclass the BaseMonitor
17
+ # class from PoolParty. A sample monitor would look similar to:
18
+ #
19
+ # class SampleMonitor < PoolParty::Monitors::BaseMonitor
20
+ # def run
21
+ # end
22
+ # end
23
+ # register_monitor :sample
24
+ #
25
+ # The monitor class must have an instance level method called run. This method is called when
26
+ # the cloud is checking the monitor. The output of this method should be the output of
27
+ # the monitor.
28
+ #
29
+ # Notice that at the end, you must call register_monitor :monitorname. This will tell your cloud
30
+ # that it can monitor it with this monitor.
31
+ # =end
32
+ # require "#{::File.dirname(__FILE__)}/../poolparty/default"
33
+ #
34
+ # module PoolParty
35
+ # module Monitors
36
+ #
37
+ # module ClassMethods
38
+ # end
39
+ #
40
+ # module InstanceMethods
41
+ # def expand_when(*arr)
42
+ # @expand_when ||= ((arr && arr.empty?) ? options[:expand_when] : configure(:expand_when => self.class.send(:rules,:expand_when,arr,false)))
43
+ # end
44
+ #
45
+ # def contract_when(*arr)
46
+ # @contract_when ||= ((arr&&arr.empty?) ? options[:contract_when] : configure(:contract_when => self.class.send(:rules,:contract_when,arr,false)))
47
+ # end
48
+ # end
49
+ #
50
+ # def self.register_monitor(*args)
51
+ # args.each do |arg|
52
+ # (available_monitors << "#{arg}".downcase.to_sym unless available_monitors.include?("#{arg}".downcase.to_sym))
53
+ #
54
+ # InstanceMethods.module_eval "def #{arg}; @#{arg} ||= get_live_#{arg}; end"
55
+ # InstanceMethods.module_eval "def get_live_#{arg}; messenger_send!(\"get_current_load #{arg}\").to_f rescue -1.0; end"
56
+ # end
57
+ # end
58
+ #
59
+ # def self.available_monitors
60
+ # $available_monitors ||= []
61
+ # end
62
+ #
63
+ # class BaseMonitor
64
+ # def self.run
65
+ # new.run
66
+ # end
67
+ # end
68
+ #
69
+ # def self.included(receiver)
70
+ # receiver.extend PoolParty::Monitors::ClassMethods
71
+ # receiver.send :include, PoolParty::Monitors::InstanceMethods
72
+ # receiver.send :include, Aska
73
+ # end
74
+ #
75
+ # end
76
+ # end
77
+ #
78
+ # # Require included monitors
79
+ # Dir["#{File.dirname(__FILE__)}/monitors/*.rb"].each {|f| require f}
80
+ # # Require custom monitors
81
+ # Dir["#{PoolParty::Default.custom_monitor_directories}/*.rb"].each {|f| require f}
@@ -101,6 +101,13 @@ module Monitors
101
101
 
102
102
  end
103
103
 
104
+ # Base monitor
105
+ class MonitorBase
106
+ def initialize(env={})
107
+ @env = env
108
+ end
109
+ end
110
+
104
111
  #load our monitors
105
112
  require ::File.dirname(__FILE__)+"/stats_monitor.rb"
106
113
  require ::File.dirname(__FILE__)+"/neighborhood_monitor.rb"
@@ -117,7 +124,7 @@ module Monitors
117
124
  end
118
125
  end
119
126
 
120
- class Favicon
127
+ class Favicon < MonitorBase
121
128
  def self.default
122
129
  ''
123
130
  end
@@ -2,7 +2,7 @@ require ::File.dirname(__FILE__)+"/monitor_rack.rb"
2
2
 
3
3
  module Monitors
4
4
 
5
- class Stats
5
+ class Stats
6
6
  attr_reader :stats, :request
7
7
  attr_accessor :response
8
8
 
@@ -33,16 +33,17 @@ module Monitors
33
33
  log << "#{Time.now.strftime("%Y-%m-%d-%H-%M")}, #{stats.to_json}\n"
34
34
  end
35
35
 
36
- def default
37
- stats.to_json
38
- end
39
-
40
36
  def log(log_file_path="/var/log/poolparty/stats_monitor.log")
41
- ::File.file? log_file_path
42
- @logfile ||= ::File.new(log_file_path, 'a')
37
+ if @logfile
38
+ @logfile
39
+ else
40
+ ::File.file? log_file_path
41
+ ::FileUtils.mkdir_p ::File.dirname(log_file_path) unless ::File.directory?(::File.dirname(log_file_path))
42
+ @logfile ||= ::File.open(log_file_path, 'a+')
43
+ end
43
44
  end
44
-
45
- def default
45
+
46
+ def default
46
47
  begin
47
48
  if !request.params || request.params.empty?
48
49
  default_stats
@@ -52,11 +53,9 @@ module Monitors
52
53
  stats.to_json
53
54
  end
54
55
  rescue Exception => e
55
- response.fail!
56
56
  "Error: #{e}"
57
57
  end
58
58
  end
59
- alias :get :default
60
59
 
61
60
  def put
62
61
  if d = JSON.parse(request.params)
@@ -112,7 +111,7 @@ module Monitors
112
111
  def default_stats
113
112
  %w(load nominations).each do |var|
114
113
  stats[my_ip][var] ||= self.send(var.to_sym)
115
- end
114
+ end
116
115
  stats
117
116
  end
118
117
 
@@ -18,19 +18,18 @@ module PoolParty
18
18
  end
19
19
 
20
20
  class Cloud < PoolParty::PoolPartyBaseClass
21
- attr_reader :templates, :cloud_name
21
+ attr_reader :templates, :cloud_name, :remote_base
22
22
 
23
23
  include CloudResourcer
24
24
  include PoolParty::PluginModel
25
25
  include PoolParty::Resources
26
26
  include PoolParty::DependencyResolverCloudExtensions
27
27
  include PrettyPrinter
28
- include Provisioner
29
28
 
30
29
  # Net methods
31
30
  include ::PoolParty::Remote
32
31
  include PoolParty::CloudDsl
33
- include PoolParty::Monitors
32
+ # include PoolParty::Monitors
34
33
 
35
34
  def verbose
36
35
  true
@@ -46,6 +45,8 @@ module PoolParty
46
45
 
47
46
  alias :name :cloud_name
48
47
 
48
+ # Call the remoter commands on the cloud if they don't exist on the cloud itself
49
+ # This gives the cloud access to the remote_base's methods
49
50
  def method_missing(m, *args, &block)
50
51
  remote_base.respond_to?(m) ? remote_base.send(m, *args, &block) : super
51
52
  end
@@ -60,6 +61,8 @@ module PoolParty
60
61
  :user => Default.user
61
62
  )
62
63
 
64
+ # Freeze the cloud_name so we can't modify it at all, set the plugin_directory
65
+ # call and run instance_eval on the block and then call the after_create callback
63
66
  def initialize(name, &block)
64
67
  @cloud_name = name
65
68
  @cloud_name.freeze
@@ -69,11 +72,15 @@ module PoolParty
69
72
  after_create
70
73
  end
71
74
 
75
+ # Fetch the name of the cloud
72
76
  def name(*args)
73
77
  @cloud_name ||= @cloud_name ? @cloud_name : (args.empty? ? :default_cloud : args.first)
74
78
  end
75
79
 
76
80
  # Callback
81
+ # called after the cloud has been created, everything has run and is set at this point
82
+ # here the base requirements are added as well as an empty chef recipe is called
83
+ # Also, the after_create hook on the plugins used by the cloud are called here
77
84
  def after_create
78
85
  dputs "In after create"
79
86
  ::FileUtils.mkdir_p("#{Default.tmp_path}/dr_configure")
@@ -86,6 +93,7 @@ module PoolParty
86
93
  setup_defaults
87
94
  end
88
95
 
96
+ # setup defaults for the cloud
89
97
  def setup_defaults
90
98
  # this can be overridden in the spec, but ec2 is the default
91
99
  using :ec2
@@ -99,70 +107,11 @@ module PoolParty
99
107
  list_of_running_instances.map {|ri| ri.ip }
100
108
  end
101
109
 
110
+ # TODO: make this be a random ip, since we should not rely on it being the same each time
102
111
  def ip
103
- ips.first #TODO: make this be a random ip, since we should not rely on it being the same each time
112
+ ips.first
104
113
  end
105
-
106
- # TODO: Deprecated
107
- def dependency_resolver_command
108
- "/usr/bin/puppet -v --logdest syslog /etc/puppet/manifests/site.pp"
109
- end
110
-
111
- # Prepare to send the new configuration to the instances
112
- # First, let's make sure that our base directory is made
113
- # Then copy the templates that have no other reference in
114
- # a spec file. Make sure the keys are stored in a file
115
- # For the master to have access to them
116
- # Then, send the saved containing cloud instances to give the
117
- # remote master access to the cloud options that are required
118
- # for the master to run checks
119
- def prepare_for_configuration
120
- # # clear_base_directory
121
- # make_base_directory
122
- # copy_misc_templates
123
- # copy_custom_monitors
124
- # copy_custom_modules
125
- # copy_custom_templates
126
- # store_keys_in_file
127
- # # Script.save!(self)
128
- # # not my favorite...
129
- # copy_ssh_key
130
- # write_unique_cookie
131
- # before_configuration_tasks
132
- # write_properties_hash if debugging || testing
133
- end
134
-
135
- def copy_custom_templates
136
- return true unless ::File.directory?("#{Dir.pwd}/templates")
137
- Dir["#{Dir.pwd}/templates/*"].each {|file| copy_template_to_storage_directory(file, true) }
138
- end
139
-
140
- # Copy the ssh keys to the storage directory in preparation for
141
- # configuration
142
- def copy_ssh_key
143
- copy_file_to_storage_directory(full_keypair_path)
144
- end
145
-
146
- # Store our keys for cloud access in a file
147
- # that is specific to this cloud
148
- def store_keys_in_file
149
- Default.store_keys_in_file_for(self)
150
- end
151
-
152
- # Let's write the cookie into the tmp path
153
- def write_unique_cookie
154
- write_to_file_in_storage_directory("cookie") do
155
- generate_unique_cookie_string
156
- end
157
- end
158
-
159
- # Generate a unique cookie string so that our erlang modules can
160
- # talk to each other safely. This is based off the keypair
161
- # and the name of the cloud
162
- def generate_unique_cookie_string
163
- Digest::SHA256.hexdigest("#{keypair.basename}#{name}")[0..12]
164
- end
165
-
114
+
166
115
  # Build the new poolparty manifest
167
116
  # Wrapping all of these requirements into the one
168
117
  # poolparty class.
@@ -180,12 +129,6 @@ module PoolParty
180
129
  end
181
130
  end
182
131
 
183
- def copy_misc_templates
184
- ["namespaceauth.conf", "puppet/puppet.conf", "gem"].each do |f|
185
- copy_file_to_storage_directory(::File.join(::File.dirname(__FILE__), "..", "templates", f))
186
- end
187
- end
188
-
189
132
  # If there is a directory named monitors in the same directory
190
133
  # as the pool specification file is in,
191
134
  # then create a monitors directory in the storage directory
@@ -194,21 +137,8 @@ module PoolParty
194
137
  # that are in known locations, these are included
195
138
  def copy_custom_monitors
196
139
  unless Default.custom_monitor_directories.empty?
197
- make_directory_in_storage_directory("monitors")
198
140
  Default.custom_monitor_directories.each do |dir|
199
- Dir["#{dir}/*.rb"].each {|f| copy_file_to_storage_directory(f, "monitors")}
200
- end
201
- end
202
- end
203
-
204
- def copy_custom_modules
205
- unless Default.custom_modules_directories.empty?
206
- make_directory_in_storage_directory("modules")
207
- Default.custom_modules_directories.each do |dir|
208
- Dir["#{dir}/*"].each do |d|
209
- to = ::File.join("modules", ::File.basename(d))
210
- copy_directory_into_storage_directory(d, to) if ::File.directory?(d)
211
- end
141
+ Dir["#{dir}/*.rb"].each {|f| ::Suitcase::Zipper.add(f, "monitors")}
212
142
  end
213
143
  end
214
144
  end
@@ -231,35 +161,9 @@ module PoolParty
231
161
  build_manifest
232
162
  end
233
163
 
234
- #FIXME DEPRECATE
235
- # def build_short_manifest
236
- # returning Array.new do |str|
237
- #
238
- # # Refactor this into the resources method
239
- # # TODO
240
- # services.each do |service|
241
- # service.options.merge!(:name => service.name)
242
- # classpackage_with_self(service)
243
- # end
244
- #
245
- # options.merge!(:name => "user")
246
- # classpackage_with_self
247
- # # resources.each do |type, res|
248
- # # str << "# #{type.to_s.pluralize}"
249
- # # str << res.to_string
250
- # # end
251
- #
252
- # global_classpackages.each do |cls|
253
- # str << cls.to_string
254
- # end
255
- #
256
- # str << "# Custom functions"
257
- # str << Resources::CustomResource.custom_functions_to_string
258
- # end.join("\n")
259
- # end
260
-
164
+ # If the
261
165
  def build_from_existing_file
262
- ::FileTest.file?("#{Default.manifest_path}/classes/poolparty.pp") ? open("#{Default.manifest_path}/classes/poolparty.pp").read : nil
166
+ ::FileTest.file?("#{Default.base_config_directory}/poolparty.pp") ? open("#{Default.base_config_directory}/poolparty.pp").read : nil
263
167
  end
264
168
 
265
169
  def write_properties_hash(filename=::File.join(Default.tmp_path, Default.properties_hash_filename) )
@@ -269,26 +173,8 @@ module PoolParty
269
173
  ::File.open("#{file_path}/#{file_name}", "w") {|f| f.write output }
270
174
  true
271
175
  end
272
-
273
- # To allow the remote instances to do their job,
274
- # they need a few options to run, these are the required options
275
- # to be saved on the remote "master" machine
276
- def minimum_runnable_options
277
- ([
278
- :keypair, :minimum_instances, :maximum_instances,
279
- :expand_when, :contract_when, :set_master_ip_to #DEPRECATE set_master_ip_to
280
- ]<< custom_minimum_runnable_options).flatten
281
- end
282
-
283
- def custom_minimum_runnable_options
284
- using_remoter? ? remote_base.custom_minimum_runnable_options : []
285
- end
286
-
287
- def remote_base
288
- @remote_base ||= nil
289
- end
290
176
 
291
- # Callbacks on before_bootstrap
177
+ # Callbacks on bootstrap and configuration
292
178
  %w( before_bootstrap
293
179
  after_bootstrap
294
180
  before_configure
@@ -314,11 +200,11 @@ module PoolParty
314
200
  end
315
201
 
316
202
  def other_clouds
317
- returning Array.new do |arr|
318
- clouds.each do |name, cl|
319
- arr << cl if name != self.name
320
- end
203
+ arr = []
204
+ clouds.each do |name, cl|
205
+ arr << cl if name != self.name
321
206
  end
207
+ arr
322
208
  end
323
209
 
324
210
  def reset!
@@ -6,7 +6,7 @@ module PoolParty
6
6
 
7
7
  def self.compile_string(string, opts={})
8
8
  vars = OpenStruct.new opts
9
- ERB.new(string).result(vars.send(:binding))
9
+ handle_render(string, vars, (opts.delete(:render) || :erb))
10
10
  end
11
11
 
12
12
  def self.compile_file(file, opts={})
@@ -14,5 +14,14 @@ module PoolParty
14
14
  compile_string(content, opts)
15
15
  end
16
16
 
17
+ def self.handle_render(string, vars, renderer)
18
+ case renderer
19
+ when :haml
20
+ nil
21
+ else
22
+ ERB.new(string).result(vars.send(:binding))
23
+ end
24
+ end
25
+
17
26
  end
18
27
  end