auser-poolparty 0.2.67 → 0.2.68
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +1 -0
- data/Rakefile +3 -3
- data/bin/pool-generate +1 -0
- data/lib/poolparty/core/string.rb +4 -4
- data/lib/poolparty/dependency_resolutions/puppet.rb +1 -1
- data/lib/poolparty/modules/definable_resource.rb +2 -2
- data/lib/poolparty/plugins/line.rb +3 -3
- data/lib/poolparty/plugins/runit.rb +1 -1
- data/lib/poolparty/plugins/svn.rb +1 -1
- data/lib/poolparty/pool/custom_resource.rb +4 -29
- data/lib/poolparty/pool/pool.rb +1 -1
- data/lib/poolparty/pool/resource.rb +22 -11
- data/lib/poolparty/pool/resources/exec.rb +6 -5
- data/lib/poolparty/templates/puppetrunner +5 -1
- data/lib/poolparty/version.rb +1 -1
- data/poolparty.gemspec +1 -1
- data/spec/poolparty/core/string_spec.rb +3 -0
- data/spec/poolparty/core/time_spec.rb +0 -3
- data/spec/poolparty/pool/custom_resource_spec.rb +4 -4
- data/spec/poolparty/pool/resource_spec.rb +5 -0
- data/website/index.html +1 -1
- metadata +1 -1
data/README.txt
CHANGED
data/Rakefile
CHANGED
@@ -53,7 +53,7 @@ task :gemspec => [:spec, :clean_tmp, :"manifest:refresh", :build_local_gem] do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
desc "Generate gemspec for github"
|
56
|
-
task :gh => [:
|
56
|
+
task :gh => [:github_release] do
|
57
57
|
filepath = ::File.join(::File.dirname(__FILE__), "poolparty.gemspec")
|
58
58
|
data = open(filepath).read
|
59
59
|
spec = eval("$SAFE = 3\n#{data}")
|
@@ -64,6 +64,6 @@ task :gh => [:gemspec, :ghgem] do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
desc "Generate github gemspec and latest gem"
|
67
|
-
task :ghgem => [:
|
68
|
-
|
67
|
+
task :ghgem => [:gh] do
|
68
|
+
%x[sudo gem install pkg/poolparty.gem]
|
69
69
|
end
|
data/bin/pool-generate
CHANGED
@@ -14,4 +14,5 @@ source = RubiGen::PathSource.new(:application,
|
|
14
14
|
File.join(File.dirname(__FILE__), "../generators"))
|
15
15
|
RubiGen::Base.reset_sources
|
16
16
|
RubiGen::Base.append_sources source
|
17
|
+
ARGV.reject! {|a| a == "generate" }
|
17
18
|
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'poolspec')
|
@@ -22,7 +22,7 @@ class String
|
|
22
22
|
self.strip.split(/\n/).join(" && ")
|
23
23
|
end
|
24
24
|
def top_level_class
|
25
|
-
self.split("::")[-1].downcase rescue self
|
25
|
+
self.split("::")[-1].underscore.downcase rescue self
|
26
26
|
end
|
27
27
|
def sanitize
|
28
28
|
self.gsub(/[ \.\/\-]*/, '')
|
@@ -60,7 +60,7 @@ class String
|
|
60
60
|
# Refactor this guy to get the class if the class is defined, and not always create a new one
|
61
61
|
# although, it doesn't really matter as ruby will just reopen the class
|
62
62
|
def class_constant(superclass=nil, opts={}, &block)
|
63
|
-
symc = ((opts && opts[:preserve]) ? ("#{self.
|
63
|
+
symc = ((opts && opts[:preserve]) ? ("#{self.camelcase}Classs") : "PoolParty#{self.camelcase}Classs").classify
|
64
64
|
|
65
65
|
kla=<<-EOE
|
66
66
|
class #{symc} #{"< #{superclass}" if superclass}
|
@@ -75,13 +75,13 @@ class String
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def module_constant(append="", &block)
|
78
|
-
symc = "#{self}_Module#{append}".
|
78
|
+
symc = "#{self}_Module#{append}".camelcase
|
79
79
|
mod = Object.const_defined?(symc) ? Object.const_get(symc.to_sym) : Module.new(&block)
|
80
80
|
Object.const_set(symc, mod) unless Object.const_defined?(symc)
|
81
81
|
symc.to_s.constantize
|
82
82
|
end
|
83
83
|
def preserved_module_constant(ext="", from="PoolParty::", &block)
|
84
|
-
symc = "#{self}#{ext}".
|
84
|
+
symc = "#{self}#{ext}".camelcase
|
85
85
|
mod = Kernel.const_defined?(symc) ? Kernel.const_get(symc.to_sym) : Module.new(&block)
|
86
86
|
Kernel.const_set(symc, mod) unless Kernel.const_defined?(symc)
|
87
87
|
symc.to_s.constantize
|
@@ -16,7 +16,7 @@ module PoolParty
|
|
16
16
|
#
|
17
17
|
# For example usage, see lib/poolparty/plugins/line.rb
|
18
18
|
def define_resource(name, &block)
|
19
|
-
symc = "#{name}".
|
19
|
+
symc = "#{name}".camelcase
|
20
20
|
klass = symc.class_constant(PoolParty::Resources::CustomResource, {:preserve => true}, &block)
|
21
21
|
PoolParty::Resources.module_eval &block
|
22
22
|
klass
|
@@ -44,7 +44,7 @@ module PoolParty
|
|
44
44
|
#
|
45
45
|
# An example is included in the poolparty-apache-plugin
|
46
46
|
def virtual_resource(name=:virtual_resource, opts={}, &block)
|
47
|
-
symc = "#{name}".
|
47
|
+
symc = "#{name}".camelcase
|
48
48
|
eval <<-EOE
|
49
49
|
class PoolParty::Resources::#{symc} < PoolParty::Resources::Resource
|
50
50
|
end
|
@@ -4,7 +4,7 @@ module PoolParty
|
|
4
4
|
define_resource(:line_in_file) do
|
5
5
|
# Should refactor
|
6
6
|
def has_line_in_file(line="line_in_file", file="file", opts={})
|
7
|
-
|
7
|
+
call_custom_function <<-EOE
|
8
8
|
line {
|
9
9
|
'#{file}_line' :
|
10
10
|
file => '#{file}',
|
@@ -16,7 +16,7 @@ module PoolParty
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def append_if_no_such_line(line="line", file="", refreshonly='false')
|
19
|
-
|
19
|
+
call_custom_function <<-EOE
|
20
20
|
append_if_no_such_line {
|
21
21
|
'#{file}' :
|
22
22
|
file => '#{file}',
|
@@ -27,7 +27,7 @@ module PoolParty
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def delete_lines_from(file="", pattern=//, opts={})
|
30
|
-
|
30
|
+
call_custom_function <<-EOE
|
31
31
|
delete_lines {
|
32
32
|
'#{file}' :
|
33
33
|
file => '#{file}',
|
@@ -3,7 +3,7 @@ module PoolParty
|
|
3
3
|
define_resource(:runitservice) do
|
4
4
|
def has_runit_service(name="runitservice", downif="", templatedir="")
|
5
5
|
path = copy_templates_from_templatedir(templatedir)
|
6
|
-
|
6
|
+
call_custom_function <<-EOC
|
7
7
|
runit_service {
|
8
8
|
"#{name}":
|
9
9
|
directory => "/etc/sv",
|
@@ -7,48 +7,23 @@ module PoolParty
|
|
7
7
|
|
8
8
|
module Resources
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
if !global_resources_store.select {|r| r.key == str.keyerize }.empty?
|
13
|
-
@res = get_resource(:call_function, str.keyerize, parent)
|
14
|
-
else
|
15
|
-
@res = returning PoolParty::Resources::CallFunction.new(str, opts.merge(:key => str.keyerize), &block) do |o|
|
16
|
-
store_into_global_resource_store(o)
|
17
|
-
resource(:call_function) << o
|
18
|
-
end
|
19
|
-
end
|
20
|
-
@res
|
10
|
+
def call_custom_function(str, opts={}, parent=self, &block)
|
11
|
+
add_resource(:call_function, opts.merge({:str => str, :name => str.keyerize}), parent, &block)
|
21
12
|
end
|
22
13
|
|
23
14
|
# Resources for function call
|
24
15
|
class CallFunction < Resource
|
25
|
-
def initialize(str="", opts={}, parent=self, &block)
|
26
|
-
@key = opts[:key] || str.keyerize
|
27
|
-
@str = str
|
28
|
-
# super(opts, parent, &block)
|
29
|
-
end
|
30
|
-
def key
|
31
|
-
@key || @str.keyerize
|
32
|
-
end
|
33
|
-
def duplicatable?
|
34
|
-
false
|
35
|
-
end
|
36
16
|
def to_string(pre="")
|
37
17
|
returning Array.new do |arr|
|
38
|
-
arr << "#{pre}#{
|
18
|
+
arr << "#{pre}#{str}"
|
39
19
|
end.join("\n")
|
40
20
|
end
|
41
21
|
end
|
42
22
|
|
43
23
|
class CustomResource < Resource
|
44
|
-
def initialize(name=:custom_method, opts={}, parent=self, &block)
|
45
|
-
@name = name
|
46
|
-
super(opts, parent, &block)
|
47
|
-
end
|
48
|
-
|
49
24
|
def self.inherited(subclass)
|
50
25
|
PoolParty::Resources.available_custom_resources << subclass
|
51
|
-
super
|
26
|
+
super
|
52
27
|
end
|
53
28
|
|
54
29
|
def to_string(pre="")
|
data/lib/poolparty/pool/pool.rb
CHANGED
@@ -20,17 +20,18 @@ module PoolParty
|
|
20
20
|
def add_resource(type, opts={}, parent=self, &block)
|
21
21
|
if in_a_resource_store?(type, opts[:name])
|
22
22
|
@res = get_resource(type, opts[:name], parent)
|
23
|
-
if should_duplicate_resource?(type, @res, parent, opts)
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
# if should_duplicate_resource?(type, @res, parent, opts)
|
24
|
+
# unless @res.parent == parent
|
25
|
+
# @pa = parent
|
26
|
+
# @res.instance_eval {@parent = @pa}
|
27
|
+
# end
|
27
28
|
# parent.resource(type) << @res
|
28
|
-
end
|
29
|
+
# end
|
29
30
|
else
|
30
|
-
@res = returning "PoolParty::Resources::#{type.to_s.camelize}".
|
31
|
+
@res = returning "PoolParty::Resources::#{type.to_s.camelize}".camelize.constantize.new(opts, parent, &block) do |o|
|
31
32
|
store_into_global_resource_store(o)
|
32
33
|
resource(type) << o
|
33
|
-
end
|
34
|
+
end
|
34
35
|
end
|
35
36
|
@res
|
36
37
|
end
|
@@ -90,7 +91,7 @@ module PoolParty
|
|
90
91
|
|
91
92
|
def self.inherited(subclass)
|
92
93
|
subclass = subclass.to_s.split("::")[-1] if subclass.to_s.index("::")
|
93
|
-
lowercase_class_name = subclass.to_s.
|
94
|
+
lowercase_class_name = subclass.to_s.underscore
|
94
95
|
|
95
96
|
# Add add resource method to the Resources module
|
96
97
|
unless PoolParty::Resources.respond_to?(lowercase_class_name.to_sym)
|
@@ -161,20 +162,30 @@ module PoolParty
|
|
161
162
|
@pa = @pa.respond_to?(:parent) ? @pa.parent : nil
|
162
163
|
end
|
163
164
|
@pa
|
164
|
-
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def parent_tree
|
168
|
+
@pa = self
|
169
|
+
returning Array.new do |arr|
|
170
|
+
while !(@pa.is_a?(PoolParty::Cloud::Cloud) || @pa.nil? || @pa == self)
|
171
|
+
@pa = @pa.respond_to?(:parent) ? @pa.parent : nil
|
172
|
+
arr << @pa
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
165
176
|
|
166
177
|
# DSL Overriders
|
167
178
|
include PoolParty::ResourcingDsl
|
168
179
|
|
169
180
|
def same_resources_of(t, k)
|
170
|
-
key == k && class_name_sym == t
|
181
|
+
key == k && class_name_sym == t
|
171
182
|
end
|
172
183
|
def duplicatable?
|
173
184
|
false
|
174
185
|
end
|
175
186
|
# This way we can subclass resources without worry
|
176
187
|
def class_type_name
|
177
|
-
self.class.to_s.top_level_class
|
188
|
+
self.class.to_s.top_level_class.underscore
|
178
189
|
end
|
179
190
|
def self.custom_function(str)
|
180
191
|
custom_functions << str
|
@@ -9,11 +9,12 @@ module PoolParty
|
|
9
9
|
|
10
10
|
# Execs cannot have the following parameters
|
11
11
|
# We use version in the gempackage resource
|
12
|
-
# So we have to exclude it here.
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
# So we have to exclude it here.
|
13
|
+
def allowed_options
|
14
|
+
[
|
15
|
+
:command, :creates, :cwd, :env, :environment, :group, :logoutput, :user,
|
16
|
+
:onlyif, :path, :refresh, :refreshonly, :returns, :timeout, :unless
|
17
|
+
]
|
17
18
|
end
|
18
19
|
|
19
20
|
def key
|
@@ -1,4 +1,8 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
3
|
. /etc/profile
|
4
|
-
/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
|
4
|
+
if [ $(/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master)]; then
|
5
|
+
echo "Run successfully"
|
6
|
+
else
|
7
|
+
/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
|
8
|
+
fi
|
data/lib/poolparty/version.rb
CHANGED
data/poolparty.gemspec
CHANGED
@@ -115,6 +115,9 @@ listen web_proxy 127.0.0.1:3000
|
|
115
115
|
it "should be able to get the top level class" do
|
116
116
|
"PoolParty::Resources::File".top_level_class.should == "file"
|
117
117
|
end
|
118
|
+
it "should turn file into a class" do
|
119
|
+
"file".camelcase.should == "File"
|
120
|
+
end
|
118
121
|
end
|
119
122
|
describe "to_option_string" do
|
120
123
|
it "should not touch a string, but return the string with single quotes" do
|
@@ -14,7 +14,7 @@ describe "Custom Resource" do
|
|
14
14
|
lambda {
|
15
15
|
define_resource(:rockstar) do
|
16
16
|
def has_a_line_in_file(line="line_in_file", file="file")
|
17
|
-
|
17
|
+
call_custom_function "line(#{file}, #{line})"
|
18
18
|
end
|
19
19
|
custom_function <<-EOF
|
20
20
|
define line($file, $line, $ensure = 'present') {
|
@@ -28,7 +28,7 @@ describe "Custom Resource" do
|
|
28
28
|
before(:each) do
|
29
29
|
define_resource(:rockstar) do
|
30
30
|
def has_a_line_in_file(line="line_in_file", file="file")
|
31
|
-
|
31
|
+
call_custom_function "line(#{file}, #{line})"
|
32
32
|
end
|
33
33
|
custom_function <<-EOF
|
34
34
|
define line($file, $line, $ensure = 'present') {
|
@@ -49,7 +49,7 @@ describe "Custom Resource" do
|
|
49
49
|
reset_resources!
|
50
50
|
define_resource(:rockstar) do
|
51
51
|
def has_a_line_in_file(line="line_in_file", file="file")
|
52
|
-
|
52
|
+
call_custom_function "line(#{file}, #{line})"
|
53
53
|
end
|
54
54
|
custom_function <<-EOF
|
55
55
|
define line($file, $line, $ensure = 'present') {
|
@@ -69,7 +69,7 @@ describe "Custom Resource" do
|
|
69
69
|
@resource.instance_eval do
|
70
70
|
has_a_line_in_file("hi", "filename")
|
71
71
|
end
|
72
|
-
@resource.resource(:call_function).to_string.should == "line(filename, hi)"
|
72
|
+
@resource.resource(:call_function).first.to_string.should == "line(filename, hi)"
|
73
73
|
end
|
74
74
|
it "should be stored in an array" do
|
75
75
|
resource(:rockstar).class.should == Array
|
@@ -383,6 +383,11 @@ describe "Resource" do
|
|
383
383
|
# @cloud2.resources_string_from_resources(@cloud2.resources).should =~ /\[ Package\['apache2'\], Package\['boxers'\] \]/
|
384
384
|
# end
|
385
385
|
end
|
386
|
+
describe "inherited" do
|
387
|
+
it "should turn passengersite_with_ssl into PassengerSiteWithSsl" do
|
388
|
+
"PassengersiteWithSsl".to_s.split("::")[-1].underscore.should == "passengersite_with_ssl"
|
389
|
+
end
|
390
|
+
end
|
386
391
|
end
|
387
392
|
end
|
388
393
|
end
|
data/website/index.html
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
<h1>PoolParty</h1>
|
35
35
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/poolparty"; return false'>
|
36
36
|
<p>Get Version</p>
|
37
|
-
<a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.
|
37
|
+
<a href="http://rubyforge.org/projects/poolparty" class="numbers">0.2.68</a>
|
38
38
|
</div>
|
39
39
|
<h1>‘Easy cloud computing’</h1>
|
40
40
|
<h2>What</h2>
|