poolparty 1.3.4 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/VERSION.yml +1 -1
- data/bin/cloud-bootstrap +1 -0
- data/bin/cloud-configure +1 -0
- data/bin/cloud-contract +1 -0
- data/bin/cloud-misc +34 -0
- data/bin/cloud-setup +36 -0
- data/bin/cloud-ssh +4 -1
- data/config/jeweler.rb +4 -3
- data/examples/monitored_cloud.rb +1 -1
- data/examples/thrift/thrift_example.rb +5 -3
- data/examples/vmware.rb +28 -0
- data/lib/cloud_providers/cloud_provider_instance.rb +14 -5
- data/lib/cloud_providers/connections.rb +1 -1
- data/lib/core/file.rb +12 -0
- data/lib/core/object.rb +2 -2
- data/lib/dependency_resolvers/base.rb +1 -1
- data/lib/dependency_resolvers/chef.rb +9 -7
- data/lib/dependency_resolvers/proxy_object.rb +11 -3
- data/lib/mixins/askable.rb +16 -7
- data/lib/poolparty/base.rb +8 -7
- data/lib/poolparty/cloud.rb +77 -7
- data/lib/poolparty/default.rb +1 -0
- data/lib/poolparty/installer.rb +8 -4
- data/lib/poolparty/installers/ec2.rb +75 -5
- data/lib/poolparty/installers/vmware.rb +17 -5
- data/lib/poolparty/plugin.rb +1 -5
- data/lib/poolparty/plugins/apache.rb +10 -7
- data/lib/poolparty/plugins/apache2/base.conf.erb +2 -2
- data/lib/poolparty/plugins/apache2/browser_fixes.conf.erb +1 -1
- data/lib/poolparty/plugins/apache2/passenger_site.rb +2 -2
- data/lib/poolparty/plugins/collectd/templates/collectd.conf.erb +369 -0
- data/lib/poolparty/plugins/collectd.rb +24 -0
- data/lib/poolparty/plugins/hermes.rb +89 -0
- data/lib/poolparty/pool.rb +33 -3
- data/lib/poolparty/resource.rb +32 -18
- data/lib/poolparty/resources/directory.rb +5 -1
- data/lib/poolparty/resources/exec.rb +2 -2
- data/lib/poolparty/resources/file.rb +8 -2
- data/lib/poolparty/resources/gem_package.rb +2 -2
- data/lib/poolparty/resources/line.rb +23 -6
- data/lib/poolparty/resources/mount.rb +2 -2
- data/lib/poolparty/resources/package.rb +2 -2
- data/lib/poolparty/resources/service.rb +2 -2
- data/lib/poolparty/resources/user.rb +2 -2
- data/lib/poolparty/resources/variable.rb +4 -3
- data/lib/poolparty.rb +5 -3
- data/lib/proto/command_interface_handler.rb +17 -1
- data/lib/proto/gen-py/cloudthrift/CommandInterface.pyc +0 -0
- data/lib/proto/gen-py/cloudthrift/__init__.pyc +0 -0
- data/lib/proto/gen-py/cloudthrift/constants.pyc +0 -0
- data/lib/proto/gen-py/cloudthrift/ttypes.pyc +0 -0
- data/lib/proto/gen-py/thrift/Thrift.pyc +0 -0
- data/lib/proto/gen-py/thrift/__init__.pyc +0 -0
- data/lib/proto/gen-py/thrift/protocol/TBinaryProtocol.pyc +0 -0
- data/lib/proto/gen-py/thrift/protocol/TProtocol.pyc +0 -0
- data/lib/proto/gen-py/thrift/protocol/__init__.pyc +0 -0
- data/lib/proto/gen-py/thrift/transport/TSocket.pyc +0 -0
- data/lib/proto/gen-py/thrift/transport/TTransport.pyc +0 -0
- data/lib/proto/gen-py/thrift/transport/__init__.pyc +0 -0
- data/test/lib/dependency_resolvers/chef_test.rb +92 -100
- data/test/lib/poolparty/base_test.rb +13 -0
- data/test/lib/poolparty/cloud_test.rb +50 -2
- data/test/lib/poolparty/monitor_test.rb +2 -2
- data/test/lib/poolparty/resource_test.rb +5 -0
- data/test/lib/poolparty/resources/line_test.rb +3 -3
- data/test/lib/poolparty/resources/service_test.rb +1 -1
- data/test/lib/poolparty/resources/variable_test.rb +33 -10
- data/vendor/gems/net-ssh/CHANGELOG.rdoc +127 -0
- data/vendor/gems/net-ssh/Manifest +104 -0
- data/vendor/gems/net-ssh/README.rdoc +110 -0
- data/vendor/gems/net-ssh/Rakefile +26 -0
- data/vendor/gems/net-ssh/THANKS.rdoc +16 -0
- data/vendor/gems/net-ssh/lib/net/ssh/authentication/agent.rb +176 -0
- data/vendor/gems/net-ssh/lib/net/ssh/authentication/constants.rb +18 -0
- data/vendor/gems/net-ssh/lib/net/ssh/authentication/key_manager.rb +193 -0
- data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/abstract.rb +60 -0
- data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
- data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
- data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/password.rb +39 -0
- data/vendor/gems/net-ssh/lib/net/ssh/authentication/methods/publickey.rb +92 -0
- data/vendor/gems/net-ssh/lib/net/ssh/authentication/pageant.rb +183 -0
- data/vendor/gems/net-ssh/lib/net/ssh/authentication/session.rb +134 -0
- data/vendor/gems/net-ssh/lib/net/ssh/buffer.rb +340 -0
- data/vendor/gems/net-ssh/lib/net/ssh/buffered_io.rb +149 -0
- data/vendor/gems/net-ssh/lib/net/ssh/config.rb +181 -0
- data/vendor/gems/net-ssh/lib/net/ssh/connection/channel.rb +625 -0
- data/vendor/gems/net-ssh/lib/net/ssh/connection/constants.rb +33 -0
- data/vendor/gems/net-ssh/lib/net/ssh/connection/session.rb +596 -0
- data/vendor/gems/net-ssh/lib/net/ssh/connection/term.rb +178 -0
- data/vendor/gems/net-ssh/lib/net/ssh/errors.rb +85 -0
- data/vendor/gems/net-ssh/lib/net/ssh/key_factory.rb +102 -0
- data/vendor/gems/net-ssh/lib/net/ssh/known_hosts.rb +129 -0
- data/vendor/gems/net-ssh/lib/net/ssh/loggable.rb +61 -0
- data/vendor/gems/net-ssh/lib/net/ssh/packet.rb +102 -0
- data/vendor/gems/net-ssh/lib/net/ssh/prompt.rb +93 -0
- data/vendor/gems/net-ssh/lib/net/ssh/proxy/errors.rb +14 -0
- data/vendor/gems/net-ssh/lib/net/ssh/proxy/http.rb +94 -0
- data/vendor/gems/net-ssh/lib/net/ssh/proxy/socks4.rb +70 -0
- data/vendor/gems/net-ssh/lib/net/ssh/proxy/socks5.rb +129 -0
- data/vendor/gems/net-ssh/lib/net/ssh/ruby_compat.rb +7 -0
- data/vendor/gems/net-ssh/lib/net/ssh/service/forward.rb +267 -0
- data/vendor/gems/net-ssh/lib/net/ssh/test/channel.rb +129 -0
- data/vendor/gems/net-ssh/lib/net/ssh/test/extensions.rb +152 -0
- data/vendor/gems/net-ssh/lib/net/ssh/test/kex.rb +44 -0
- data/vendor/gems/net-ssh/lib/net/ssh/test/local_packet.rb +51 -0
- data/vendor/gems/net-ssh/lib/net/ssh/test/packet.rb +81 -0
- data/vendor/gems/net-ssh/lib/net/ssh/test/remote_packet.rb +38 -0
- data/vendor/gems/net-ssh/lib/net/ssh/test/script.rb +157 -0
- data/vendor/gems/net-ssh/lib/net/ssh/test/socket.rb +59 -0
- data/vendor/gems/net-ssh/lib/net/ssh/test.rb +89 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/algorithms.rb +384 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/cipher_factory.rb +80 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/constants.rb +30 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/abstract.rb +78 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/md5.rb +12 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/none.rb +15 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/sha1.rb +13 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/hmac.rb +31 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/identity_cipher.rb +55 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/kex.rb +13 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/openssl.rb +128 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/packet_stream.rb +230 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/server_version.rb +60 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/session.rb +276 -0
- data/vendor/gems/net-ssh/lib/net/ssh/transport/state.rb +201 -0
- data/vendor/gems/net-ssh/lib/net/ssh/verifiers/lenient.rb +30 -0
- data/vendor/gems/net-ssh/lib/net/ssh/verifiers/null.rb +12 -0
- data/vendor/gems/net-ssh/lib/net/ssh/verifiers/strict.rb +53 -0
- data/vendor/gems/net-ssh/lib/net/ssh/version.rb +62 -0
- data/vendor/gems/net-ssh/lib/net/ssh.rb +215 -0
- data/vendor/gems/net-ssh/net-ssh.gemspec +33 -0
- data/vendor/gems/net-ssh/setup.rb +1585 -0
- data/vendor/gems/net-ssh/test/authentication/methods/common.rb +28 -0
- data/vendor/gems/net-ssh/test/authentication/methods/test_abstract.rb +51 -0
- data/vendor/gems/net-ssh/test/authentication/methods/test_hostbased.rb +114 -0
- data/vendor/gems/net-ssh/test/authentication/methods/test_keyboard_interactive.rb +98 -0
- data/vendor/gems/net-ssh/test/authentication/methods/test_password.rb +50 -0
- data/vendor/gems/net-ssh/test/authentication/methods/test_publickey.rb +127 -0
- data/vendor/gems/net-ssh/test/authentication/test_agent.rb +205 -0
- data/vendor/gems/net-ssh/test/authentication/test_key_manager.rb +105 -0
- data/vendor/gems/net-ssh/test/authentication/test_session.rb +93 -0
- data/vendor/gems/net-ssh/test/common.rb +106 -0
- data/vendor/gems/net-ssh/test/configs/eqsign +3 -0
- data/vendor/gems/net-ssh/test/configs/exact_match +8 -0
- data/vendor/gems/net-ssh/test/configs/wild_cards +14 -0
- data/vendor/gems/net-ssh/test/connection/test_channel.rb +452 -0
- data/vendor/gems/net-ssh/test/connection/test_session.rb +488 -0
- data/vendor/gems/net-ssh/test/test_all.rb +6 -0
- data/vendor/gems/net-ssh/test/test_buffer.rb +336 -0
- data/vendor/gems/net-ssh/test/test_buffered_io.rb +63 -0
- data/vendor/gems/net-ssh/test/test_config.rb +84 -0
- data/vendor/gems/net-ssh/test/test_key_factory.rb +67 -0
- data/vendor/gems/net-ssh/test/transport/hmac/test_md5.rb +39 -0
- data/vendor/gems/net-ssh/test/transport/hmac/test_md5_96.rb +25 -0
- data/vendor/gems/net-ssh/test/transport/hmac/test_none.rb +34 -0
- data/vendor/gems/net-ssh/test/transport/hmac/test_sha1.rb +34 -0
- data/vendor/gems/net-ssh/test/transport/hmac/test_sha1_96.rb +25 -0
- data/vendor/gems/net-ssh/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
- data/vendor/gems/net-ssh/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
- data/vendor/gems/net-ssh/test/transport/test_algorithms.rb +302 -0
- data/vendor/gems/net-ssh/test/transport/test_cipher_factory.rb +171 -0
- data/vendor/gems/net-ssh/test/transport/test_hmac.rb +34 -0
- data/vendor/gems/net-ssh/test/transport/test_identity_cipher.rb +40 -0
- data/vendor/gems/net-ssh/test/transport/test_packet_stream.rb +435 -0
- data/vendor/gems/net-ssh/test/transport/test_server_version.rb +57 -0
- data/vendor/gems/net-ssh/test/transport/test_session.rb +315 -0
- data/vendor/gems/net-ssh/test/transport/test_state.rb +173 -0
- metadata +116 -4
- 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
|
data/lib/poolparty/pool.rb
CHANGED
@@ -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
|
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
|
data/lib/poolparty/resource.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module PoolParty
|
2
2
|
class Resource < Base
|
3
3
|
|
4
|
-
|
5
|
-
|
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
|
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
|
-
|
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(
|
60
|
-
|
61
|
-
|
62
|
-
|
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={}
|
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
|
@@ -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
|
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
|
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
|
-
|
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
|
-
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
-
|
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
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|