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
@@ -23,7 +23,8 @@ module PoolParty
23
23
  # Do not print if the option is nil or empty.
24
24
  # Also, don't show the option if the option is empty or the default option on the cloud
25
25
  def pretty_options(prev, o)
26
- print_options = (o.respond_to?(:parent) && o.parent) ?
26
+ return "" unless o.respond_to?(:options)
27
+ print_options = (o.respond_to?(:parent) && o.parent && o.parent.respond_to?(:options)) ?
27
28
  (o.options.delete_if {|k,v| o.parent.options.has_key?(k) && o.parent.options[k] == o.options[k] && !o.options[k].nil? } ) :
28
29
  o.options
29
30
  print_options = print_options.map {|k,v| [k, o.send(k.to_sym).to_s] }.inject({}) { |r,e| r[e[0]] = e[1] unless o.class.default_options[e[0]] == e[1] || e[1].nil? || e[1].empty?; r }
@@ -12,7 +12,7 @@ module PoolParty
12
12
  self.class.send :attr_reader, :remote_base
13
13
  mod = "#{t}".preserved_module_constant
14
14
 
15
- mod.send :include, PoolParty::Remote::RemoterBase
15
+ mod.send :include, PoolParty::Remote::RemoterBase
16
16
  self.class.send :include, mod
17
17
  self.extend mod
18
18
 
@@ -1,4 +1,6 @@
1
- require "ec2"
1
+ require 'rubygems'
2
+ require 'EC2'
3
+
2
4
  class String
3
5
  def convert_from_ec2_to_ip
4
6
  self.gsub(/.compute-1.amazonaws.com*/, '').gsub(/ec2-/, '').gsub(/-/, '.')
@@ -6,15 +8,15 @@ class String
6
8
  end
7
9
  module PoolParty
8
10
  module Ec2
9
- def launch_new_instance!
11
+ def launch_new_instance!(num=1)
10
12
  instance = ec2.run_instances(
11
- :image_id => self.respond_to?(:ami) ? ami : Base.ami,
13
+ :image_id => (ami || Base.ami),
12
14
  :user_data => "",
13
15
  :minCount => 1,
14
- :maxCount => 1,
15
- :key_name => "#{self.respond_to?(:keypair) ? keypair : Base.keypair}",
16
+ :maxCount => num,
17
+ :key_name => (keypair || Base.keypair),
16
18
  :availability_zone => nil,
17
- :size => "#{self.respond_to?(:size) ? size : Base.size}")
19
+ :size => "#{size || Base.size}")
18
20
  begin
19
21
  item = instance#.instancesSet.item
20
22
  EC2ResponseObject.get_hash_from_response(item)
@@ -34,7 +36,7 @@ module PoolParty
34
36
  @id = 0
35
37
  @describe_instances = get_instances_description.each_with_index do |h,i|
36
38
  if h[:status] == "running"
37
- @name = "node#{@id}"
39
+ @name = @id == 0 ? "master" : "node#{@id}"
38
40
  @id += 1
39
41
  else
40
42
  @name = "#{h[:status]}_node#{i}"
@@ -45,7 +47,6 @@ module PoolParty
45
47
  :ip => h[:ip].convert_from_ec2_to_ip
46
48
  })
47
49
  end
48
- @describe_instances.first[:name] = "master" unless @describe_instances.empty?
49
50
  end
50
51
  @describe_instances
51
52
  end
@@ -58,8 +59,10 @@ module PoolParty
58
59
  # This is a helper to create the keypair and add them to the cloud for you
59
60
  def create_keypair
60
61
  return false unless keypair
61
- FileUtils.mkdir_p ::File.dirname(new_keypair_path) unless ::File.directory?(::File.dirname(new_keypair_path))
62
- Kernel.system "ec2-add-keypair #{keypair} > #{new_keypair_path} && chmod 600 #{new_keypair_path}"
62
+ unless ::File.exists?( new_keypair_path )
63
+ FileUtils.mkdir_p ::File.dirname( new_keypair_path )
64
+ Kernel.system "ec2-add-keypair #{keypair} > #{new_keypair_path} && chmod 600 #{new_keypair_path}"
65
+ end
63
66
  end
64
67
  # EC2 connections
65
68
  def ec2
@@ -9,8 +9,9 @@ module PoolParty
9
9
  include CloudResourcer
10
10
 
11
11
  def initialize(opts, parent=self)
12
- set_parent(parent) if parent
13
- set_vars_from_options(opts) unless opts.empty?
12
+ @parent = parent
13
+ set_vars_from_options(parent.options) if parent && parent.respond_to?(:options)
14
+ set_vars_from_options(opts) unless opts.nil? || opts.empty?
14
15
  on_init
15
16
  end
16
17
 
@@ -46,7 +46,7 @@ module PoolParty
46
46
  out = list_from_remote(:cache => true)
47
47
  end
48
48
  return out
49
- end
49
+ end
50
50
  # List the instances that are known from the remoter_base
51
51
  # Create a RemoteInstance for each of the instances from the hash
52
52
  # returned by the list of instances, write them to the cached file
@@ -87,14 +87,15 @@ module PoolParty
87
87
  ]
88
88
  end
89
89
 
90
- # More functional methods
90
+ # List calculation methods
91
+ #
91
92
  # Are the minimum number of instances running?
92
93
  def minimum_number_of_instances_are_running?
93
- list_of_running_instances.size >= minimum_instances
94
+ list_of_running_instances.size >= minimum_instances.to_i
94
95
  end
95
96
  # Can we shutdown an instance?
96
97
  def can_shutdown_an_instance?
97
- list_of_running_instances.size > minimum_instances
98
+ list_of_running_instances.size > minimum_instances.to_i
98
99
  end
99
100
  # Request to launch a number of instances
100
101
  def request_launch_new_instances(num=1)
@@ -113,38 +114,52 @@ module PoolParty
113
114
  end
114
115
  # Are the maximum number of instances running?
115
116
  def maximum_number_of_instances_are_not_running?
116
- list_of_running_instances.size < maximum_instances
117
+ list_of_running_instances.size < maximum_instances.to_i
117
118
  end
118
119
  # Launch new instance while waiting for the number of pending instances
119
120
  # to be zero before actually launching. This ensures that we only
120
121
  # launch one instance at a time
121
- def request_launch_one_instance_at_a_time
122
- when_no_pending_instances do
123
- launch_new_instance!
124
- end
122
+ def request_launch_one_instance_at_a_time
123
+ when_no_pending_instances { launch_new_instance! }
125
124
  end
126
125
  # A convenience method for waiting until there are no more
127
126
  # pending instances and then running the block
128
127
  def when_no_pending_instances(&block)
129
128
  reset!
130
- if list_of_pending_instances.size > 0
129
+ if list_of_pending_instances.size == 0
130
+ block.call if block
131
+ else
131
132
  wait "5.seconds"
132
133
  when_no_pending_instances(&block)
133
- else
134
- block.call if block
135
134
  end
136
135
  end
137
136
 
138
137
  # This will launch the minimum_instances if the minimum number of instances are not running
139
138
  # If the minimum number of instances are not running and if we can start a new instance
140
- def launch_minimum_number_of_instances
141
- if can_start_a_new_instance?
142
- while !minimum_number_of_instances_are_running?
143
- request_launch_one_instance_at_a_time
144
- wait "5.seconds"
145
- end
139
+ def launch_minimum_number_of_instances
140
+ if can_start_a_new_instance? && !minimum_number_of_instances_are_running?
141
+ list_of_pending_instances.size == 0 ? request_launch_one_instance_at_a_time : wait("5.seconds")
142
+ reset!
143
+ launch_minimum_number_of_instances unless minimum_number_of_instances_are_running?
146
144
  end
147
145
  end
146
+ # Launch the master and let the master handle the starting of the cloud
147
+ # We should only launch an instance if there are no pending instances, in the case
148
+ # that the master has launched, but is still pending
149
+ # and if the master is not running AND we can start a new instance
150
+ # Then wait for the master to launch
151
+ def launch_and_configure_master!(testing=false)
152
+ request_launch_new_instances(1) if list_of_pending_instances.size.zero? && can_start_a_new_instance? && !is_master_running?
153
+
154
+ when_no_pending_instances do
155
+ wait "5.seconds"
156
+ Provisioner.provision_master(self, testing)
157
+ end
158
+
159
+ end
160
+ def is_master_running?
161
+ !list_of_running_instances.select {|a| a.name == "master"}.first.nil?
162
+ end
148
163
  # Stub method for the time being to handle expansion of the cloud
149
164
  def should_expand_cloud?(force=false)
150
165
  force || false
@@ -54,7 +54,7 @@ module PoolParty
54
54
  list.reject {|i| true if !i.terminating? }
55
55
  end
56
56
  # Get the instances that are non-master instances
57
- def nonmaster_nonterminated_instances(list = remote_instances_list)
57
+ def nonmaster_nonterminated_instances(list = list_of_nonterminated_instances)
58
58
  list_of_nonterminated_instances.reject {|i| i.master? }
59
59
  end
60
60
  # list all the nonterminated instances
@@ -73,7 +73,7 @@ module PoolParty
73
73
  # If no keypair is passed, select them all
74
74
  def list_of_instances(keyp=nil)
75
75
  key = keyp ? keyp : keypair
76
- describe_instances.select {|a| key ? a[:keypair] == key : true }
76
+ describe_instances.select {|a| key ? a[:keypair] == key : true } if describe_instances
77
77
  end
78
78
  # Instances
79
79
  # Get the master from the cloud
@@ -87,7 +87,7 @@ module PoolParty
87
87
  end
88
88
  # Reset the cache of descriptions
89
89
  def reset!
90
- end
90
+ end
91
91
  def self.included(other)
92
92
  PoolParty.register_remote_base(self.class.to_s.downcase.to_sym)
93
93
  end
@@ -1,38 +1,15 @@
1
1
  module PoolParty
2
2
  class Gem
3
3
 
4
- define_resource(:gem_package) do
4
+ virtual_resource(:gempackage) do
5
5
 
6
- def has_gem_package(opts={})
7
- call_function <<-EOE
8
- gem_package { "#{opts[:package] || opts[:name]}":
9
- source => "#{opts[:source] || "http://gems.github.com" }",
10
- package => "#{opts[:package] || opts[:name]}"
11
- }
12
- EOE
6
+ def loaded
7
+ has_exec(:name => "gem-package-#{name}", :cwd => "/tmp", :path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin") do
8
+ command "gem install --no-ri --no-rdoc #{"--version \"#{version}\"" if respond_to?(:version)} #{"--source \"#{source}\"" if respond_to?(:source)} #{@parent.name}"
9
+ ifnot "gem list --local #{@parent.name} | grep #{@parent.name} #{"| grep #{version}" if respond_to?(:version)}"
10
+ end
13
11
  end
14
12
 
15
- custom_function <<-EOF
16
- define gem_package ($source = "http://gems", $version, $package=false) {
17
- include ruby
18
-
19
- if $version {
20
- exec { "gem-package-$package":
21
- path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin",
22
- cwd => "/tmp",
23
- command => "gem install --source $source --version \"$version\" $package",
24
- unless => "gem list --local $package | grep \"$package\" | grep \"$version\""
25
- }
26
- } else {
27
- exec { "gem-package-$package":
28
- path => "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/var/lib/gems/1.8/bin",
29
- cwd => "/tmp",
30
- command => "gem install --source $source $package",
31
- unless => "gem list --local $package | grep \"$package\"
32
- }
33
- }
34
- }
35
- EOF
36
13
  end
37
14
 
38
15
  end
@@ -0,0 +1,22 @@
1
+ module PoolParty
2
+ class Git
3
+
4
+ virtual_resource(:git) do
5
+
6
+ def loaded
7
+
8
+ has_directory(:name => "#{name}", :path => "#{path}", :user => "#{user || Base.user}")
9
+
10
+ exec({:name => "git-#{name}", :command => (user ? "git clone #{user}@#{source}" : "git clone #{source}")}) do
11
+ cwd "#{path}"
12
+ requires "File[#{name}]"
13
+ end
14
+
15
+ exec(:name => "git-update-#{name}", :cwd => "#{path}") do
16
+ requires "Exec['git-#{name}']"
17
+ end
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -20,21 +20,19 @@ module PoolParty
20
20
  :base_config_directory => "/etc/poolparty",
21
21
  :template_directory => "tmp/templates",
22
22
  :template_path => "/var/lib/puppet/templates",
23
+ :default_specfile_name => "pool.spec",
23
24
  :port => "80",
24
25
  :forwarding_port => "8080",
25
26
  :proxy_mode => "http",
26
27
  :pool_logger_location => File.join(Dir.pwd, "logs"),
27
28
  # EC2 Options
28
- :ami => "ami-4bb05422"
29
+ :ami => "ami-1cd73375"
29
30
  })
30
31
 
31
32
  # Class methods
32
33
  class << self
33
- def actionable_default_options
34
- default_options.merge!({:access_key => self.access_key,:secret_access_key => secret_access_key})
35
- end
36
34
  def options(h={})
37
- @options ||= actionable_default_options.merge(h)
35
+ @options ||= default_options.merge(h)
38
36
  end
39
37
  # Get the access_key
40
38
  def access_key
@@ -46,6 +44,8 @@ module PoolParty
46
44
  def load_keys_from_file
47
45
  @keys ||= get_working_key_file_locations ? YAML::load( open(get_working_key_file_locations).read ) : {}
48
46
  end
47
+ # Store the keys in a yaml format to give the master access
48
+ # So that the master has access to the files
49
49
  def store_keys_in_file
50
50
  unless access_key.nil? || secret_access_key.nil?
51
51
  write_to_file( key_file_locations.first, YAML::dump({:access_key => access_key, :secret_access_key => secret_access_key}))
@@ -62,8 +62,9 @@ module PoolParty
62
62
  # Expected places for the instances.list to be located at on the machine
63
63
  def key_file_locations
64
64
  [
65
- "#{Base.storage_directory}/.ppkeys",
65
+ ".ppkeys",
66
66
  "#{Base.base_config_directory}/.ppkeys",
67
+ "#{Base.storage_directory}/ppkeys",
67
68
  "~/.ppkeys",
68
69
  "ppkeys"
69
70
  ]
@@ -23,7 +23,7 @@ module PoolParty
23
23
  include PrettyPrinter
24
24
  include Configurable
25
25
  include CloudResourcer
26
- extend CloudResourcer
26
+ # extend CloudResourcer
27
27
  # Net methods
28
28
  include PoolParty::Remote::RemoterBase
29
29
  include Remote
@@ -40,11 +40,12 @@ module PoolParty
40
40
  })
41
41
 
42
42
  def initialize(name, parent, &block)
43
- @name = name
43
+ @name = name
44
+ # store_block(&block)
44
45
  set_parent(parent) if parent
45
- self.instance_eval &block if block_given?
46
+ self.instance_eval &block if block
46
47
  # this can be overridden in the spec, but ec2 is the default
47
- using :ec2
48
+ self.using :ec2
48
49
  end
49
50
 
50
51
  # Keypairs
@@ -60,13 +61,34 @@ module PoolParty
60
61
  options[:keypair] = args.length > 0 ? args[0] : "#{@parent.respond_to?(:name) ? @parent.name : ""}_#{@name}"
61
62
  end
62
63
 
64
+ # Prepare to send the new configuration to the instances
65
+ # First, let's make sure that our base directory is made
66
+ # Then copy the templates that have no other reference in
67
+ # a spec file. Make sure the keys are stored in a file
68
+ # For the master to have access to them
69
+ # Then, send the saved containing cloud instances to give the
70
+ # remote master access to the cloud options that are required
71
+ # for the master to run checks
63
72
  def prepare_to_configuration
64
73
  # clear_base_directory
65
74
  make_base_directory
66
75
  copy_misc_templates
67
76
  Base.store_keys_in_file
77
+ Script.save!
78
+ copy_ssh_key # not my favorite...
68
79
  end
69
80
 
81
+ def copy_ssh_key
82
+ copy_file_to_storage_directory(full_keypair_path)
83
+ end
84
+
85
+ # Build the new poolparty manifest
86
+ # Wrapping all of these requirements into the one
87
+ # poolparty class.
88
+ #
89
+ # TODO: Consider the benefits of moving all the manifest
90
+ # classes to separate files and keeping the containing
91
+ # references in the include
70
92
  def build_and_store_new_config_file
71
93
  @manifest = build_manifest
72
94
  config_file = ::File.join(Base.storage_directory, "poolparty.pp")
@@ -85,7 +107,7 @@ module PoolParty
85
107
 
86
108
  # Configuration files
87
109
  def build_manifest
88
- reset_resources!
110
+ reset_resources!
89
111
  add_poolparty_base_requirements
90
112
 
91
113
  returning Array.new do |str|
@@ -105,6 +127,13 @@ module PoolParty
105
127
  end.join("\n")
106
128
  end
107
129
 
130
+ # To allow the remote instances to do their job,
131
+ # they need a few options to run, these are the required options
132
+ # to be saved on the remote "master" machine
133
+ def minimum_runnable_options
134
+ [:keypair, :minimum_instances, :maximum_instances]
135
+ end
136
+
108
137
  # Add all the poolparty requirements here
109
138
  # NOTE: These are written as plugins in the lib/poolparty/base_packages directory
110
139
  # for examples.
@@ -20,9 +20,9 @@ module PoolParty
20
20
 
21
21
  # Resources for function call
22
22
  class CallFunction < Resource
23
- def initialize(str="", opts={}, &block)
23
+ def initialize(str="", opts={}, parent=self, &block)
24
24
  @str = str
25
- super(opts, &block)
25
+ super(opts, parent, &block)
26
26
  end
27
27
  def to_string(prev="")
28
28
  returning Array.new do |arr|
@@ -32,9 +32,9 @@ module PoolParty
32
32
  end
33
33
 
34
34
  class CustomResource < Resource
35
- def initialize(name=:custom_method, opts={}, &block)
35
+ def initialize(name=:custom_method, opts={}, parent=self, &block)
36
36
  @name = name
37
- super(opts, &block)
37
+ super(opts, parent, &block)
38
38
  end
39
39
 
40
40
  def self.inherited(subclass)
@@ -6,7 +6,6 @@ module PoolParty
6
6
  include Configurable
7
7
  include CloudResourcer
8
8
  include Resources
9
- extend Resources
10
9
 
11
10
  attr_accessor :parent
12
11
  class_inheritable_accessor :name
@@ -22,19 +21,19 @@ module PoolParty
22
21
  def enable
23
22
  end
24
23
 
25
- def method_missing(m, *args, &block)
26
- if block_given?
27
- (args[0].class == self.class) ? args[0].instance_eval(&block) : super
28
- elsif parent && parent.respond_to?(m)
29
- parent.send m, *args, &block
30
- else
31
- get_from_options(m, *args)
32
- end
33
- end
34
-
35
- def get_from_options(m, *args)
36
- args.empty? ? options[m] : options[m] = args[0]
37
- end
24
+ # def method_missing(m, *args, &block)
25
+ # if block_given?
26
+ # (args[0].class == self.class) ? args[0].instance_eval(&block) : super
27
+ # elsif parent && parent.respond_to?(m)
28
+ # parent.send m, *args, &block
29
+ # else
30
+ # get_from_options(m, *args)
31
+ # end
32
+ # end
33
+ #
34
+ # def get_from_options(m, *args)
35
+ # args.empty? ? options[m] : options[m] = args[0]
36
+ # end
38
37
 
39
38
  end
40
39