auser-poolparty 1.2.0 → 1.2.1
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.
- data/VERSION.yml +1 -1
- data/bin/cloud-verify +2 -0
- data/bin/install-poolparty +216 -0
- data/lib/poolparty/{aska/aska.rb → aska.rb} +0 -0
- data/lib/poolparty/core/string.rb +11 -0
- data/lib/poolparty/core/symbol.rb +10 -0
- data/lib/poolparty/dependency_resolver/chef_resolver.rb +16 -34
- data/lib/poolparty/dependency_resolver/dependency_resolver_cloud_extensions.rb +4 -4
- data/lib/poolparty/dependency_resolver/puppet_resolver.rb +15 -27
- data/lib/poolparty/lite.rb +1 -1
- data/lib/poolparty/modules/searchable_paths.rb +91 -0
- data/lib/poolparty/net/init.rb +0 -1
- data/lib/poolparty/net/remote_bases.rb +0 -1
- data/lib/poolparty/net/remoter_base.rb +5 -0
- data/lib/poolparty/net/remoter_bases/ec2/ec2.rb +3 -1
- data/lib/poolparty/plugins/apache2/apache.rb +340 -0
- data/lib/poolparty/plugins/rails_deploy.rb +76 -0
- data/lib/poolparty/poolparty/default.rb +1 -0
- data/lib/poolparty/poolparty/plugin.rb +4 -1
- data/lib/poolparty/poolparty/poolparty_base_class.rb +2 -4
- data/lib/poolparty/poolparty/resource.rb +4 -0
- data/lib/poolparty/poolparty/service.rb +8 -0
- data/lib/poolparty/resources/file.rb +3 -3
- data/lib/poolparty/templates/apache2/apache2.conf +14 -0
- data/lib/poolparty/templates/apache2/base.conf.erb +168 -0
- data/lib/poolparty/templates/apache2/browser_fixes.conf.erb +26 -0
- data/lib/poolparty/templates/apache2/debian.conf.erb +675 -0
- data/lib/poolparty/templates/apache2/default-site.conf.erb +41 -0
- data/lib/poolparty/templates/apache2/directory_indexes.conf.erb +101 -0
- data/lib/poolparty/templates/apache2/logging-syslog.conf.erb +42 -0
- data/lib/poolparty/templates/apache2/mime-extras.conf.erb +211 -0
- data/lib/poolparty/templates/apache2/mime-minimal.conf.erb +15 -0
- data/lib/poolparty/templates/apache2/mpm-worker.conf.erb +20 -0
- data/lib/poolparty/templates/apache2/mpm-worker.erb +20 -0
- data/lib/poolparty/templates/apache2/passenger.conf.erb +20 -0
- data/lib/poolparty/templates/apache2/php.ini.erb +1253 -0
- data/lib/poolparty/templates/apache2/server-status.erb +19 -0
- data/lib/poolparty/verification/verifiers/http_match.rb +43 -0
- data/lib/poolparty/verification/verifiers/http_status.rb +59 -0
- data/lib/poolparty/verification/verifiers/ping.rb +13 -1
- data/lib/poolparty.rb +1 -1
- data/lib/poolpartycl.rb +51 -0
- data/spec/poolparty/dependency_resolver/dependency_resolver_cloud_extensions_spec.rb +5 -11
- data/spec/poolparty/modules/searchable_paths_spec.rb +76 -0
- data/spec/poolparty/plugins/git_spec.rb +4 -3
- data/spec/poolparty/poolparty/cloud_spec.rb +3 -19
- data/spec/poolparty/resources/file_spec.rb +1 -0
- data/spec/poolparty/resources/service_spec.rb +1 -1
- data/test/poolparty/dependency_resolver/puppet_resolver_test.rb +5 -11
- data/test/poolparty/poolparty/poolparty_base_class_test.rb +1 -1
- metadata +27 -7
- data/lib/poolparty/plugins/apache2.rb +0 -53
- data/lib/poolparty/plugins/dynomite.rb +0 -14
- data/lib/poolparty/plugins/tokyo_tyrant.rb +0 -23
data/VERSION.yml
CHANGED
data/bin/cloud-verify
CHANGED
@@ -0,0 +1,216 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
|
+
require "poolparty"
|
4
|
+
require "poolpartycl"
|
5
|
+
require "highline/import"
|
6
|
+
|
7
|
+
welcome_msg = <<-EOE
|
8
|
+
We are going to take you through the installation process of PoolParty.
|
9
|
+
|
10
|
+
First, we'll setup your environment so using PoolParty will be a breeze
|
11
|
+
EOE
|
12
|
+
|
13
|
+
closing_message = <<-EOE
|
14
|
+
You are now set to ride the waves with PoolParty! You'll notice there is a clouds.rb file in your current directory. You can start your new cloud
|
15
|
+
by typing:
|
16
|
+
|
17
|
+
cloud start
|
18
|
+
|
19
|
+
You can start your clouds.rb. More samples are available here:
|
20
|
+
http://github.com/auser/poolparty-examples/tree/master
|
21
|
+
EOE
|
22
|
+
|
23
|
+
colored_say "Welcome to PoolParty!", :help
|
24
|
+
say welcome_msg
|
25
|
+
begin
|
26
|
+
t = colored_ask "Press enter to continue or Ctrl+C to exit"
|
27
|
+
rescue Exception => e
|
28
|
+
say <<-EOE
|
29
|
+
|
30
|
+
Cancelled PoolParty installation
|
31
|
+
|
32
|
+
You can always restart this by typing:
|
33
|
+
install-poolparty
|
34
|
+
EOE
|
35
|
+
exit 0
|
36
|
+
end
|
37
|
+
|
38
|
+
say("\nWhat remoter base would you like to use?")
|
39
|
+
choose do |menu|
|
40
|
+
menu.prompt = "> "
|
41
|
+
|
42
|
+
available_bases.each do |base|
|
43
|
+
menu.choice base.to_sym do
|
44
|
+
|
45
|
+
colored_say "Great, we'll be using #{base}"
|
46
|
+
|
47
|
+
case base
|
48
|
+
when :ec2
|
49
|
+
|
50
|
+
key_help_str = <<-EOE
|
51
|
+
Now you need to get your keys from Amazon AWS.
|
52
|
+
If you don't already have your keys setup, navigate to http://aws.amazon.com
|
53
|
+
and click on Your Account. Click on the Access Identifiers tab and find:
|
54
|
+
Your Access Key ID. This is your access key.
|
55
|
+
EOE
|
56
|
+
access_key_str = <<-EOE
|
57
|
+
Since you'll be using ec2, we'll have to set some things up before
|
58
|
+
we can get going on PoolParty. Don't worry, this information will stay between us.
|
59
|
+
|
60
|
+
EOE
|
61
|
+
say access_key_str
|
62
|
+
ask_with_help :message => "First, what's your access key?",
|
63
|
+
:help => key_help_str do |t|
|
64
|
+
|
65
|
+
@access_key = t
|
66
|
+
|
67
|
+
key_help_str = <<-EOE
|
68
|
+
If you don't already have your keys setup, navigate to http://aws.amazon.com
|
69
|
+
and click on Your Account. Click on the Access Identifiers tab and find:
|
70
|
+
Your Secret Access Key ID. Click on the - show button.
|
71
|
+
This is your secret access key.
|
72
|
+
EOE
|
73
|
+
ask_with_help :message => "Awesome. Now what's your secret access key? ",
|
74
|
+
:help => key_help_str do |t|
|
75
|
+
@secret_access_key = t
|
76
|
+
|
77
|
+
rescued_ask_str = <<-EOS
|
78
|
+
Super duper! You'll need to make sure you have yout X.509 certificate downloaded too.
|
79
|
+
Save this in your ~/.ec2 directory.
|
80
|
+
|
81
|
+
Press enter when you're ready
|
82
|
+
EOS
|
83
|
+
|
84
|
+
cert_help_str = <<-EOE
|
85
|
+
To get your X.509 certificates, navigate to http://aws.amazon.com and login. Click on
|
86
|
+
Your Account and scroll down. The X.509 Certificate box is at the bottom. Make sure you
|
87
|
+
click download and save the cert-*.pem file. If you don't know or don't have the pk-*.pem file
|
88
|
+
you may have to recreate it. Not to worry though, it's super easy. Click on the Create New button.
|
89
|
+
From there, you can download the cert-*.pem and the pk-*.pem files.
|
90
|
+
|
91
|
+
EOE
|
92
|
+
|
93
|
+
ask_with_help :message => rescued_ask_str,
|
94
|
+
:help => cert_help_str do |t|
|
95
|
+
|
96
|
+
begin
|
97
|
+
ec2 = PoolParty::Remote::Ec2.ec2({:access_key => @access_key, :secret_access_key => @secret_access_key})
|
98
|
+
keypairs = ec2.describe_keypairs["keySet"]["item"]
|
99
|
+
keynames = keypairs.map {|k| k["keyName"]}
|
100
|
+
rescue Exception => e
|
101
|
+
colored_say "There was an error: #{e}. Recheck your access_key and secret_access_key to make sure you copied them correctly"
|
102
|
+
exit 1
|
103
|
+
end
|
104
|
+
|
105
|
+
key_str =<<-EOK
|
106
|
+
|
107
|
+
Finally, what's the name of the keypair you'd like to use?
|
108
|
+
|
109
|
+
You already have the following keypairs setup:
|
110
|
+
\t#{keynames.join("\n\t")}
|
111
|
+
|
112
|
+
You can use one of these keys, or create a new one.
|
113
|
+
EOK
|
114
|
+
|
115
|
+
key_str_help =<<-EOH
|
116
|
+
To make a new keypair, make sure you have the ec2 tools installed. You can create a new one by typing the command:
|
117
|
+
ec2-add-keypair
|
118
|
+
|
119
|
+
Save this into a file in your ~/.ec2 directory. Enter the name of the keypair here.
|
120
|
+
EOH
|
121
|
+
ask_with_help :message => key_str,
|
122
|
+
:help => key_str_help do |t|
|
123
|
+
@keypair = t
|
124
|
+
say <<-EOE
|
125
|
+
|
126
|
+
In your clouds.rb, you can use this keypair in your clouds.
|
127
|
+
|
128
|
+
Create one for each cloud you want to use.
|
129
|
+
|
130
|
+
EOE
|
131
|
+
|
132
|
+
clds =<<-EOC
|
133
|
+
pool :my_pool do
|
134
|
+
cloud :my_app do
|
135
|
+
|
136
|
+
# Copy these lines and source them in your .profile or .bashrc file
|
137
|
+
# export AWS_ACCESS_KEY="#{@access_key}"
|
138
|
+
# export AWS_SECRET_ACCESS_KEY="#{@secret_access_key}"
|
139
|
+
# export EC2_PRIVATE_KEY=$(ls ~/.ec2/pk-*.pem)
|
140
|
+
# export EC2_CERT=$(ls ~/.ec2/cert-*.pem)
|
141
|
+
|
142
|
+
access_key "#{@access_key}"
|
143
|
+
secret_access_key "#{@secret_access_key}"
|
144
|
+
keypair "#{@keypair}"
|
145
|
+
|
146
|
+
has_file "/etc/motd" do
|
147
|
+
content "Welcome to your first PoolParty instance!"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
EOC
|
152
|
+
|
153
|
+
::File.open("clouds.rb", "w") {|f| f << clds}
|
154
|
+
colored_say closing_message
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
160
|
+
when :vmrun
|
161
|
+
vmrun_file_help =<<-EOV
|
162
|
+
Vmware uses a vmwarevm file to keep information about the vmware instance. To find the vmwarevm file,
|
163
|
+
navigate to vmware and find the vm you'd like to use. Find this in finder and paste that here.
|
164
|
+
EOV
|
165
|
+
default_vmrun_file = Dir["#{::File.expand_path("~")}/Documents/Virtual\ Machines/*.vmwarevm"].first rescue nil
|
166
|
+
vmrun_file = <<-EOE
|
167
|
+
Awesome. What's the path to your vmwarevm file?
|
168
|
+
#{
|
169
|
+
if default_vmrun_file
|
170
|
+
"Is this it: #{default_vmrun_file}? (Press enter to accept default)"
|
171
|
+
end
|
172
|
+
}
|
173
|
+
EOE
|
174
|
+
ask_with_help :message => vmrun_file,
|
175
|
+
:help => vmrun_file_help do |t|
|
176
|
+
|
177
|
+
t = default_vmrun_file if t.nil? || t.empty?
|
178
|
+
ip_help =<<-EOV
|
179
|
+
Right now, vmrun, the remoter base needs an explicitly set ip. Log into your vm and type ifconfig. Copy and paste that here.
|
180
|
+
EOV
|
181
|
+
ask_with_help :message => "Now, what's the ip of your vm?",
|
182
|
+
:validate => /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|h|H/,
|
183
|
+
:help => ip_help do |i|
|
184
|
+
|
185
|
+
ask_with_help :message => "Finally, make sure you get your key on the vm. You can use this command: \n\tscp ~/.ssh/id_rsa.pub root@#{i}:/root/.ssh/authorized_keys.\n\nPress enter when you're ready" do |qqqq|
|
186
|
+
|
187
|
+
vmx_file = Dir["#{t}/*.vmx"].first
|
188
|
+
clds =<<-EOC
|
189
|
+
pool :my_pool do
|
190
|
+
cloud :my_app do
|
191
|
+
using :vmrun do
|
192
|
+
vmx_hash({
|
193
|
+
"#{vmx_file}" => "#{i}"
|
194
|
+
})
|
195
|
+
end
|
196
|
+
|
197
|
+
has_file "/etc/motd" do
|
198
|
+
content "Welcome to your first PoolParty instance!"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
EOC
|
203
|
+
|
204
|
+
::File.open("clouds.rb", "w") {|f| f << clds}
|
205
|
+
colored_say closing_message
|
206
|
+
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
else
|
211
|
+
say("Not sure what remoter_base you mean. Please choose from the menu.")
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
File without changes
|
@@ -176,5 +176,16 @@ class String
|
|
176
176
|
def macify
|
177
177
|
split(":").map {|a| a[0].chr == "0" ? a[1].chr : a}.join(":")
|
178
178
|
end
|
179
|
+
|
180
|
+
##
|
181
|
+
# @param o<String> The path component to join with the string.
|
182
|
+
#
|
183
|
+
# @return <String> The original path concatenated with o.
|
184
|
+
#
|
185
|
+
# @example
|
186
|
+
# "merb"/"core_ext" #=> "merb/core_ext"
|
187
|
+
def /(o)
|
188
|
+
File.join(self, o.to_s)
|
189
|
+
end
|
179
190
|
|
180
191
|
end
|
@@ -14,4 +14,14 @@ class Symbol
|
|
14
14
|
def <=>(b)
|
15
15
|
"#{self}" <=> "#{b}"
|
16
16
|
end
|
17
|
+
##
|
18
|
+
# @param o<String, Symbol> The path component to join with the string.
|
19
|
+
#
|
20
|
+
# @return <String> The original path concatenated with o.
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# :merb/"core_ext" #=> "merb/core_ext"
|
24
|
+
def /(o)
|
25
|
+
File.join(self.to_s, o.to_s)
|
26
|
+
end
|
17
27
|
end
|
@@ -39,11 +39,7 @@ module PoolParty
|
|
39
39
|
|
40
40
|
def comp(cld_name, props, tabs)
|
41
41
|
|
42
|
-
default_recipe = [
|
43
|
-
resources_to_string(props[:resources],tabs),
|
44
|
-
services_to_string(props[:services],tabs)
|
45
|
-
].join("\n")
|
46
|
-
|
42
|
+
default_recipe = resources_to_string(props[:resources],tabs)
|
47
43
|
::File.open("#{base_dir}/recipes/default.rb", "w+") {|f| f << default_recipe }
|
48
44
|
|
49
45
|
default_recipe
|
@@ -73,7 +69,7 @@ module PoolParty
|
|
73
69
|
end
|
74
70
|
|
75
71
|
def resources_to_string(opts,tabs=0)
|
76
|
-
out = []
|
72
|
+
out = []
|
77
73
|
out << opts.map do |resource|
|
78
74
|
case ty = resource.delete(:pp_type)
|
79
75
|
when "variable"
|
@@ -82,6 +78,8 @@ module PoolParty
|
|
82
78
|
"#{tf(tabs)}include_recipe #{to_option_string(resource.name)}"
|
83
79
|
when "chef_library"
|
84
80
|
"#{tf(tabs)}require #{to_option_string("/etc/chef/lib/#{resource.name}")}"
|
81
|
+
when "plugin"
|
82
|
+
handle_print_service(resource, tabs)
|
85
83
|
else
|
86
84
|
real_type = handle_chef_types(ty)
|
87
85
|
real_name = resource[:name]
|
@@ -89,22 +87,22 @@ module PoolParty
|
|
89
87
|
"#{tf(tabs)}#{real_type} \"#{real_name}\" do\n#{tf(tabs+1)}#{hash_flush_out(res).compact.join("\n#{tf(tabs+1)}")}\n#{tf(tabs)}end"
|
90
88
|
end
|
91
89
|
end
|
92
|
-
out.join("\n")
|
90
|
+
out.compact.join("\n")
|
93
91
|
end
|
94
92
|
|
95
93
|
def handle_print_variable(varhash)
|
96
94
|
o = []
|
97
95
|
if varhash[:namespace]
|
98
96
|
o << ["\n#{varhash[:namespace]} Mash.new unless attribute?('#{varhash[:namespace]}')"]
|
99
|
-
o << "#{varhash[:namespace]}[
|
97
|
+
o << "#{varhash[:namespace]}['#{varhash[:name]}'] = #{to_option_string(varhash[:value])}\n"
|
100
98
|
else
|
101
|
-
o << "poolparty[
|
99
|
+
o << "poolparty['#{varhash[:name]}'] = #{to_option_string(varhash[:value])}"
|
102
100
|
end
|
103
101
|
::File.open("#{base_dir}/attributes/poolparty.rb", "a+") do |f|
|
104
102
|
f << o.join("\n")
|
105
103
|
f << "\n"
|
106
104
|
end
|
107
|
-
|
105
|
+
nil
|
108
106
|
end
|
109
107
|
|
110
108
|
def handle_chef_types(ty)
|
@@ -137,19 +135,15 @@ module PoolParty
|
|
137
135
|
end
|
138
136
|
end
|
139
137
|
|
140
|
-
def handle_print_service(
|
141
|
-
|
142
|
-
|
143
|
-
nil
|
144
|
-
else
|
145
|
-
kname = klassname.to_s.gsub(/pool_party_/, '').gsub(/_class/, '')
|
138
|
+
def handle_print_service(plugin, tabs)
|
139
|
+
if plugin && plugin.has_key?(:resources) && !plugin[:resources].empty?
|
140
|
+
kname = plugin.delete(:name).to_s.gsub(/pool_party_/, '').gsub(/_class/, '')
|
146
141
|
str = "\n#{tf(tabs)}# #{kname}\n"
|
147
142
|
str << "#{tf(tabs)}"
|
148
|
-
|
149
|
-
str << _compile(hsh,tabs+1, klassname)
|
150
|
-
end
|
143
|
+
str << _compile(plugin,tabs+1, kname)
|
151
144
|
str << "#{tf(tabs)}"
|
152
145
|
end
|
146
|
+
str
|
153
147
|
end
|
154
148
|
|
155
149
|
# Check if the hash has content and that the content exists here. This is used
|
@@ -170,21 +164,6 @@ module PoolParty
|
|
170
164
|
hsh
|
171
165
|
end
|
172
166
|
|
173
|
-
# Turn the services into strings using the handle_print_service method
|
174
|
-
# Here we can strip out non-meaningful chef services
|
175
|
-
def services_to_string(opts,tabs=0)
|
176
|
-
if opts
|
177
|
-
str = ""
|
178
|
-
[:control_statements, :conditional].each do |k|
|
179
|
-
opts.delete(k)
|
180
|
-
end
|
181
|
-
opts.map do |klassname, klasshash|
|
182
|
-
str << handle_print_service(klassname, klasshash, tabs)
|
183
|
-
end
|
184
|
-
str
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
167
|
# Handle ensures
|
189
168
|
def handle_actions(key,value)
|
190
169
|
case key
|
@@ -197,6 +176,8 @@ module PoolParty
|
|
197
176
|
|
198
177
|
# Take the keys from the resource hash and turn them into chef-like
|
199
178
|
# meaningful keys. This is how helpers are created for chef
|
179
|
+
#
|
180
|
+
# * <tt>reloads</tt> - todo
|
200
181
|
def to_chef_key(key)
|
201
182
|
case key
|
202
183
|
when :ensures
|
@@ -224,6 +205,7 @@ module PoolParty
|
|
224
205
|
|
225
206
|
# Resolve the value of the resource hash into a meaningful chef
|
226
207
|
# value. Resources are turned into resource strings here
|
208
|
+
#
|
227
209
|
def to_option_string(obj)
|
228
210
|
case obj
|
229
211
|
when PoolParty::Resources::Resource
|
@@ -6,15 +6,15 @@ module PoolParty
|
|
6
6
|
# Take the cloud dependency tree
|
7
7
|
module DependencyResolverCloudExtensions
|
8
8
|
def to_properties_hash
|
9
|
-
oh =
|
9
|
+
oh = {}
|
10
10
|
oh[:options] = options.merge(:cloud_name => name)
|
11
11
|
oh[:resources] = ordered_resources.map {|a| a.to_properties_hash }
|
12
12
|
# oh[:resources] = resources.keys.inject(OrderedHash.new) do |sum,k|
|
13
13
|
# sum.merge(k.to_sym => resources[k].map {|a| a.to_properties_hash } )
|
14
14
|
# end
|
15
|
-
oh[:services] = services.keys.inject(OrderedHash.new) do |sum,k|
|
16
|
-
|
17
|
-
end
|
15
|
+
# oh[:services] = services.keys.inject(OrderedHash.new) do |sum,k|
|
16
|
+
# sum.merge(k.to_sym => services[k].map {|a| a.to_properties_hash } )
|
17
|
+
# end
|
18
18
|
oh
|
19
19
|
end
|
20
20
|
|
@@ -22,11 +22,7 @@ module PoolParty
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def compile(props=@properties_hash, tabs=0)
|
25
|
-
[
|
26
|
-
# options_to_string(props[:options],tabs),
|
27
|
-
resources_to_string(props[:resources],tabs),
|
28
|
-
services_to_string(props[:services],tabs)
|
29
|
-
].join("\n")
|
25
|
+
resources_to_string(props[:resources],tabs)
|
30
26
|
end
|
31
27
|
|
32
28
|
def options_to_string(opts,tabs=0)
|
@@ -62,6 +58,8 @@ module PoolParty
|
|
62
58
|
case ty = resource.delete(:pp_type)
|
63
59
|
when "variable"
|
64
60
|
handle_print_variable(resource[:name], resource[:value], :variable)
|
61
|
+
when "plugin"
|
62
|
+
handle_print_service(resource.delete(:name), resource, tabs)
|
65
63
|
else
|
66
64
|
real_name = resource[:name]
|
67
65
|
handle_print_resource(resource, ty.to_sym, tabs)
|
@@ -80,14 +78,6 @@ module PoolParty
|
|
80
78
|
# end
|
81
79
|
end
|
82
80
|
|
83
|
-
def services_to_string(opts,tabs=0)
|
84
|
-
if opts
|
85
|
-
opts.map do |klassname, klasshash|
|
86
|
-
handle_print_service(klassname, klasshash, tabs)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
81
|
def hash_flush_out(hash, pre="", post="")
|
92
82
|
setup_hash_for_output(hash).map do |k,v|
|
93
83
|
hash.empty? ? nil : "#{pre}#{k} => #{v}#{post}"
|
@@ -135,28 +125,26 @@ module PoolParty
|
|
135
125
|
end
|
136
126
|
end
|
137
127
|
|
138
|
-
def handle_print_service(klassname,
|
128
|
+
def handle_print_service(klassname, plugin, tabs)
|
139
129
|
case klassname.to_s
|
140
130
|
when "conditional"
|
141
131
|
# "#{tf(tabs)}case $#{klasshash[:options][:variable]} {#{klasshash[:services][:control_statements].map do |k,v|"\n#{tf(tabs+1)}#{k} : {#{compile(v.to_properties_hash, tabs+2)}#{tf(tabs+1)}\n#{tf(tabs)}}" end}}"
|
142
|
-
|
143
|
-
str = ""
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
149
|
-
str << "#{tf(tabs)}}"
|
132
|
+
#
|
133
|
+
# str = ""
|
134
|
+
# plugin.each do |klasshash|
|
135
|
+
# # str << "\n#{tf(tabs+1)}#{compile(hsh,tabs+1)}"
|
136
|
+
# str << "#{tf(tabs)}case $#{klasshash[:options][:variable]} {"
|
137
|
+
# str << "#{klasshash[:services][:control_statements].map do |k,v|"\n#{tf(tabs+1)}#{k} : {#{compile(v.to_properties_hash, tabs+2)}#{tf(tabs+1)}\n#{tf(tabs)}}" end}"
|
138
|
+
# end
|
139
|
+
# str << "#{tf(tabs)}}"
|
140
|
+
# deprecated conditional
|
150
141
|
|
151
142
|
else
|
152
143
|
kname = klassname.to_s.gsub(/pool_party_/, '').gsub(/_class/, '')
|
153
144
|
str = "\n#{tf(tabs)}# #{kname}\n"
|
154
145
|
str << "#{tf(tabs)}class #{kname} {"
|
155
|
-
|
156
|
-
|
157
|
-
end
|
158
|
-
str << "#{tf(tabs)}} include #{kname}"
|
159
|
-
|
146
|
+
str << "\n#{tf(tabs+1)}#{compile(plugin,tabs+1)}"
|
147
|
+
str << "#{tf(tabs)}} include #{kname}"
|
160
148
|
end
|
161
149
|
end
|
162
150
|
|
data/lib/poolparty/lite.rb
CHANGED
@@ -8,8 +8,8 @@ end
|
|
8
8
|
require "#{::File.dirname(__FILE__)}/poolparty/default"
|
9
9
|
require "#{::File.dirname(__FILE__)}/modules/user_helpers"
|
10
10
|
require "#{::File.dirname(__FILE__)}/schema"
|
11
|
-
require "#{::File.dirname(__FILE__)}/net/init"
|
12
11
|
require "#{::File.dirname(__FILE__)}/core/string"
|
12
|
+
require "#{::File.dirname(__FILE__)}/net/init"
|
13
13
|
require "#{::File.dirname(__FILE__)}/core/hash"
|
14
14
|
require "#{::File.dirname(__FILE__)}/poolparty/neighborhoods"
|
15
15
|
require "#{::File.dirname(__FILE__)}/exceptions/RemoteException.rb"
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module PoolParty
|
2
|
+
# Abstracts out the searchable path for a resource such as a
|
3
|
+
# template file, key, or clouds.rb
|
4
|
+
#
|
5
|
+
# NOTE: this is currently _only_ implemented on templates
|
6
|
+
# (PoolParty::Resources::File) and not yet working on clouds.rb or key files.
|
7
|
+
# These will eventually be refactored to use this class.
|
8
|
+
module SearchablePaths
|
9
|
+
def self.included(mod)
|
10
|
+
mod.extend(ClassMethods)
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
# Specify that a particular class has methods for searchable paths.
|
15
|
+
#
|
16
|
+
# Options:
|
17
|
+
# * <tt>:dirs</tt>: array of directories to look in *under* the search paths. (default: <tt>["/"]</tt>)
|
18
|
+
# * <tt>:dir</tt>: set the directory to look in *under* the search paths. Use either dir or dirs, not both. (default: +/+)
|
19
|
+
# * <tt>:paths</tt>: overwrite all default paths and set the paths to this array exactly
|
20
|
+
# * <tt>:append_paths</tt>: append these paths to any existing paths
|
21
|
+
# * <tt>:prepend_paths</tt>: prepend these paths to any existing paths
|
22
|
+
def has_searchable_paths(opts={})
|
23
|
+
class_eval do
|
24
|
+
extend PoolParty::SearchablePaths::SingletonMethods
|
25
|
+
|
26
|
+
@searchable_paths_dirs = [opts[:dir]] if opts[:dir]
|
27
|
+
@searchable_paths_dirs = opts[:dirs] if opts[:dirs]
|
28
|
+
@paths_override = opts[:paths] if opts[:paths]
|
29
|
+
@paths_prepend = opts[:prepend_paths] || []
|
30
|
+
@paths_append = opts[:append_paths] || []
|
31
|
+
end
|
32
|
+
include PoolParty::SearchablePaths::InstanceMethods
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module SingletonMethods
|
37
|
+
def searchable_paths_dir; @searchable_paths_dirs.first; end
|
38
|
+
def searchable_paths_dirs
|
39
|
+
@searchable_paths_dirs && @searchable_paths_dirs.size > 0 ? @searchable_paths_dirs : ["/"]
|
40
|
+
end
|
41
|
+
|
42
|
+
# The default paths are primarily defined in PoolParty::Default. These are the default search paths in order:
|
43
|
+
#
|
44
|
+
# * current working directory (Dir.pwd)
|
45
|
+
# * ~/.poolparty
|
46
|
+
# * ~/.ec2
|
47
|
+
# * /etc/poolparty
|
48
|
+
# * /var/poolparty
|
49
|
+
def default_paths
|
50
|
+
[
|
51
|
+
Dir.pwd,
|
52
|
+
PoolParty::Default.poolparty_home_path,
|
53
|
+
PoolParty::Default.base_keypair_path,
|
54
|
+
PoolParty::Default.poolparty_src_path,
|
55
|
+
PoolParty::Default.poolparty_src_path/:lib/:poolparty,
|
56
|
+
PoolParty::Default.base_config_directory,
|
57
|
+
PoolParty::Default.remote_storage_path
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
# returns the full set of valid searchable paths, given the options
|
62
|
+
def searchable_paths
|
63
|
+
return @paths_override if @paths_override && @paths_override.size > 0
|
64
|
+
@paths_prepend + default_paths + @paths_append
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
module InstanceMethods
|
69
|
+
|
70
|
+
# Searches for +filepath+ in the <tt>searchable_paths</tt> iff +filepath+
|
71
|
+
# doesn't exist. e.g. +filepath+ is interpreted *first* as an absolute
|
72
|
+
# path, if +filepath+ doesn't exist verbatim then it looks for the file
|
73
|
+
# in the searchable_paths.
|
74
|
+
#
|
75
|
+
# Returns +nil+ if the file cannot be found.
|
76
|
+
def search_in_known_locations(filepath)
|
77
|
+
return filepath if File.exists?(filepath) # return the file if its an absolute path
|
78
|
+
self.class.searchable_paths.each do |path|
|
79
|
+
self.class.searchable_paths_dirs.each do |dir|
|
80
|
+
full_path = File.expand_path(path / dir / filepath)
|
81
|
+
return full_path if File.exists?(full_path)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
alias_method :find_file, :search_in_known_locations
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
data/lib/poolparty/net/init.rb
CHANGED
@@ -33,6 +33,11 @@ module PoolParty
|
|
33
33
|
instance_eval &block if block
|
34
34
|
@cloud = prnt
|
35
35
|
end
|
36
|
+
|
37
|
+
def self.inherited(arg)
|
38
|
+
base_name = "#{arg}".downcase.top_level_class.to_sym
|
39
|
+
(remote_bases << base_name) unless remote_bases.include?(base_name)
|
40
|
+
end
|
36
41
|
|
37
42
|
|
38
43
|
# def method_missing(meth, *args, &block)
|
@@ -105,7 +105,9 @@ module PoolParty
|
|
105
105
|
)
|
106
106
|
end
|
107
107
|
def self.ec2(o)
|
108
|
-
@ec2 ||=
|
108
|
+
@ec2 ||= EC2::Base.new( :access_key_id => o[:access_key],
|
109
|
+
:secret_access_key => o[:secret_access_key]
|
110
|
+
)
|
109
111
|
end
|
110
112
|
|
111
113
|
# Get the ec2 description for the response in a hash format
|