auser-poolparty 0.2.9 → 0.2.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/Manifest.txt +33 -4
  2. data/PostInstall.txt +3 -1
  3. data/bin/cloud-provision +8 -4
  4. data/bin/cloud-start +2 -0
  5. data/bin/server-get-load +29 -0
  6. data/bin/server-list-active +1 -1
  7. data/bin/server-rerun +24 -0
  8. data/config/requirements.rb +1 -1
  9. data/lib/erlang/messenger/Makefile +15 -0
  10. data/lib/erlang/messenger/README +5 -0
  11. data/lib/erlang/messenger/Rakefile +39 -0
  12. data/lib/erlang/messenger/control +11 -0
  13. data/lib/erlang/messenger/ebin/erl_crash.dump +12138 -0
  14. data/lib/erlang/messenger/ebin/load_app.beam +0 -0
  15. data/lib/erlang/messenger/ebin/pm_master.beam +0 -0
  16. data/lib/erlang/messenger/ebin/pm_master_supervisor.beam +0 -0
  17. data/lib/erlang/messenger/ebin/pm_node.beam +0 -0
  18. data/lib/erlang/messenger/ebin/pm_node_supervisor.beam +0 -0
  19. data/lib/erlang/messenger/lib/load_app.app +18 -0
  20. data/lib/erlang/messenger/src/load_app.erl +26 -0
  21. data/lib/erlang/messenger/src/pm_cluster.erl +31 -0
  22. data/lib/erlang/messenger/src/pm_master.erl +27 -0
  23. data/lib/erlang/messenger/src/pm_master_supervisor.erl +8 -0
  24. data/lib/erlang/messenger/src/pm_node.erl +79 -0
  25. data/lib/erlang/messenger/src/pm_node_supervisor.erl +33 -0
  26. data/lib/poolparty.rb +9 -6
  27. data/lib/poolparty/base_packages/haproxy.rb +9 -2
  28. data/lib/poolparty/base_packages/heartbeat.rb +31 -30
  29. data/lib/poolparty/base_packages/poolparty.rb +30 -17
  30. data/lib/poolparty/base_packages/ruby.rb +1 -2
  31. data/lib/poolparty/core/array.rb +2 -2
  32. data/lib/poolparty/core/hash.rb +16 -2
  33. data/lib/poolparty/core/string.rb +1 -1
  34. data/lib/poolparty/core/symbol.rb +2 -2
  35. data/lib/poolparty/dependency_resolutions/base.rb +12 -0
  36. data/lib/poolparty/dependency_resolutions/puppet.rb +49 -0
  37. data/lib/poolparty/helpers/display.rb +3 -3
  38. data/lib/poolparty/helpers/provisioner_base.rb +6 -6
  39. data/lib/poolparty/helpers/provisioners/master.rb +21 -21
  40. data/lib/poolparty/helpers/provisioners/slave.rb +4 -3
  41. data/lib/poolparty/modules/definable_resource.rb +1 -0
  42. data/lib/poolparty/modules/file_writer.rb +11 -18
  43. data/lib/poolparty/modules/method_missing_sugar.rb +1 -1
  44. data/lib/poolparty/modules/pretty_printer.rb +11 -11
  45. data/lib/poolparty/modules/resourcing_dsl.rb +57 -0
  46. data/lib/poolparty/monitors/base_monitor.rb +17 -3
  47. data/lib/poolparty/monitors/monitors/cpu_monitor.rb +15 -0
  48. data/lib/poolparty/monitors/monitors/memory_monitor.rb +23 -0
  49. data/lib/poolparty/net/remote_instance.rb +5 -0
  50. data/lib/poolparty/net/remoter.rb +12 -2
  51. data/lib/poolparty/net/remoter_base.rb +5 -1
  52. data/lib/poolparty/plugins/git.rb +24 -15
  53. data/lib/poolparty/pool/base.rb +1 -2
  54. data/lib/poolparty/pool/cloud.rb +14 -9
  55. data/lib/poolparty/pool/custom_resource.rb +6 -6
  56. data/lib/poolparty/pool/resource.rb +53 -104
  57. data/lib/poolparty/pool/resources/class_package.rb +4 -4
  58. data/lib/poolparty/pool/resources/conditional.rb +5 -1
  59. data/lib/poolparty/pool/resources/gem.rb +22 -8
  60. data/lib/poolparty/pool/resources/symlink.rb +10 -6
  61. data/lib/poolparty/pool/resources/variable.rb +1 -1
  62. data/lib/poolparty/templates/ha.cf +3 -3
  63. data/lib/poolparty/templates/haproxy.conf +3 -3
  64. data/lib/poolparty/templates/puppet.conf +1 -1
  65. data/lib/poolparty/version.rb +1 -1
  66. data/poolparty.gemspec +7 -5
  67. data/setup.rb +3 -3
  68. data/spec/poolparty/core/hash_spec.rb +19 -1
  69. data/spec/poolparty/dependency_resolutions/base_spec.rb +11 -0
  70. data/spec/poolparty/modules/file_writer_spec.rb +9 -0
  71. data/spec/poolparty/monitors/base_monitor_spec.rb +19 -0
  72. data/spec/poolparty/monitors/monitors/cpu_monitor_spec.rb +17 -0
  73. data/spec/poolparty/net/remote_instance_spec.rb +6 -1
  74. data/spec/poolparty/net/remoter_spec.rb +2 -1
  75. data/spec/poolparty/pool/cloud_spec.rb +15 -1
  76. data/spec/poolparty/pool/custom_resource_spec.rb +2 -2
  77. data/spec/poolparty/pool/plugin_spec.rb +4 -4
  78. data/spec/poolparty/pool/resource_spec.rb +39 -1
  79. data/spec/poolparty/pool/resources/gem_spec.rb +30 -3
  80. data/spec/poolparty/pool/resources/symlink_spec.rb +4 -1
  81. data/spec/poolparty/spec_helper.rb +1 -0
  82. data/website/index.html +1 -1
  83. metadata +40 -7
  84. data/lib/erlang/eb_server.erl +0 -27
  85. data/lib/poolparty/plugins/gem_package.rb +0 -30
  86. data/lib/poolparty/puppet_plugins/poolparty/plugins/puppet/parser/functions/activenodeips.rb +0 -11
  87. data/lib/poolparty/puppet_plugins/poolparty/plugins/puppet/parser/functions/activenodenames.rb +0 -11
@@ -12,14 +12,28 @@ class Hash
12
12
  o.keys.each {|k| self.delete(k) }
13
13
  o
14
14
  end
15
+ def append(other_hash)
16
+ returning Hash.new do |h|
17
+ h.merge!(self)
18
+ other_hash.each do |k,v|
19
+ h[k] = has_key?(k) ? [self[k], v].flatten : v
20
+ end
21
+ end
22
+ end
23
+ def append!(other_hash)
24
+ other_hash.each do |k,v|
25
+ self[k] = has_key?(k) ? [self[k], v].flatten : v
26
+ end
27
+ self
28
+ end
15
29
  def safe_merge(other_hash)
16
30
  merge(other_hash.delete_if {|k,v| has_key?(k) })
17
31
  end
18
32
  def safe_merge!(other_hash)
19
33
  merge!(other_hash.delete_if {|k,v| has_key?(k) && !v.nil? })
20
34
  end
21
- def flush_out(prev="", post="")
22
- map {|k,v| "#{prev}#{k} => #{v.to_option_string}#{post}"}
35
+ def flush_out(pre="", post="")
36
+ map {|k,v| "#{pre}#{k} => #{v.to_option_string}#{post}"}
23
37
  end
24
38
  def to_os
25
39
  m={}
@@ -25,7 +25,7 @@ class String
25
25
  self.split("::")[-1].downcase rescue self
26
26
  end
27
27
  def sanitize
28
- self.gsub(/[\.]*/, '')
28
+ self.gsub(/[\.\/]*/, '')
29
29
  end
30
30
  def nice_runnable(quite=true)
31
31
  self.split(/ && /).join("\n")
@@ -1,6 +1,6 @@
1
1
  class Symbol
2
- def to_string(prev="")
3
- "#{prev}#{self.to_s}"
2
+ def to_string(pre="")
3
+ "#{pre}#{self.to_s}"
4
4
  end
5
5
  def sanitize
6
6
  self.to_s.sanitize
@@ -0,0 +1,12 @@
1
+ module PoolParty
2
+ module DependencyResolutions
3
+ module Base
4
+
5
+ def to_s
6
+ end
7
+ def to_string
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,49 @@
1
+ module PoolParty
2
+ module DependencyResolutions
3
+ module Puppet
4
+
5
+ def pretty_print_resources(pre=" ")
6
+ returning Array.new do |out|
7
+ resources.each do |name, res|
8
+ out << "#{pre}#{name}"
9
+ out << "#{pre*2}#{res.map {|a| a.name}}"
10
+ res.each do |r|
11
+ out << "#{pre*2}#{r.pretty_print_resources(pre*2)}"
12
+ end
13
+ end
14
+ end.join("\n")
15
+ end
16
+
17
+ # Generic to_s
18
+ # Most Resources won't need to extend this
19
+ def to_string(pre="")
20
+ opts = get_modified_options
21
+ returning Array.new do |output|
22
+ unless cancelled?
23
+ output << @prestring || ""
24
+
25
+ if resources && !resources.empty?
26
+ @cp = classpackage_with_self(self)
27
+ output << @cp.to_string
28
+ output << "include #{@cp.name.sanitize}"
29
+ end
30
+
31
+ unless virtual_resource?
32
+ output << "#{pre}#{class_type_name.downcase} {"
33
+ output << "#{pre}\"#{self.key}\":"
34
+ output << opts.flush_out("#{pre*2}").join(",\n")
35
+ output << "#{pre}}"
36
+ end
37
+
38
+ output << @poststring || ""
39
+ end
40
+ end.join("\n")
41
+ end
42
+
43
+ def to_s
44
+ "#{class_type_name.capitalize}['#{key}']"
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -7,10 +7,10 @@ module PoolParty
7
7
  print v.pretty_print
8
8
  end
9
9
  else
10
- prev = "\t"
10
+ pre = "\t"
11
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")
12
+ puts cl.pretty_name(pre*2, cl)
13
+ puts cl.pretty_options(pre*2, cl) #cl.pretty_print("#{pre}\t")
14
14
  end
15
15
  end
16
16
 
@@ -17,7 +17,7 @@ module PoolParty
17
17
  end
18
18
 
19
19
  def self.provision_slaves(cloud, testing=false)
20
- cloud.nonmaster_nonterminated_instances.each do |sl|
20
+ cloud.nonmaster_nonterminated_instances.each do |sl|
21
21
  provision_slave(sl, cloud, testing)
22
22
  end
23
23
  end
@@ -53,7 +53,7 @@ module PoolParty
53
53
  loaded
54
54
  end
55
55
  # Callback after initialized
56
- def loaded
56
+ def loaded(opts={}, parent=self)
57
57
  end
58
58
  # This is the actual runner for the installation
59
59
  def install
@@ -71,10 +71,11 @@ module PoolParty
71
71
  setup_runner(@cloud)
72
72
 
73
73
  unless testing
74
- puts "Logging on to #{@instance.ip}"
74
+ logger.debug "Logging on to #{@instance.ip}"
75
+ @cloud.prepare_reconfiguration
75
76
  @cloud.rsync_storage_files_to(@instance)
76
77
 
77
- cmd = "cd #{Base.remote_storage_path}/#{Base.tmp_path} && chmod +x install_#{name}.sh && /bin/sh install_#{name}.sh && rm install_#{name}.sh"
78
+ cmd = "cd #{Base.remote_storage_path} && chmod +x install_#{name}.sh && /bin/sh install_#{name}.sh && rm install_#{name}.sh"
78
79
  hide_output do
79
80
  @cloud.run_command_on(cmd, @instance)
80
81
  end
@@ -96,7 +97,7 @@ module PoolParty
96
97
  unless testing
97
98
  @cloud.rsync_storage_files_to(@instance)
98
99
 
99
- cmd = "cd #{Base.remote_storage_path}/#{Base.tmp_path} && chmod +x configure_#{name}.sh && /bin/sh configure_#{name}.sh && rm configure_#{name}.sh"
100
+ cmd = "cd #{Base.remote_storage_path} && chmod +x configure_#{name}.sh && /bin/sh configure_#{name}.sh && rm configure_#{name}.sh"
100
101
  @cloud.run_command_on(cmd, @instance)
101
102
  end
102
103
  end
@@ -230,7 +231,6 @@ module PoolParty
230
231
  touch /etc/apt/sources.list
231
232
  echo 'deb http://mirrors.kernel.org/ubuntu hardy main universe' >> /etc/apt/sources.list
232
233
  apt-get update --fix-missing -y
233
- apt-get upgrade -y
234
234
  "
235
235
  else
236
236
  "# No system upgrade needed"
@@ -29,10 +29,9 @@ module PoolParty
29
29
 
30
30
  def configure_tasks
31
31
  [
32
- start_puppetmaster,
32
+ # start_puppetmaster,
33
33
  create_local_node,
34
34
  move_templates,
35
- move_plugins,
36
35
  create_poolparty_manifest,
37
36
  restart_puppetd
38
37
  ]
@@ -53,7 +52,7 @@ echo "import 'nodes/*.pp'" > /etc/puppet/manifests/site.pp
53
52
  echo "import 'classes/*.pp'" >> /etc/puppet/manifests/site.pp
54
53
  mkdir -p /etc/puppet/manifests/nodes
55
54
  mkdir -p /etc/puppet/manifests/classes
56
- cp #{Base.remote_storage_path}/#{Base.tmp_path}/namespaceauth.conf /etc/puppet/namespaceauth.conf
55
+ cp #{Base.remote_storage_path}/namespaceauth.conf /etc/puppet/namespaceauth.conf
57
56
  EOS
58
57
  end
59
58
 
@@ -67,7 +66,7 @@ echo "#{open(File.join(template_directory, "puppet.conf")).read}" > /etc/puppet/
67
66
  <<-EOS
68
67
  echo "
69
68
  [files]
70
- path #{Base.remote_storage_path}/#{Base.tmp_path}
69
+ path #{Base.remote_storage_path}
71
70
  allow *" > /etc/puppet/fileserver.conf
72
71
  mkdir -p /var/poolparty/facts
73
72
  mkdir -p /var/poolparty/files
@@ -102,35 +101,36 @@ cp #{Base.remote_storage_path}/#{Base.template_directory}/* #{Base.template_path
102
101
  EOS
103
102
  end
104
103
 
105
- def move_plugins
106
- <<-EOS
107
- mkdir -p #{Base.module_path}
108
- cp -R #{Base.remote_storage_path}/#{Base.plugin_directory}/ #{Base.module_path}
109
- mkdir -p /var/lib/puppet/lib/parser/functions/
110
- cp -R #{Base.remote_storage_path}/#{Base.plugin_directory}/puppet/* /var/lib/puppet/lib/parser/functions/
111
- EOS
112
- end
113
-
114
104
  def create_poolparty_manifest
115
105
  <<-EOS
116
- cp #{Base.remote_storage_path}/#{Base.tmp_path}/poolparty.pp /etc/puppet/manifests/classes/poolparty.pp
117
- cp #{Base.remote_storage_path}/#{Base.tmp_path}/#{Base.key_file_locations.first} "#{Base.base_config_directory}/.ppkeys"
118
- cp #{Base.remote_storage_path}/#{Base.tmp_path}/#{Base.default_specfile_name} #{Base.base_config_directory}/#{Base.default_specfile_name}
119
- cp #{Base.remote_storage_path}/#{Base.tmp_path}/#{@cloud.full_keypair_name} #{@cloud.remote_keypair_path}
106
+ cp #{Base.remote_storage_path}/poolparty.pp /etc/puppet/manifests/classes/poolparty.pp
107
+ cp #{Base.remote_storage_path}/#{Base.key_file_locations.first} "#{Base.base_config_directory}/.ppkeys"
108
+ cp #{Base.remote_storage_path}/#{Base.default_specfile_name} #{Base.base_config_directory}/#{Base.default_specfile_name}
109
+ #{copy_ssh_app}
120
110
  EOS
121
111
  end
112
+
113
+ def copy_ssh_app
114
+ if @cloud.remote_keypair_path != "#{Base.remote_storage_path}/#{@cloud.full_keypair_name}"
115
+ "cp #{Base.remote_storage_path}/#{@cloud.full_keypair_name} #{@cloud.remote_keypair_path}"
116
+ end
117
+ end
122
118
 
119
+ # ps aux | grep puppetmasterd | awk '{print $2}' | xargs kill
120
+ # rm -rf /etc/puppet/ssl
121
+ # puppetmasterd --verbose
123
122
  def start_puppetmaster
124
123
  <<-EOS
125
- ps aux | grep puppetmasterd | awk '{print $2}' | xargs kill
126
- rm -rf /etc/puppet/ssl
127
- puppetmasterd --verbose
128
124
  EOS
129
125
  end
130
126
 
127
+ # puppetd --listen --fqdn #{@instance.name}
131
128
  def restart_puppetd
132
129
  <<-EOS
133
- puppetd --listen --fqdn #{@instance.name}
130
+ killall ruby
131
+ rm -rf /etc/puppet/ssl/*
132
+ puppetmasterd --verbose
133
+ . /etc/profile && #{@instance.puppet_runner_command}
134
134
  EOS
135
135
  end
136
136
  end
@@ -18,7 +18,7 @@ module PoolParty
18
18
  def setup_puppet
19
19
  <<-EOE
20
20
  if [ -z "$(grep -v '#' /etc/hosts | grep 'master')" ]; then echo "#{master_ip} puppet master" >> /etc/hosts; else echo "host already set"; fi
21
- cp #{Base.remote_storage_path}/#{Base.tmp_path}/namespaceauth.conf /etc/puppet/namespaceauth.conf
21
+ cp #{Base.remote_storage_path}/namespaceauth.conf /etc/puppet/namespaceauth.conf
22
22
  EOE
23
23
  end
24
24
 
@@ -28,10 +28,11 @@ module PoolParty
28
28
  EOS
29
29
  end
30
30
 
31
+ # /etc/init.d/puppetmasterd stop
32
+ # puppetd --listen --fqdn #{@instance.name}
31
33
  def start_puppet
32
34
  <<-EOS
33
- /etc/init.d/puppetmasterd stop
34
- puppetd --listen --fqdn #{@instance.name}
35
+ rm -rf /etc/puppet/ssl*
35
36
  EOS
36
37
  end
37
38
 
@@ -52,6 +52,7 @@ module PoolParty
52
52
  klass = "PoolParty::Resources::#{symc}".constantize
53
53
  klass.module_eval &block if block
54
54
  klass.send :define_method, :virtual_resource?, Proc.new{true}
55
+ klass.send :define_method, :printable?, Proc.new{false}
55
56
  klass
56
57
  end
57
58
 
@@ -1,26 +1,21 @@
1
1
  module PoolParty
2
2
  module FileWriter
3
- def copy_file_to_storage_directory(file)
3
+ def copy_file_to_storage_directory(file, preceded="")
4
4
  make_base_directory
5
- path = ::File.join( Base.storage_directory, ::File.basename(file) )
6
- FileUtils.cp file, path
5
+ path = ::File.join( Base.storage_directory, preceded, ::File.basename(file) )
6
+ FileUtils.cp file, path unless file == path || ::File.exists?(path)
7
7
  end
8
8
  def copy_template_to_storage_directory(file)
9
9
  make_template_directory
10
- path = ::File.join( Base.template_directory, ::File.basename(file) )
11
- FileUtils.cp file, path
10
+ path = ::File.join( Base.tmp_path, Base.template_directory, ::File.basename(file) )
11
+ FileUtils.cp file, path unless file == path || ::File.exists?(path)
12
12
  end
13
- def copy_plugin_to_storage_directory(file)
14
- make_plugin_directory
15
- path = ::File.join( Base.plugin_directory, ::File.basename(file) )
16
- FileUtils.cp file, path
17
- end
18
- def write_to_file_in_storage_directory(file, str, &block)
19
- path = ::File.join( Base.storage_directory, ::File.basename(file) )
13
+ def write_to_file_in_storage_directory(file, str, preceded="", &block)
14
+ path = ::File.join( Base.storage_directory, preceded, ::File.basename(file) )
20
15
  write_to_file(path, str, &block)
21
16
  end
22
- def write_to_file(file, str, &block)
23
- path = ::File.join( Base.storage_directory, ::File.basename(file) )
17
+ def write_to_file(file, str, preceded="", &block)
18
+ path = ::File.join( Base.storage_directory, preceded, ::File.basename(file) )
24
19
  make_base_path( Base.storage_directory )
25
20
  ::File.open(path, "w+") do |f|
26
21
  f.print str
@@ -51,10 +46,8 @@ module PoolParty
51
46
  FileUtils.mkdir_p Base.storage_directory unless ::File.directory?(Base.storage_directory)
52
47
  end
53
48
  def make_template_directory
54
- FileUtils.mkdir_p Base.template_directory unless ::File.directory?(Base.template_directory)
55
- end
56
- def make_plugin_directory
57
- FileUtils.mkdir_p Base.plugin_directory unless ::File.directory?(Base.plugin_directory)
49
+ path = ::File.join(Base.tmp_path, Base.template_directory)
50
+ FileUtils.mkdir_p path unless ::File.directory?(path)
58
51
  end
59
52
  def clear_base_directory
60
53
  FileUtils::rm_rf "#{Base.storage_directory}"
@@ -42,7 +42,7 @@ module PoolParty
42
42
  if options.has_key?(m)
43
43
  options[m]
44
44
  else
45
- (parent.nil? || parent.class == self.class || !parent.respond_to?(:options)) ? nil : parent.send(m, *args, &block)
45
+ (parent.nil? || parent.class == self.class || !parent.respond_to?(:options) || parent.options.has_key?(m)) ? nil : parent.send(m, *args, &block)
46
46
  end
47
47
  else
48
48
  options[m] = (args.is_a?(Array) && args.size > 1) ? args : args[0]
@@ -1,20 +1,20 @@
1
1
  module PoolParty
2
2
  module PrettyPrinter
3
3
 
4
- def pretty_print(prev="\t")
4
+ def pretty_print(pre="\t")
5
5
  returning Array.new do |out|
6
- out << pretty_name(prev, self)
7
- out << pretty_options(prev, self)
6
+ out << pretty_name(pre, self)
7
+ out << pretty_options(pre, self)
8
8
 
9
9
  if self.respond_to?(:clouds)
10
10
  clouds.each do |name, cl|
11
- out << pretty_name(prev*2, cl)
12
- out << pretty_options(prev*2, cl) #cl.pretty_print("#{prev}\t")
11
+ out << pretty_name(pre*2, cl)
12
+ out << pretty_options(pre*2, cl) #cl.pretty_print("#{pre}\t")
13
13
  end
14
14
  end
15
15
  if self.respond_to?(:plugins)
16
- out << "#{prev}\t\tPlugins"
17
- out << "#{prev}\t\t" + plugins.map {|a| a}.join("\n")
16
+ out << "#{pre}\t\tPlugins"
17
+ out << "#{pre}\t\t" + plugins.map {|a| a}.join("\n")
18
18
  end
19
19
  end.join("\n")
20
20
  end
@@ -22,17 +22,17 @@ module PoolParty
22
22
  # Gather options on the object
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
- def pretty_options(prev, o)
25
+ def pretty_options(pre, o)
26
26
  return "" unless o.respond_to?(:options)
27
27
  print_options = (o.respond_to?(:parent) && o.parent && o.parent.respond_to?(:options)) ?
28
28
  (o.options.delete_if {|k,v| o.parent.options.has_key?(k) && o.parent.options[k] == o.options[k] && !o.options[k].nil? } ) :
29
29
  o.options
30
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 }
31
- print_options.flush_out("#{prev}\t")
31
+ print_options.flush_out("#{pre}\t")
32
32
  end
33
33
 
34
- def pretty_name(prev, o)
35
- "#{prev}#{o.class.to_s.top_level_class.capitalize}: #{o.name if o.respond_to?(:name)}"
34
+ def pretty_name(pre, o)
35
+ "#{pre}#{o.class.to_s.top_level_class.capitalize}: #{o.name if o.respond_to?(:name)}"
36
36
  end
37
37
 
38
38
  end
@@ -0,0 +1,57 @@
1
+ module PoolParty
2
+ module ResourcingDsl
3
+ # Overrides for syntax
4
+ # Allows us to send require to require a resource
5
+ def require(str="")
6
+ str ? options.merge!(:require => str) : options[:require]
7
+ end
8
+ def requires(str=nil)
9
+ str ? options.append!(:require => str) : options[:require]
10
+ end
11
+ def ensures(str="running")
12
+ if %w(absent running).map {|a| self.send a.to_sym}.include?(str)
13
+ str == "absent" ? is_absent : is_present
14
+ else
15
+ options.append!(:ensure => str)
16
+ end
17
+ str
18
+ end
19
+ # Allows us to send an ensure to ensure the presence of a resource
20
+ def is_present(*args)
21
+ options.merge!(:ensure => present)
22
+ end
23
+ # Ensures that what we are sending is absent
24
+ def is_absent(*args)
25
+ options.merge!(:ensure => absent)
26
+ end
27
+ # Alias for unless
28
+ def ifnot(str="")
29
+ options.merge!(:unless => str)
30
+ end
31
+ def present
32
+ "present"
33
+ end
34
+ def absent
35
+ "absent"
36
+ end
37
+ def cancel(*args)
38
+ options[:cancelled] = args.empty? ? true : args[0]
39
+ end
40
+ def cancelled?
41
+ options[:cancelled] || false
42
+ end
43
+ # Give us a template to work with on the resource
44
+ # Make sure this template is moved to the tmp directory as well
45
+ def template(file, opts={})
46
+ raise TemplateNotFound.new("no template given") unless file
47
+ raise TemplateNotFound.new("template cannot be found #{file}") unless ::File.file?(file)
48
+ unless opts[:just_copy]
49
+ options.merge!({:content => "template(\"#{::File.basename(file)}\")"})
50
+ options.delete(:source) if options.has_key?(:source)
51
+ copy_template_to_storage_directory(file)
52
+ else
53
+ copy_file_to_storage_directory(file)
54
+ end
55
+ end
56
+ end
57
+ end