poolparty 1.3.4 → 1.3.6

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 (174) hide show
  1. data/Rakefile +2 -2
  2. data/VERSION.yml +1 -1
  3. data/bin/cloud-bootstrap +1 -0
  4. data/bin/cloud-configure +1 -0
  5. data/bin/cloud-contract +1 -0
  6. data/bin/cloud-misc +34 -0
  7. data/bin/cloud-setup +36 -0
  8. data/bin/cloud-ssh +4 -1
  9. data/config/jeweler.rb +4 -3
  10. data/examples/monitored_cloud.rb +1 -1
  11. data/examples/thrift/thrift_example.rb +5 -3
  12. data/examples/vmware.rb +28 -0
  13. data/lib/cloud_providers/cloud_provider_instance.rb +14 -5
  14. data/lib/cloud_providers/connections.rb +1 -1
  15. data/lib/core/file.rb +12 -0
  16. data/lib/core/object.rb +2 -2
  17. data/lib/dependency_resolvers/base.rb +1 -1
  18. data/lib/dependency_resolvers/chef.rb +9 -7
  19. data/lib/dependency_resolvers/proxy_object.rb +11 -3
  20. data/lib/mixins/askable.rb +16 -7
  21. data/lib/poolparty/base.rb +8 -7
  22. data/lib/poolparty/cloud.rb +77 -7
  23. data/lib/poolparty/default.rb +1 -0
  24. data/lib/poolparty/installer.rb +8 -4
  25. data/lib/poolparty/installers/ec2.rb +75 -5
  26. data/lib/poolparty/installers/vmware.rb +17 -5
  27. data/lib/poolparty/plugin.rb +1 -5
  28. data/lib/poolparty/plugins/apache.rb +10 -7
  29. data/lib/poolparty/plugins/apache2/base.conf.erb +2 -2
  30. data/lib/poolparty/plugins/apache2/browser_fixes.conf.erb +1 -1
  31. data/lib/poolparty/plugins/apache2/passenger_site.rb +2 -2
  32. data/lib/poolparty/plugins/collectd/templates/collectd.conf.erb +369 -0
  33. data/lib/poolparty/plugins/collectd.rb +24 -0
  34. data/lib/poolparty/plugins/hermes.rb +89 -0
  35. data/lib/poolparty/pool.rb +33 -3
  36. data/lib/poolparty/resource.rb +32 -18
  37. data/lib/poolparty/resources/directory.rb +5 -1
  38. data/lib/poolparty/resources/exec.rb +2 -2
  39. data/lib/poolparty/resources/file.rb +8 -2
  40. data/lib/poolparty/resources/gem_package.rb +2 -2
  41. data/lib/poolparty/resources/line.rb +23 -6
  42. data/lib/poolparty/resources/mount.rb +2 -2
  43. data/lib/poolparty/resources/package.rb +2 -2
  44. data/lib/poolparty/resources/service.rb +2 -2
  45. data/lib/poolparty/resources/user.rb +2 -2
  46. data/lib/poolparty/resources/variable.rb +4 -3
  47. data/lib/poolparty.rb +5 -3
  48. data/lib/proto/command_interface_handler.rb +17 -1
  49. data/lib/proto/gen-py/cloudthrift/CommandInterface.pyc +0 -0
  50. data/lib/proto/gen-py/cloudthrift/__init__.pyc +0 -0
  51. data/lib/proto/gen-py/cloudthrift/constants.pyc +0 -0
  52. data/lib/proto/gen-py/cloudthrift/ttypes.pyc +0 -0
  53. data/lib/proto/gen-py/thrift/Thrift.pyc +0 -0
  54. data/lib/proto/gen-py/thrift/__init__.pyc +0 -0
  55. data/lib/proto/gen-py/thrift/protocol/TBinaryProtocol.pyc +0 -0
  56. data/lib/proto/gen-py/thrift/protocol/TProtocol.pyc +0 -0
  57. data/lib/proto/gen-py/thrift/protocol/__init__.pyc +0 -0
  58. data/lib/proto/gen-py/thrift/transport/TSocket.pyc +0 -0
  59. data/lib/proto/gen-py/thrift/transport/TTransport.pyc +0 -0
  60. data/lib/proto/gen-py/thrift/transport/__init__.pyc +0 -0
  61. data/test/lib/dependency_resolvers/chef_test.rb +92 -100
  62. data/test/lib/poolparty/base_test.rb +13 -0
  63. data/test/lib/poolparty/cloud_test.rb +50 -2
  64. data/test/lib/poolparty/monitor_test.rb +2 -2
  65. data/test/lib/poolparty/resource_test.rb +5 -0
  66. data/test/lib/poolparty/resources/line_test.rb +3 -3
  67. data/test/lib/poolparty/resources/service_test.rb +1 -1
  68. data/test/lib/poolparty/resources/variable_test.rb +33 -10
  69. data/vendor/gems/net-ssh/CHANGELOG.rdoc +127 -0
  70. data/vendor/gems/net-ssh/Manifest +104 -0
  71. data/vendor/gems/net-ssh/README.rdoc +110 -0
  72. data/vendor/gems/net-ssh/Rakefile +26 -0
  73. data/vendor/gems/net-ssh/THANKS.rdoc +16 -0
  74. data/vendor/gems/net-ssh/lib/net/ssh/authentication/agent.rb +176 -0
  75. data/vendor/gems/net-ssh/lib/net/ssh/authentication/constants.rb +18 -0
  76. data/vendor/gems/net-ssh/lib/net/ssh/authentication/key_manager.rb +193 -0
  77. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/abstract.rb +60 -0
  78. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
  79. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
  80. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb +39 -0
  81. data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/publickey.rb +92 -0
  82. data/vendor/gems/net-ssh/lib/net/ssh/authentication/pageant.rb +183 -0
  83. data/vendor/gems/net-ssh/lib/net/ssh/authentication/session.rb +134 -0
  84. data/vendor/gems/net-ssh/lib/net/ssh/buffer.rb +340 -0
  85. data/vendor/gems/net-ssh/lib/net/ssh/buffered_io.rb +149 -0
  86. data/vendor/gems/net-ssh/lib/net/ssh/config.rb +181 -0
  87. data/vendor/gems/net-ssh/lib/net/ssh/connection/channel.rb +625 -0
  88. data/vendor/gems/net-ssh/lib/net/ssh/connection/constants.rb +33 -0
  89. data/vendor/gems/net-ssh/lib/net/ssh/connection/session.rb +596 -0
  90. data/vendor/gems/net-ssh/lib/net/ssh/connection/term.rb +178 -0
  91. data/vendor/gems/net-ssh/lib/net/ssh/errors.rb +85 -0
  92. data/vendor/gems/net-ssh/lib/net/ssh/key_factory.rb +102 -0
  93. data/vendor/gems/net-ssh/lib/net/ssh/known_hosts.rb +129 -0
  94. data/vendor/gems/net-ssh/lib/net/ssh/loggable.rb +61 -0
  95. data/vendor/gems/net-ssh/lib/net/ssh/packet.rb +102 -0
  96. data/vendor/gems/net-ssh/lib/net/ssh/prompt.rb +93 -0
  97. data/vendor/gems/net-ssh/lib/net/ssh/proxy/errors.rb +14 -0
  98. data/vendor/gems/net-ssh/lib/net/ssh/proxy/http.rb +94 -0
  99. data/vendor/gems/net-ssh/lib/net/ssh/proxy/socks4.rb +70 -0
  100. data/vendor/gems/net-ssh/lib/net/ssh/proxy/socks5.rb +129 -0
  101. data/vendor/gems/net-ssh/lib/net/ssh/ruby_compat.rb +7 -0
  102. data/vendor/gems/net-ssh/lib/net/ssh/service/forward.rb +267 -0
  103. data/vendor/gems/net-ssh/lib/net/ssh/test/channel.rb +129 -0
  104. data/vendor/gems/net-ssh/lib/net/ssh/test/extensions.rb +152 -0
  105. data/vendor/gems/net-ssh/lib/net/ssh/test/kex.rb +44 -0
  106. data/vendor/gems/net-ssh/lib/net/ssh/test/local_packet.rb +51 -0
  107. data/vendor/gems/net-ssh/lib/net/ssh/test/packet.rb +81 -0
  108. data/vendor/gems/net-ssh/lib/net/ssh/test/remote_packet.rb +38 -0
  109. data/vendor/gems/net-ssh/lib/net/ssh/test/script.rb +157 -0
  110. data/vendor/gems/net-ssh/lib/net/ssh/test/socket.rb +59 -0
  111. data/vendor/gems/net-ssh/lib/net/ssh/test.rb +89 -0
  112. data/vendor/gems/net-ssh/lib/net/ssh/transport/algorithms.rb +384 -0
  113. data/vendor/gems/net-ssh/lib/net/ssh/transport/cipher_factory.rb +80 -0
  114. data/vendor/gems/net-ssh/lib/net/ssh/transport/constants.rb +30 -0
  115. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/abstract.rb +78 -0
  116. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/md5.rb +12 -0
  117. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
  118. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/none.rb +15 -0
  119. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/sha1.rb +13 -0
  120. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
  121. data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac.rb +31 -0
  122. data/vendor/gems/net-ssh/lib/net/ssh/transport/identity_cipher.rb +55 -0
  123. data/vendor/gems/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
  124. data/vendor/gems/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
  125. data/vendor/gems/net-ssh/lib/net/ssh/transport/kex.rb +13 -0
  126. data/vendor/gems/net-ssh/lib/net/ssh/transport/openssl.rb +128 -0
  127. data/vendor/gems/net-ssh/lib/net/ssh/transport/packet_stream.rb +230 -0
  128. data/vendor/gems/net-ssh/lib/net/ssh/transport/server_version.rb +60 -0
  129. data/vendor/gems/net-ssh/lib/net/ssh/transport/session.rb +276 -0
  130. data/vendor/gems/net-ssh/lib/net/ssh/transport/state.rb +201 -0
  131. data/vendor/gems/net-ssh/lib/net/ssh/verifiers/lenient.rb +30 -0
  132. data/vendor/gems/net-ssh/lib/net/ssh/verifiers/null.rb +12 -0
  133. data/vendor/gems/net-ssh/lib/net/ssh/verifiers/strict.rb +53 -0
  134. data/vendor/gems/net-ssh/lib/net/ssh/version.rb +62 -0
  135. data/vendor/gems/net-ssh/lib/net/ssh.rb +215 -0
  136. data/vendor/gems/net-ssh/net-ssh.gemspec +33 -0
  137. data/vendor/gems/net-ssh/setup.rb +1585 -0
  138. data/vendor/gems/net-ssh/test/authentication/methods/common.rb +28 -0
  139. data/vendor/gems/net-ssh/test/authentication/methods/test_abstract.rb +51 -0
  140. data/vendor/gems/net-ssh/test/authentication/methods/test_hostbased.rb +114 -0
  141. data/vendor/gems/net-ssh/test/authentication/methods/test_keyboard_interactive.rb +98 -0
  142. data/vendor/gems/net-ssh/test/authentication/methods/test_password.rb +50 -0
  143. data/vendor/gems/net-ssh/test/authentication/methods/test_publickey.rb +127 -0
  144. data/vendor/gems/net-ssh/test/authentication/test_agent.rb +205 -0
  145. data/vendor/gems/net-ssh/test/authentication/test_key_manager.rb +105 -0
  146. data/vendor/gems/net-ssh/test/authentication/test_session.rb +93 -0
  147. data/vendor/gems/net-ssh/test/common.rb +106 -0
  148. data/vendor/gems/net-ssh/test/configs/eqsign +3 -0
  149. data/vendor/gems/net-ssh/test/configs/exact_match +8 -0
  150. data/vendor/gems/net-ssh/test/configs/wild_cards +14 -0
  151. data/vendor/gems/net-ssh/test/connection/test_channel.rb +452 -0
  152. data/vendor/gems/net-ssh/test/connection/test_session.rb +488 -0
  153. data/vendor/gems/net-ssh/test/test_all.rb +6 -0
  154. data/vendor/gems/net-ssh/test/test_buffer.rb +336 -0
  155. data/vendor/gems/net-ssh/test/test_buffered_io.rb +63 -0
  156. data/vendor/gems/net-ssh/test/test_config.rb +84 -0
  157. data/vendor/gems/net-ssh/test/test_key_factory.rb +67 -0
  158. data/vendor/gems/net-ssh/test/transport/hmac/test_md5.rb +39 -0
  159. data/vendor/gems/net-ssh/test/transport/hmac/test_md5_96.rb +25 -0
  160. data/vendor/gems/net-ssh/test/transport/hmac/test_none.rb +34 -0
  161. data/vendor/gems/net-ssh/test/transport/hmac/test_sha1.rb +34 -0
  162. data/vendor/gems/net-ssh/test/transport/hmac/test_sha1_96.rb +25 -0
  163. data/vendor/gems/net-ssh/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
  164. data/vendor/gems/net-ssh/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
  165. data/vendor/gems/net-ssh/test/transport/test_algorithms.rb +302 -0
  166. data/vendor/gems/net-ssh/test/transport/test_cipher_factory.rb +171 -0
  167. data/vendor/gems/net-ssh/test/transport/test_hmac.rb +34 -0
  168. data/vendor/gems/net-ssh/test/transport/test_identity_cipher.rb +40 -0
  169. data/vendor/gems/net-ssh/test/transport/test_packet_stream.rb +435 -0
  170. data/vendor/gems/net-ssh/test/transport/test_server_version.rb +57 -0
  171. data/vendor/gems/net-ssh/test/transport/test_session.rb +315 -0
  172. data/vendor/gems/net-ssh/test/transport/test_state.rb +173 -0
  173. metadata +116 -4
  174. data/bin/install-poolparty +0 -20
@@ -0,0 +1,89 @@
1
+ =begin rdoc
2
+ =end
3
+
4
+ module PoolParty
5
+ module Resources
6
+
7
+ class Hermes < Resource
8
+
9
+ default_options(
10
+ :name => nil
11
+ )
12
+
13
+ def after_loaded
14
+ add_unpack
15
+ run_if_needed
16
+ end
17
+
18
+ def after_compile
19
+ run_dependencies
20
+ build_rsync_directory
21
+ end
22
+
23
+ def run_dependencies
24
+ case cloud.platform
25
+ when false
26
+ else
27
+ has_package "erlang-nox"
28
+ has_package "erlang-dev"
29
+ has_package "rrdtool"
30
+ end
31
+ end
32
+
33
+ def build_rsync_directory
34
+ hermes_dir = cloud.tmp_path + "/tmp/hermes"
35
+ FileUtils.mkdir_p(hermes_dir)
36
+ FileUtils.cp(hermes_release_tar_gz, hermes_dir)
37
+ FileUtils.cp(target_system_file, hermes_dir)
38
+ build_nodes_config
39
+ end
40
+
41
+ # write out a conf file listing all of the seed nodes based on the nodes in the cluster
42
+ def build_nodes_config
43
+ etc_poolparty = cloud.tmp_path + "/etc/poolparty"
44
+ FileUtils.mkdir_p(etc_poolparty)
45
+ node_names = cloud.nodes.collect{|n| n.internal_ip || n.dns_name}.compact.collect{|n| "hermes@#{n}"}
46
+ contents = node_names.collect{|n| %Q{"#{n}".}}.join("\n")
47
+ File.open(etc_poolparty + "/seeds.conf", "w") {|f| f.puts contents}
48
+ end
49
+
50
+ def add_unpack
51
+ has_exec "cd /tmp/hermes && escript target_system install hermes-#{hermes_release_version} #{remote_hermes_deployed_dir}",
52
+ :creates => "#{remote_hermes_deployed_dir}/releases/#{hermes_release_version}"
53
+ end
54
+
55
+ def run_if_needed
56
+ has_exec "env GEN_CLUSTER_SEED_CONFIG=/etc/poolparty/seeds.conf #{remote_hermes_deployed_dir}/bin/erl -boot #{remote_hermes_deployed_dir}/releases/#{hermes_release_version}/start -noshell -detached",
57
+ :not_if => "ps aux | grep -v grep | grep hermes | grep beam"
58
+ end
59
+
60
+ private
61
+
62
+ def hermes_release_tar_gz
63
+ `#{hermes_dir}/scripts/most_recent_release tar.gz`.strip
64
+ end
65
+
66
+ def target_system_file
67
+ "#{hermes_dir}/scripts/target_system"
68
+ end
69
+
70
+ def hermes_dir
71
+ PoolParty.lib_dir + "/vendor/erlang/hermes"
72
+ end
73
+
74
+ def remote_hermes_deployed_dir
75
+ "/var/poolparty/hermes"
76
+ end
77
+
78
+ def hermes_release_version
79
+ File.basename(hermes_release_tar_gz).gsub(/hermes-(.*?)\.tar\.gz/, '\1')
80
+ end
81
+
82
+ end
83
+ end
84
+ end
85
+
86
+ # == install
87
+ # upload tar.gz & target_system
88
+ # run target_system unless VERSION exists
89
+ # run erlang: /usr/local/erl-target/bin/erl -boot /usr/local/erl-target/releases/FIRST/start _unless_ already running
@@ -2,6 +2,11 @@ module PoolParty
2
2
 
3
3
  class Pool < DslBase
4
4
 
5
+ default_options(
6
+ :minimum_instances => nil, # minimum_instances default
7
+ :maximum_instances => nil # maximum_instances default
8
+ )
9
+
5
10
  # Freeze the pool_name so we can't modify it at all
6
11
  # call and run instance_eval on the block and then call the after_create callback
7
12
  def initialize(n, &block)
@@ -26,12 +31,25 @@ module PoolParty
26
31
  # Define a cloud by a name and a block
27
32
  def cloud(name, o={}, &block)
28
33
  if block
29
- clouds[name.to_s] ||= PoolParty::Cloud.new(name, o, &block)
34
+ clouds[name.to_s] ||= PoolParty::Cloud.new(name, soakable_options.merge(o), &block)
30
35
  else
31
36
  raise PoolPartyError.new("CloudError", "You must pass a block when defining a cloud")
32
37
  end
33
38
  end
34
39
 
40
+ # Soaked options
41
+ # These are options that can be set on the pool that will be grabbed from the pool
42
+ # that can be set to the cloud.
43
+ # Soakable options:
44
+ # minimum_instances
45
+ # maximum_instances
46
+ def soakable_options
47
+ soaked_options = {}
48
+ soaked_options.merge!(:minimum_instances => minimum_instances) if minimum_instances
49
+ soaked_options.merge!(:maximum_instances => maximum_instances) if maximum_instances
50
+ soaked_options
51
+ end
52
+
35
53
  # Run twice to catch the errors on the first run
36
54
  # TODO: CHANGE ME!
37
55
  def form_clouds
@@ -78,7 +96,7 @@ module PoolParty
78
96
  end
79
97
  end
80
98
 
81
- def self.clouds_dot_rb_dir
99
+ def self.clouds_dot_rb_dir(n=nil)
82
100
  File.dirname(self.clouds_dot_rb_file) if self.clouds_dot_rb_file
83
101
  end
84
102
 
@@ -98,6 +116,7 @@ module PoolParty
98
116
  else
99
117
  find_default_clouds_dot_rb(filename)
100
118
  end
119
+ ENV["CLOUDS_DOT_RB"] = f
101
120
  load_from_file(f)
102
121
  end
103
122
 
@@ -133,7 +152,18 @@ module PoolParty
133
152
  # + sets up the log
134
153
  def self.before_file_load(filepath)
135
154
  $:.unshift(::File.dirname(filepath))
136
- Dir["#{::File.dirname(filepath)}/plugins/*"].each { |plugin_path| $:.unshift(plugin_path) }
155
+ Dir["#{ ::File.dirname(filepath)}/{plugins,lib}/**/*"].each do |plugin_path|
156
+ if File.directory?(plugin_path)
157
+ $:.unshift(plugin_path)
158
+
159
+ ["#{plugin_path}/#{File.basename(plugin_path)}", "#{plugin_path}/lib/#{File.basename(plugin_path)}"].each do |potential|
160
+ require potential if File.exists?(potential)
161
+ end
162
+
163
+ elsif File.file?(plugin_path) && plugin_path.match(/.rb$/)
164
+ require plugin_path
165
+ end
166
+ end
137
167
  end
138
168
 
139
169
  # Call init to the resource methods and init the log
@@ -1,8 +1,8 @@
1
1
  module PoolParty
2
2
  class Resource < Base
3
3
 
4
- attr_reader :exists
5
- attr_reader :meta_notifies, :meta_not_if, :meta_only_if, :meta_subscribes
4
+ attr_accessor :exists
5
+ attr_accessor :meta_notifies, :meta_not_if, :meta_only_if, :meta_subscribes
6
6
  attr_accessor :graph_index
7
7
 
8
8
  default_options(
@@ -12,9 +12,9 @@ module PoolParty
12
12
  :provider => nil
13
13
  )
14
14
 
15
- def initialize(opts={}, extra_opts={}, &block)
16
- @exists = true
17
- super
15
+ def initialize(opts={}, extra_opts={}, exists=true, &block)
16
+ @exists ||= exists
17
+ super(opts, extra_opts, &block)
18
18
  valid?
19
19
  end
20
20
 
@@ -44,7 +44,9 @@ module PoolParty
44
44
  other_resources_hash.each do |k,v|
45
45
  notifies_array = (@meta_notifies[k] ||= [])
46
46
  notifies_array << [v, action_to_take] unless notifies_array.include?([v, action_to_take])
47
- end
47
+ # Implicitly add a require
48
+ # requires(k => v)
49
+ end
48
50
  end
49
51
 
50
52
  def subscribes(other_resources_hash, action_to_take=:reload, at_time=:delayed)
@@ -56,12 +58,19 @@ module PoolParty
56
58
  end
57
59
 
58
60
  # Requires
59
- def requires(other_resources_hsh)
60
- other_resources_hsh.each do |k,v|
61
- current_deps = (dependencies[k] ||= [])
62
- current_deps << v unless current_deps.include?(v)
61
+ def requires(other_resources_obj)
62
+ case other_resources_obj
63
+ when Hash
64
+ other_resources_obj.each do |k,v|
65
+ dependencies[k] ||= []
66
+ dependencies[k] << v unless dependencies[k].include?(v)
67
+ end
68
+ when Array
69
+ other_resources_obj.each do |obj|
70
+ requires(obj)
71
+ end
63
72
  end
64
- end
73
+ end
65
74
 
66
75
  # Not if
67
76
  # If a block is given with the not_if, we assume it is
@@ -79,7 +88,10 @@ module PoolParty
79
88
  # Should this resource exist on the remote systems
80
89
  # which is a lookup of the instance variable
81
90
  # on the instance of the resource
82
- # The default is that the resource DOES exist
91
+ # The default is that the resource DOES exist
92
+ def exists(n=nil)
93
+ @exists
94
+ end
83
95
  alias :exists? :exists
84
96
 
85
97
  # The resource exists in the output and should be created
@@ -102,6 +114,10 @@ module PoolParty
102
114
  def after_compile
103
115
  end
104
116
 
117
+ def after_loaded
118
+ requires parent if parent && !parent.is_a?(PoolParty::Cloud) && !parent.is_a?(PoolParty::Pool)
119
+ end
120
+
105
121
  # Singleton methods
106
122
  # has_name
107
123
  # The has_ and does_not_have methods names
@@ -159,15 +175,13 @@ module PoolParty
159
175
  # PoolParty classes that use Base
160
176
  def self.define_resource(res)
161
177
  Base.class_eval <<-EOE
162
- def has_#{res.has_method_name}(a={},b={},&block)
163
- obj = #{res}.new(a,b,&block)
164
- obj.exists!
178
+ def has_#{res.has_method_name}(a={},b={},e=true, &block)
179
+ obj = #{res}.new(a,b,e,&block)
165
180
  resources << obj
166
181
  obj
167
182
  end
168
- def does_not_have_#{res.has_method_name}(a={},b={},&block)
169
- obj = has_#{res.has_method_name}(a,b,&block)
170
- obj.does_not_exist!
183
+ def does_not_have_#{res.has_method_name}(a={},b={},e=false,&block)
184
+ obj = has_#{res.has_method_name}(a,b,e,&block)
171
185
  obj
172
186
  end
173
187
  def #{res.has_method_name}s
@@ -31,6 +31,10 @@ module PoolParty
31
31
  :group => "root",
32
32
  :recursive => true
33
33
  )
34
+
35
+ def after_loaded
36
+ requires get_user(owner) if owner && owner != "root"
37
+ end
34
38
 
35
39
  def print_to_chef
36
40
  <<-EOE
@@ -47,4 +51,4 @@ end
47
51
  end
48
52
 
49
53
  end
50
- end
54
+ end
@@ -43,7 +43,7 @@ module PoolParty
43
43
  str = 'execute "<%= name %>" do
44
44
  command <%= print_variable(command || name) %>
45
45
  path <%= print_variable(path) %>
46
- action :<%= action ? action : (exists ? :run : :nothing) %>
46
+ action <%= print_variable(action ? action : (exists ? :run : :nothing)) %>
47
47
  '
48
48
  str << " creates <%= print_variable(creates) %>\n" if creates
49
49
  str << " cwd <%= print_variable(cwd) %>\n" if cwd
@@ -58,4 +58,4 @@ str = 'execute "<%= name %>" do
58
58
  end
59
59
 
60
60
  end
61
- end
61
+ end
@@ -38,7 +38,11 @@ module PoolParty
38
38
  :backup => 5,
39
39
  :owner => "root"
40
40
  )
41
-
41
+
42
+ def after_loaded
43
+ requires get_user(owner) if owner && owner != "root"
44
+ end
45
+
42
46
  def self.has_method_name
43
47
  "file"
44
48
  end
@@ -62,6 +66,8 @@ end
62
66
  file = arg.first
63
67
  @template = if File.file?(b = File.expand_path(file))
64
68
  b
69
+ elsif File.file?(c = File.expand_path(File.join(clouds_dot_rb_dir, file)))
70
+ c
65
71
  elsif f = search_in_known_locations(file)
66
72
  f
67
73
  else
@@ -78,4 +84,4 @@ end
78
84
  end
79
85
 
80
86
  end
81
- end
87
+ end
@@ -40,7 +40,7 @@ module PoolParty
40
40
  def print_to_chef
41
41
  str = <<-EOE
42
42
  gem_package "<%= name %>" do
43
- action :<%= (action ? action : (exists ? :install : :remove)) %>
43
+ action <%= print_variable(action ? action : (exists ? :install : :remove)) %>
44
44
  EOE
45
45
  str << " options <%= print_variable(options) %>\n" if options
46
46
  str << " version <%= print_variable(version) %>\n" if version
@@ -52,4 +52,4 @@ EOE
52
52
  end
53
53
 
54
54
  end
55
- end
55
+ end
@@ -32,16 +32,33 @@ module PoolParty
32
32
  end
33
33
 
34
34
  def after_loaded
35
- has_exec "line_in_#{filepath}" do
36
- command "grep -q \'#{line.safe_quote}\' #{filepath} || echo \'#{line.safe_quote}\' >> #{filepath}"
37
- not_if "grep -q \'#{line.safe_quote}\' #{filepath}"
35
+ opts = if exists?
36
+ {:command => "grep -q \'#{line.safe_quote}\' #{filepath} || echo \'#{line.safe_quote}\' >> #{filepath}",
37
+ :not_if => "grep -q \'#{line.safe_quote}\' #{filepath}"}
38
+ else
39
+ {:command => "cat #{filepath} | grep -v \'#{line.safe_quote}\' > tempfile && mv tempfile #{filepath}",
40
+ :only_if => "grep -q \'#{line.safe_quote}\' #{filepath}"}
41
+ end
42
+
43
+ opts.merge!(:name => exists? ? "line in #{filepath}" : "no line in #{filepath}")
44
+
45
+ e = has_exec opts
46
+
47
+ # Not incredibly pretty.
48
+ # {:file => [["pool_name", :reload]]}
49
+ # TODO: Find an alternative
50
+ e.meta_notifies = meta_notifies if meta_notifies
51
+ e.meta_subscribes = meta_subscribes if meta_subscribes
52
+
53
+ # TODO: Figure out better solution
54
+ deps = @dependencies
55
+ e.instance_eval do
56
+ @dependencies = deps
38
57
  end
39
58
  end
40
59
 
41
60
  def print_to_chef
42
- <<-EOE
43
- # line in file: <%= filepath %>
44
- EOE
61
+ :no_print
45
62
  end
46
63
 
47
64
  end
@@ -40,7 +40,7 @@ module PoolParty
40
40
  def print_to_chef
41
41
  str = <<-EOE
42
42
  mount "<%= name %>" do
43
- action :<%= (action ? action : (exists ? :mount : :unmount)) %>
43
+ action <%= print_variable(action ? action : (exists ? :mount : :unmount)) %>
44
44
  device_type <%= print_variable(device_type) %>
45
45
  EOE
46
46
  str << " device <%= print_variable(device) %>\n" if device
@@ -54,4 +54,4 @@ EOE
54
54
  end
55
55
 
56
56
  end
57
- end
57
+ end
@@ -40,7 +40,7 @@ module PoolParty
40
40
  def print_to_chef
41
41
  str = <<-EOE
42
42
  package "<%= name %>" do
43
- action :<%= (action ? action : (exists ? :install : :remove)) %>
43
+ action <%= print_variable(action ? action : (exists ? :install : :remove)) %>
44
44
  EOE
45
45
  str << " options <%= print_variable(options) %>\n" if options
46
46
  str << " version <%= print_variable(version) %>\n" if version
@@ -52,4 +52,4 @@ EOE
52
52
  end
53
53
 
54
54
  end
55
- end
55
+ end
@@ -39,7 +39,7 @@ module PoolParty
39
39
  def print_to_chef
40
40
  str = 'service "<%= name %>" do
41
41
  pattern <%= print_variable(pattern || name) %>
42
- action :<%= action ? print_variable(action) : (exists ? :enable : :disable) %>
42
+ action <%= print_variable(action ? action : (exists ? :enable : :disable)) %>
43
43
  '
44
44
  str << " running <%= print_variable(running) %>\n" if running
45
45
  str << " start_command <%= print_variable(start_command) %>\n" if start_command
@@ -55,4 +55,4 @@ str = 'service "<%= name %>" do
55
55
  end
56
56
 
57
57
  end
58
- end
58
+ end
@@ -44,7 +44,7 @@ module PoolParty
44
44
 
45
45
  def print_to_chef
46
46
  str = 'user "<%= name %>" do
47
- action :<%= action ? print_variable(action) : (exists ? :create : :remove) %>
47
+ action <%= print_variable(action ? action : (exists ? :create : :remove)) %>
48
48
  '
49
49
  str << " comment <%= print_variable(comment) %>\n" if comment
50
50
  str << " uid <%= print_variable(uid) %>\n" if uid
@@ -60,4 +60,4 @@ str = 'user "<%= name %>" do
60
60
  end
61
61
 
62
62
  end
63
- end
63
+ end
@@ -33,7 +33,7 @@ module PoolParty
33
33
  :value => nil
34
34
  )
35
35
 
36
- def initialize(k, v=nil)
36
+ def initialize(k, v=nil, exists=true)
37
37
  case k
38
38
  when Hash
39
39
  super
@@ -41,7 +41,7 @@ module PoolParty
41
41
  if value.is_a?(Hash)
42
42
  super(v.merge(:name => k))
43
43
  else
44
- super(:name => k, :value => v)
44
+ super({:name => k, :value => v})
45
45
  end
46
46
  end
47
47
  end
@@ -51,7 +51,8 @@ module PoolParty
51
51
  def print_to_chef
52
52
  # Variable
53
53
  # TODO: Variable => <%= name %>
54
- "poolparty[:#{name}] = #{value}"
54
+ # "poolparty[:#{name}] = #{value}"
55
+ :no_print
55
56
  end
56
57
 
57
58
  end
data/lib/poolparty.rb CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  t=Time.now
4
4
 
5
5
  # Load system gems
6
- %w(rubygems logger erb net/ssh open-uri).each do |lib|
6
+ %w(rubygems logger erb open-uri).each do |lib|
7
7
  require lib
8
8
  end
9
9
 
@@ -11,7 +11,7 @@ end
11
11
  Dir[File.dirname(__FILE__)+"/../vendor/gems/*"].each {|lib| $LOAD_PATH.unshift(File.expand_path("#{lib}/lib")) }
12
12
 
13
13
  # Load local gems
14
- %w(dslify parenting json daemons).each do |dep|
14
+ %w(dslify parenting json daemons net/ssh).each do |dep|
15
15
  require dep
16
16
  end
17
17
 
@@ -43,7 +43,9 @@ require "poolparty/pool_party_error"
43
43
  hash
44
44
  symbol
45
45
  proc
46
- time).each do |lib|
46
+ time
47
+ file
48
+ ).each do |lib|
47
49
  require "core/#{lib}"
48
50
  end
49
51
 
@@ -6,7 +6,23 @@ class CommandInterfaceHandler
6
6
  cr.command = command
7
7
  resp = begin
8
8
  the_cloud = clouds[cld.name]
9
- the_cloud ? the_cloud.send(command.to_sym, *args) : "Cloud not found: #{cld.name}"
9
+ if the_cloud
10
+ if command.include?(".")
11
+ command.split(".").inject([]) do |sum, cmd|
12
+ if cmd.match(/\((.*)\)/)
13
+ args = $1
14
+ new_cmd = cmd.gsub(args, '').gsub(/\(\)/, '')
15
+ sum = arr.send(new_cmd.to_sym, *args)
16
+ else
17
+ sum = arr.send(cmd)
18
+ end
19
+ end
20
+ else
21
+ the_cloud.send(command.to_sym, *args)
22
+ end
23
+ else
24
+ "Cloud not found: #{cld.name}"
25
+ end
10
26
  rescue Exception => e
11
27
  cr.response = "Error: #{e.inspect}"
12
28
  end
Binary file
Binary file