auser-poolparty 0.2.61 → 0.2.62
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/poolparty/base_packages/poolparty.rb +8 -4
- data/lib/poolparty/core/symbol.rb +3 -0
- data/lib/poolparty/dependency_resolutions/puppet.rb +23 -7
- data/lib/poolparty/helpers/console.rb +2 -2
- data/lib/poolparty/helpers/provisioners/master.rb +1 -2
- data/lib/poolparty/net/remoter.rb +1 -1
- data/lib/poolparty/net/remoter_base.rb +1 -1
- data/lib/poolparty/plugins/deploydirectory.rb +2 -2
- data/lib/poolparty/plugins/git.rb +12 -11
- data/lib/poolparty/pool/cloud.rb +12 -6
- data/lib/poolparty/pool/resource.rb +18 -11
- data/lib/poolparty/pool/resources/class_package.rb +58 -31
- data/lib/poolparty/pool/resources/conditional.rb +3 -2
- data/lib/poolparty/pool/script.rb +7 -9
- data/lib/poolparty/templates/puppetcleaner +1 -4
- data/lib/poolparty/version.rb +1 -1
- data/poolparty.gemspec +2 -2
- data/spec/poolparty/helpers/provisioner_base_spec.rb +2 -1
- data/spec/poolparty/plugins/git_spec.rb +3 -3
- data/spec/poolparty/pool/cloud_spec.rb +1 -1
- data/spec/poolparty/pool/resource_spec.rb +30 -26
- data/spec/poolparty/pool/resources/class_package_spec.rb +41 -10
- data/spec/poolparty/pool/resources/conditional_spec.rb +16 -0
- data/spec/poolparty/pool/resources/cron_spec.rb +3 -2
- data/spec/poolparty/pool/resources/exec_spec.rb +1 -1
- data/spec/poolparty/pool/resources/gem_spec.rb +1 -1
- metadata +2 -2
@@ -37,17 +37,21 @@ module PoolParty
|
|
37
37
|
has_gempackage(:name => "poolparty", :download_url => "http://github.com/auser/poolparty/tree/master%2Fpkg%2Fpoolparty.gem?raw=true", :requires => [get_gempackage("ruby2ruby"), get_gempackage("RubyInline"), get_gempackage("ParseTree")])
|
38
38
|
|
39
39
|
# , :ifnot => "/bin/ps aux | /bin/grep -q pm_node"
|
40
|
-
has_exec(:name => "build_messenger", :command => ". /etc/profile && server-build-messenger")
|
41
|
-
has_exec(:name => "start_node", :command => ". /etc/profile && server-start-node")
|
42
|
-
has_exec(:name => "update_hosts", :command => ". /etc/profile && server-update-hosts")
|
43
40
|
# has_runit_service("pm_node", "pm_node", File.join(File.dirname(__FILE__), "..", "templates/messenger/node/"))
|
44
41
|
end
|
45
42
|
|
43
|
+
has_exec(:name => "build_messenger", :command => ". /etc/profile && server-build-messenger")
|
44
|
+
has_exec(:name => "start_node", :command => ". /etc/profile && server-start-node")
|
45
|
+
has_exec(:name => "update_hosts", :command => ". /etc/profile && server-update-hosts")
|
46
|
+
|
46
47
|
# execute_on_node do
|
47
48
|
has_cron(:name => "puppetd runner", :user => Base.user, :minute => "*/5") do
|
48
49
|
requires get_gempackage("poolparty")
|
49
50
|
command "/usr/bin/puppetrunner"
|
50
51
|
end
|
52
|
+
has_cron(:name => "update_hosts", :user => Base.user, :minute => "0") do
|
53
|
+
command ". /etc/profile && server-update-hosts"
|
54
|
+
end
|
51
55
|
has_remotefile(:name => "/usr/bin/puppetrunner") do
|
52
56
|
mode 744
|
53
57
|
template File.join(File.dirname(__FILE__), "..", "templates/puppetrunner")
|
@@ -73,7 +77,7 @@ module PoolParty
|
|
73
77
|
has_cron(:name => "Load handler", :user => Base.user, :minute => "*/4") do
|
74
78
|
requires get_gempackage("poolparty")
|
75
79
|
command(". /etc/profile && cloud-handle-load")
|
76
|
-
end
|
80
|
+
end
|
77
81
|
has_cron(:name => "provisioning ensurer", :user => Base.user, :minute => "*/2") do
|
78
82
|
requires get_gempackage("poolparty")
|
79
83
|
command ". /etc/profile && cloud-ensure-provisioning"
|
@@ -21,18 +21,18 @@ module PoolParty
|
|
21
21
|
returning Array.new do |output|
|
22
22
|
unless cancelled?
|
23
23
|
output << @prestring || ""
|
24
|
-
|
24
|
+
|
25
25
|
if resources && !resources.empty?
|
26
|
-
@cp = classpackage_with_self(self)
|
27
|
-
output << @cp.to_string
|
28
|
-
output << "include #{@cp.name.sanitize}"
|
26
|
+
# @cp = classpackage_with_self(self)
|
27
|
+
# output << @cp.to_string
|
28
|
+
# output << "include #{@cp.name.downcase.sanitize}"
|
29
|
+
output << resources_string_from_resources(resources, pre)
|
29
30
|
end
|
30
31
|
|
31
32
|
unless virtual_resource?
|
32
|
-
output << "#{pre}#{class_type_name.downcase} {"
|
33
|
-
output << "#{pre}\"#{self.key}\":"
|
33
|
+
output << "#{pre}#{class_type_name.downcase} { #{pre}\"#{self.key}\":"
|
34
34
|
output << opts.flush_out("#{pre*2}").join(",\n")
|
35
|
-
output << "#{pre}}"
|
35
|
+
output << "#{pre}}"
|
36
36
|
end
|
37
37
|
|
38
38
|
output << @poststring || ""
|
@@ -40,6 +40,22 @@ module PoolParty
|
|
40
40
|
end.join("\n")
|
41
41
|
end
|
42
42
|
|
43
|
+
def resources_string_from_resources(res, pre="\t")
|
44
|
+
@variables = res.extract! {|name,resource| name == :variable}
|
45
|
+
returning Array.new do |str|
|
46
|
+
unless @variables.empty?
|
47
|
+
str << "\n# Variables"
|
48
|
+
@variables.each do |name, variable|
|
49
|
+
str << variable.to_string("#{pre}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
res.each do |type, resource|
|
54
|
+
str << resource.to_string("#{pre*2}")
|
55
|
+
end
|
56
|
+
end.join("\n")
|
57
|
+
end
|
58
|
+
|
43
59
|
def to_s
|
44
60
|
"#{class_type_name.capitalize}['#{key}']"
|
45
61
|
end
|
@@ -17,11 +17,11 @@ module PoolParty
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def extract_cloud_from_options(o)
|
20
|
-
o.cloudname ? [cloud(o.cloudname.downcase.to_sym)] : [clouds[clouds.keys.first]]
|
20
|
+
o.cloudname ? [cloud(o.cloudname.downcase.to_sym)] : [clouds[clouds.keys.sort.first]]
|
21
21
|
end
|
22
22
|
|
23
23
|
def extract_pool_from_options(o)
|
24
|
-
o.poolname ? [pool(o.poolname.downcase.to_sym)] : [pools[pools.keys.first]]
|
24
|
+
o.poolname ? [pool(o.poolname.downcase.to_sym)] : [pools[pools.keys.sort.first]]
|
25
25
|
end
|
26
26
|
|
27
27
|
# Clear all the pools and reload the console
|
@@ -150,7 +150,6 @@ cp #{Base.remote_storage_path}/#{Base.template_directory}/puppetrerun /usr/bin/p
|
|
150
150
|
cp #{Base.remote_storage_path}/#{Base.template_directory}/puppetrunner /usr/bin/puppetrunner
|
151
151
|
chmod +x /usr/bin/puppetrerun
|
152
152
|
chmod +x /usr/bin/puppetrunner
|
153
|
-
/bin/sh /usr/bin/server-update-hosts
|
154
153
|
EOE
|
155
154
|
end
|
156
155
|
|
@@ -167,7 +166,7 @@ node default {
|
|
167
166
|
node "#{ri.name}" inherits default {}
|
168
167
|
EOS
|
169
168
|
end
|
170
|
-
"echo '#{str}' > #{Base.manifest_path}
|
169
|
+
"echo '#{str}' > #{Base.manifest_path}/nodes/nodes.pp"
|
171
170
|
end
|
172
171
|
|
173
172
|
def move_templates
|
@@ -73,7 +73,7 @@ module PoolParty
|
|
73
73
|
def remote_instances_list
|
74
74
|
# puts "> #{@containing_cloud.name} - #{@containing_cloud.class}"
|
75
75
|
@containing_cloud = self
|
76
|
-
|
76
|
+
list_of_instances(keypair).collect {|h| PoolParty::Remote::RemoteInstance.new(h, @containing_cloud) }
|
77
77
|
end
|
78
78
|
# List the instances for the current key pair, regardless of their states
|
79
79
|
# If no keypair is passed, select them all
|
@@ -21,8 +21,8 @@ module PoolParty
|
|
21
21
|
execute_on_master do
|
22
22
|
has_exec({:name => "deploy-directory-#{name}", :requires => get_directory("#{cwd}"), :cwd => cwd}) do
|
23
23
|
# && rm #{Base.tmp_path}/#{parent.name.dir_safe}.tar.gz
|
24
|
-
command "cd #{
|
25
|
-
onlyif "test -f #{Base.remote_storage_path}/#{
|
24
|
+
command "cd #{cwd}; tar -zxf #{Base.remote_storage_path}/#{name.dir_safe}.tar.gz; rm #{Base.remote_storage_path}/#{name.dir_safe}.tar.gz"
|
25
|
+
onlyif "test -f #{Base.remote_storage_path}/#{name.dir_safe}.tar.gz"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -8,17 +8,18 @@ module PoolParty
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def has_git_repos
|
11
|
-
has_package(:name => "git-core")
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
has_package(:name => "git-core") do
|
12
|
+
has_exec({:requires => get_package("git-core"), :requires => [get_directory("#{cwd}")]}) do
|
13
|
+
name key
|
14
|
+
command user ? "git clone #{user}@#{source} #{path}" : "git clone #{source} #{to ? to : ""}"
|
15
|
+
cwd "#{cwd if cwd}"
|
16
|
+
creates "#{::File.join( (cwd), ::File.basename(source, ::File.extname(source)) )}/.git"
|
17
|
+
end
|
18
|
+
has_exec(:name => "update-#{name}") do
|
19
|
+
cwd ::File.dirname( get_exec(key).creates )
|
20
|
+
command "git pull"
|
21
|
+
end
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
25
|
def at(dir)
|
data/lib/poolparty/pool/cloud.rb
CHANGED
@@ -89,7 +89,7 @@ module PoolParty
|
|
89
89
|
make_base_directory
|
90
90
|
copy_misc_templates
|
91
91
|
Base.store_keys_in_file
|
92
|
-
Script.save!
|
92
|
+
Script.save!(self)
|
93
93
|
copy_ssh_key # not my favorite...
|
94
94
|
end
|
95
95
|
|
@@ -145,12 +145,18 @@ module PoolParty
|
|
145
145
|
# Refactor this into the resources method
|
146
146
|
# TODO
|
147
147
|
services.each do |service|
|
148
|
-
|
149
|
-
|
150
|
-
str << @cp.include_string
|
148
|
+
service.options.merge!(:name => service.name)
|
149
|
+
classpackage_with_self(service)
|
151
150
|
end
|
152
151
|
|
153
|
-
|
152
|
+
global_classpackages.each do |cls|
|
153
|
+
str << cls.to_string
|
154
|
+
end
|
155
|
+
|
156
|
+
resources.each do |type, res|
|
157
|
+
str << "# #{type.to_s.pluralize}"
|
158
|
+
str << res.to_string
|
159
|
+
end
|
154
160
|
|
155
161
|
str << "# Custom functions"
|
156
162
|
str << Resources::CustomResource.custom_functions_to_string
|
@@ -158,7 +164,7 @@ module PoolParty
|
|
158
164
|
end
|
159
165
|
|
160
166
|
def build_from_existing_file
|
161
|
-
::FileTest.file?("/
|
167
|
+
::FileTest.file?("#{Base.manifest_path}/classes/poolparty.pp") ? open("#{Base.manifest_path}/classes/poolparty.pp").read : nil
|
162
168
|
end
|
163
169
|
|
164
170
|
# To allow the remote instances to do their job,
|
@@ -19,13 +19,14 @@ module PoolParty
|
|
19
19
|
|
20
20
|
def add_resource(type, opts={}, parent=self, &block)
|
21
21
|
if in_resources?(type, opts[:name])
|
22
|
-
get_resource(type, opts[:name], parent)
|
22
|
+
@res = get_resource(type, opts[:name], parent)
|
23
23
|
else
|
24
|
-
returning "PoolParty::Resources::#{type.to_s.camelize}".classify.constantize.new(opts, parent, &block) do |o|
|
24
|
+
@res = returning "PoolParty::Resources::#{type.to_s.camelize}".classify.constantize.new(opts, parent, &block) do |o|
|
25
25
|
store_into_global_resource_store(o)
|
26
26
|
resource(type) << o
|
27
27
|
end
|
28
28
|
end
|
29
|
+
@res
|
29
30
|
end
|
30
31
|
def get_resource(ty, key, parent=self)
|
31
32
|
resource(ty).select {|r| r.key == key }.first || get_from_global_resource_store(ty, key)
|
@@ -47,7 +48,7 @@ module PoolParty
|
|
47
48
|
end
|
48
49
|
#:nodoc:
|
49
50
|
def reset_resources!
|
50
|
-
$global_resources = @resources = nil
|
51
|
+
$global_resources = $global_classpackage_store = @resources = nil
|
51
52
|
end
|
52
53
|
|
53
54
|
# def resources_string(pre="")
|
@@ -104,25 +105,31 @@ module PoolParty
|
|
104
105
|
# Then it takes the value of the block and sets whatever is sent there as
|
105
106
|
# the options
|
106
107
|
# Finally, it uses the parent's options as the lowest priority
|
107
|
-
def initialize(opts={}, parent=self, &block)
|
108
|
+
def initialize(opts={}, parent=self, &block)
|
109
|
+
run_setup(parent, &block)
|
108
110
|
# Take the options of the parents
|
109
111
|
set_vars_from_options(opts) unless opts.empty?
|
110
|
-
set_resource_parent(parent)
|
111
112
|
|
112
|
-
|
113
|
-
|
113
|
+
set_resource_parent
|
114
|
+
|
114
115
|
loaded(opts, @parent)
|
115
116
|
end
|
116
117
|
|
117
118
|
# Helper to set the containing parent on the resource
|
118
|
-
def set_resource_parent
|
119
|
-
if parent && parent != self
|
120
|
-
|
121
|
-
if @parent.is_a?(PoolParty::Resources::Resource) && @parent.printable? && @parent.name != name
|
119
|
+
def set_resource_parent
|
120
|
+
if @parent && @parent != self
|
121
|
+
if can_set_requires_for_parent
|
122
122
|
# requires @parent.to_s
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
126
|
+
|
127
|
+
def can_set_requires_for_parent
|
128
|
+
@parent.is_a?(PoolParty::Resources::Resource) &&
|
129
|
+
@parent.printable? &&
|
130
|
+
@parent.name != name &&
|
131
|
+
!@parent.is_a?(PoolParty::Resources::Classpackage)
|
132
|
+
end
|
126
133
|
|
127
134
|
# Stub, so you can create virtual resources
|
128
135
|
# This is called after the resource is initialized
|
@@ -1,12 +1,51 @@
|
|
1
1
|
module PoolParty
|
2
2
|
module Resources
|
3
3
|
|
4
|
+
def global_classpackages
|
5
|
+
$global_classpackage_store ||= []
|
6
|
+
end
|
7
|
+
|
8
|
+
def in_global_classpackages?(name)
|
9
|
+
!get_from_global_classpackage_store(name).nil?
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_from_global_classpackage_store(key)
|
13
|
+
global_classpackages.select {|a| a if key == a.name }.first
|
14
|
+
end
|
15
|
+
|
16
|
+
def store_into_global_classpackage_store(r)
|
17
|
+
arr = r.is_a?(Array) ? r : [r]
|
18
|
+
arr.each do |a|
|
19
|
+
global_classpackages << a unless in_global_classpackages?(a.name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
4
23
|
# Wrap all the resources into a class package from
|
5
24
|
def classpackage_with_self(parent=self, &block)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
25
|
+
name = (parent.options.name || Classpackage.name(parent).to_s).sanitize
|
26
|
+
if in_global_classpackages?(name)
|
27
|
+
puts "#{name} already a class in the global storage"
|
28
|
+
returning get_from_global_classpackage_store(name) do |cls|
|
29
|
+
cls.run_in_context(parent, &block) if block
|
30
|
+
end
|
31
|
+
else
|
32
|
+
@@parent_resources = parent.resources
|
33
|
+
@@cp = parent.add_resource(:classpackage, parent.options.merge(:name => name), parent, &block)
|
34
|
+
@@cp = @@cp.is_a?(Array) ? @@cp[-1] : @@cp
|
35
|
+
|
36
|
+
@@cp.run_in_context(parent) do
|
37
|
+
@@parent_resources.each do |ty, res|
|
38
|
+
resources[ty] = res unless ty == :classpackage
|
39
|
+
end
|
40
|
+
end
|
41
|
+
parent.instance_eval do
|
42
|
+
@resources = {:classpackage => [@@cp]}
|
43
|
+
end
|
44
|
+
@@cp.instance_eval &block if block
|
45
|
+
|
46
|
+
store_into_global_classpackage_store(@@cp)
|
47
|
+
end
|
48
|
+
return @@cp
|
10
49
|
end
|
11
50
|
|
12
51
|
class Classpackage < Resource
|
@@ -22,48 +61,36 @@ module PoolParty
|
|
22
61
|
# self.instance_eval &block if block
|
23
62
|
run_setup(parent, &block) if block
|
24
63
|
# self.run_in_context &block if block
|
25
|
-
# store_block(&block)
|
64
|
+
# store_block(&block)
|
26
65
|
loaded
|
27
66
|
end
|
28
67
|
|
29
|
-
def to_string
|
30
|
-
|
31
|
-
|
32
|
-
output << "
|
33
|
-
output << resources_string_from_resources(resources)
|
34
|
-
output << "
|
35
|
-
end
|
68
|
+
def to_string(pre="")
|
69
|
+
"" unless resources.size > 0
|
70
|
+
returning Array.new do |output|
|
71
|
+
output << "#{pre}class #{name.sanitize.downcase} {"
|
72
|
+
output << "#{pre}#{resources_string_from_resources(resources)}"
|
73
|
+
output << "#{pre}}"
|
74
|
+
end.join("\n")
|
36
75
|
end
|
37
76
|
|
38
77
|
def include_string
|
39
78
|
"include #{name.sanitize.downcase}"
|
40
79
|
end
|
41
80
|
|
42
|
-
def
|
43
|
-
|
81
|
+
def virtual_resource?
|
82
|
+
true
|
44
83
|
end
|
84
|
+
|
45
85
|
def printable?
|
46
86
|
false
|
47
87
|
end
|
88
|
+
|
89
|
+
def self.name(parent=nil)
|
90
|
+
"custom_#{parent ? parent.object_id.to_s : "parent"}"
|
91
|
+
end
|
48
92
|
|
49
93
|
end
|
50
94
|
|
51
|
-
def resources_string_from_resources(resources, pre="\t")
|
52
|
-
@variables = resources.extract! {|name,resource| name == :variable}
|
53
|
-
returning Array.new do |str|
|
54
|
-
unless @variables.empty?
|
55
|
-
str << "\n# Variables \n"
|
56
|
-
@variables.each do |name, variable|
|
57
|
-
str << variable.to_string("#{pre}")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
resources.each do |type, resource|
|
62
|
-
str << "\n#{pre*2}# #{type}\n"
|
63
|
-
str << resource.to_string("#{pre*2}")
|
64
|
-
end
|
65
|
-
end.join("\n")
|
66
|
-
end
|
67
|
-
|
68
95
|
end
|
69
96
|
end
|
@@ -12,9 +12,10 @@ module PoolParty
|
|
12
12
|
def execute_if(attr_s="$hostname", comparison="==", str="", cust_opts={}, parent=self, &block)
|
13
13
|
# parent = parent.is_a?(PoolParty::Cloud::Cloud) ? parent : parent.parent
|
14
14
|
opts = {:attribute => attr_s, :equal => str, :comparison => comparison}.merge(cust_opts)
|
15
|
-
options = (parent.respond_to?(:options) && parent) ? parent.options.merge!(opts) : opts
|
15
|
+
options = (parent.respond_to?(:options) && parent && parent != self) ? parent.options.merge!(opts) : opts
|
16
16
|
# @c = PoolParty::Resources::Conditional.new(options, parent, &block)
|
17
|
-
conditional(options, parent, &block)
|
17
|
+
# conditional(options, parent, &block)
|
18
|
+
add_resource(:conditional, options, parent, &block)
|
18
19
|
end
|
19
20
|
|
20
21
|
class Conditional < Resource
|
@@ -20,22 +20,20 @@ module PoolParty
|
|
20
20
|
blk.to_ruby(opts)
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.for_save_string
|
23
|
+
def self.for_save_string(in_cloud=nil)
|
24
24
|
returning Array.new do |out|
|
25
|
-
clouds.each do |
|
26
|
-
|
27
|
-
|
28
|
-
cloud :#{name} do
|
25
|
+
(in_cloud ? [in_cloud] : clouds.collect {|n,cl| cl }).each do |cl|
|
26
|
+
out << <<-EOE
|
27
|
+
cloud :#{cl.name} do
|
29
28
|
#{cl.minimum_runnable_options.map {|o| "\t#{o} #{cl.send(o).respec_string}"}.join("\n")}
|
30
29
|
end
|
31
|
-
|
32
|
-
end
|
30
|
+
EOE
|
33
31
|
end
|
34
32
|
end.join("\n")
|
35
33
|
end
|
36
34
|
|
37
|
-
def self.save!(to_file=true)
|
38
|
-
write_to_file_in_storage_directory(Base.default_specfile_name, for_save_string) if to_file
|
35
|
+
def self.save!(cl=nil,to_file=true)
|
36
|
+
write_to_file_in_storage_directory(Base.default_specfile_name, for_save_string(cl)) if to_file
|
39
37
|
for_save_string
|
40
38
|
end
|
41
39
|
|
@@ -3,7 +3,4 @@
|
|
3
3
|
# /var/lib/puppet/state/puppetdlock
|
4
4
|
. /etc/profile
|
5
5
|
ps aux | grep puppetmaster | awk '{print $2}' | xargs kill
|
6
|
-
/etc/init.d/puppetmaster stop
|
7
|
-
rm -rf /etc/puppet/ssl
|
8
|
-
/etc/init.d/puppetmaster start
|
9
|
-
puppetmasterd --verbose
|
6
|
+
/etc/init.d/puppetmaster stop;rm -rf /etc/puppet/ssl;/etc/init.d/puppetmaster start;puppetmasterd --verbose
|
data/lib/poolparty/version.rb
CHANGED
data/poolparty.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poolparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.62
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Lerner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-18 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -102,9 +102,10 @@ describe "ProvisionerBase" do
|
|
102
102
|
@cloud.stub!(:keypair_path).and_return "~/.ec2/fake_keypair"
|
103
103
|
@cloud.stub!(:other_clouds).and_return []
|
104
104
|
@cloud.stub!(:expand_when).and_return "cpu > 10"
|
105
|
-
Provisioner::Master.stub!(:new).and_return @provisioner
|
106
105
|
@cloud.stub!(:copy_file_to_storage_directory).and_return true
|
107
106
|
@cloud.stub!(:rsync_storage_files_to).and_return true
|
107
|
+
@cloud.stub!(:minimum_runnable_options).and_return []
|
108
|
+
Provisioner::Master.stub!(:new).and_return @provisioner
|
108
109
|
@provisioner.stub!(:build_and_store_new_config_file).and_return true
|
109
110
|
@provisioner.stub!(:process_clean_reconfigure_for!).and_return true
|
110
111
|
end
|
@@ -14,7 +14,7 @@ describe "Remote Instance" do
|
|
14
14
|
@tc = TestClass.new
|
15
15
|
end
|
16
16
|
it "should be a string" do
|
17
|
-
@tc.has_git(:name => "gitrepos.git", :source => "git://source.git").to_string.should =~ /exec
|
17
|
+
@tc.has_git(:name => "gitrepos.git", :source => "git://source.git").to_string.should =~ /exec/
|
18
18
|
end
|
19
19
|
it "should included the flushed out options" do
|
20
20
|
@tc.has_git({:name => "git.git", :source => "git://source.git", :user => "finger"}).to_string.should =~ /finger@git:/
|
@@ -25,7 +25,7 @@ describe "Remote Instance" do
|
|
25
25
|
describe "in resource" do
|
26
26
|
before(:each) do
|
27
27
|
@tc.instance_eval do
|
28
|
-
|
28
|
+
has_git(:name => "gittr") do
|
29
29
|
source "git://source.git"
|
30
30
|
path "/var/www/xnot.org"
|
31
31
|
symlink "/var/www/xnot.org/public"
|
@@ -33,7 +33,7 @@ describe "Remote Instance" do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
it "should have the path set within the resource" do
|
36
|
-
@tc.resource(:git).first.to_string.should =~ /exec \{/
|
36
|
+
@tc.resource(:git).first.to_string.should =~ /exec \{ "gittr"/
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -290,7 +290,7 @@ describe "Cloud" do
|
|
290
290
|
File.open("test_manifest.pp", "w+") {|f| f << @manifest}
|
291
291
|
end
|
292
292
|
it "should include the hosts for all the listed local instances" do
|
293
|
-
@manifest.should =~ /master
|
293
|
+
@manifest.should =~ /master \{/
|
294
294
|
end
|
295
295
|
end
|
296
296
|
describe "building with an existing manifest" do
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
require File.dirname(__FILE__) + '/test_plugins/webserver'
|
3
2
|
|
4
3
|
include PoolParty::Resources
|
5
4
|
|
5
|
+
require File.dirname(__FILE__) + '/test_plugins/webserver'
|
6
|
+
|
6
7
|
class MyResource < PoolParty::Resources::Resource
|
7
8
|
# Just to give some options for the test class
|
8
9
|
def options(h={})
|
@@ -30,28 +31,7 @@ describe "Resource" do
|
|
30
31
|
end
|
31
32
|
describe "to_s" do
|
32
33
|
it "should be able to coalesce the instances" do
|
33
|
-
@resource.to_string.should =~ /resource \{
|
34
|
-
end
|
35
|
-
describe "with resources" do
|
36
|
-
before(:each) do
|
37
|
-
self.stub!(:options).and_return(:name => "cook")
|
38
|
-
|
39
|
-
@obj = PoolParty::Resources::Resource.new
|
40
|
-
@obj.stub!(:name).and_return "cook"
|
41
|
-
|
42
|
-
@resource2 = MyResource.new do
|
43
|
-
file(:name => "shulie")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
it "should call classpackage_with_self when it has resources" do
|
47
|
-
@resource2.should_receive(:classpackage_with_self).and_return @obj
|
48
|
-
@resource2.to_string
|
49
|
-
end
|
50
|
-
it "should call to_string on the class package" do
|
51
|
-
@obj.should_receive(:to_string).and_return "wee"
|
52
|
-
@resource2.should_receive(:classpackage_with_self).and_return @obj
|
53
|
-
@resource2.to_string
|
54
|
-
end
|
34
|
+
@resource.to_string.should =~ /resource \{/
|
55
35
|
end
|
56
36
|
end
|
57
37
|
describe "class methods" do
|
@@ -138,10 +118,19 @@ describe "Resource" do
|
|
138
118
|
before(:each) do
|
139
119
|
@cloud = cloud :command_cloud do; end
|
140
120
|
end
|
141
|
-
|
142
|
-
|
143
|
-
|
121
|
+
describe "add_resource" do
|
122
|
+
it "should call add_resource when creating using the command: file" do
|
123
|
+
@cloud.should_receive(:add_resource).with(:file, {:name => "frank"}, @cloud)
|
124
|
+
@cloud.instance_eval do
|
125
|
+
file(:name => "frank")
|
126
|
+
end
|
127
|
+
end
|
128
|
+
it "should return a resource when the resource does not exist" do
|
129
|
+
file(:name => "/etc/frank.txt").class.should == PoolParty::Resources::File
|
130
|
+
end
|
131
|
+
it "should return a resource when the resource does exist" do
|
144
132
|
file(:name => "frank")
|
133
|
+
file(:name => "frank").class.should == PoolParty::Resources::File
|
145
134
|
end
|
146
135
|
end
|
147
136
|
it "should create the new 'resource' as a resource" do
|
@@ -346,6 +335,21 @@ describe "Resource" do
|
|
346
335
|
it "should be able to get the resource from the global_resources_store by the name and type" do
|
347
336
|
@cloud2.get_from_global_resource_store(:directory, "/var/www").key.should == "/var/www"
|
348
337
|
end
|
338
|
+
describe "adding to global resource store" do
|
339
|
+
before(:each) do
|
340
|
+
@cloud3 = cloud :pumpkinpie do
|
341
|
+
file(:name => "/var/www/pumpkinfile.html")
|
342
|
+
file(:name => "/var/www/pumpkinfile.html")
|
343
|
+
apache do
|
344
|
+
file(:name => "/var/www/pumpkinfile.html")
|
345
|
+
end
|
346
|
+
end
|
347
|
+
@cloud3 = cloud(:pumpkinpie)
|
348
|
+
end
|
349
|
+
it "should not have 2 of the same resources" do
|
350
|
+
@cloud3.resource(:file).size.should == 1
|
351
|
+
end
|
352
|
+
end
|
349
353
|
describe "grabbing after already instantiated" do
|
350
354
|
before(:each) do
|
351
355
|
@cloud2.instance_eval do
|
@@ -69,21 +69,52 @@ describe "File" do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
describe "from a collection of resources to another" do
|
72
|
-
before(:each) do
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
before(:each) do
|
73
|
+
reset_resources!
|
74
|
+
cloud :bunkers do
|
75
|
+
file(:name => "franksfile")
|
76
|
+
exec(:name => "get file", :command => "kill frank for file")
|
77
|
+
end
|
78
|
+
@cloud = cloud(:bunkers)
|
79
|
+
@class2 = classpackage_with_self(@cloud)
|
76
80
|
end
|
77
81
|
it "should have the method classpackage_with_self" do
|
78
82
|
self.respond_to?(:classpackage_with_self).should == true
|
79
83
|
end
|
80
84
|
it "should transfer the resources to the class" do
|
81
|
-
@class2
|
82
|
-
|
85
|
+
@class2.resources.size.should == 2
|
86
|
+
end
|
87
|
+
it "should have the file resource in the classpackage" do
|
88
|
+
@class2.resource(:file).first.name.should == "franksfile"
|
89
|
+
end
|
90
|
+
it "should have the exec resource in the classpackage" do
|
91
|
+
@class2.resource(:exec).first.name.should == "get file"
|
92
|
+
end
|
93
|
+
it "should have the resources on the new classpackage" do
|
94
|
+
@cloud.resources.size.should == 1
|
95
|
+
end
|
96
|
+
it "should have the conditional classpackage on the resources" do
|
97
|
+
@cloud.resource(:classpackage).first.should == @class2
|
98
|
+
end
|
99
|
+
describe "to_string" do
|
100
|
+
before(:each) do
|
101
|
+
@output = @class2.to_string
|
102
|
+
end
|
103
|
+
it "should have the file in the string" do
|
104
|
+
@output.should =~ /franksfile/
|
105
|
+
end
|
106
|
+
it "should contain just the two resources in the string" do
|
107
|
+
@output.match(/(\w+) \{/).size.should == 2
|
108
|
+
end
|
109
|
+
describe "from within the cloud" do
|
110
|
+
before(:each) do
|
111
|
+
reset_resources!
|
112
|
+
@output = @cloud.build_short_manifest
|
113
|
+
end
|
114
|
+
it "should have one class" do
|
115
|
+
@output.match(/class (\w+) \{/).size.should == 2
|
116
|
+
end
|
117
|
+
end
|
83
118
|
end
|
84
|
-
# it "should leave zero resources on the parent" do
|
85
|
-
# @class2 = classpackage_with_self(self)
|
86
|
-
# resources.should be_empty
|
87
|
-
# end
|
88
119
|
end
|
89
120
|
end
|
@@ -49,6 +49,22 @@ describe "Conditional" do
|
|
49
49
|
it "should have a case statement for the hostname" do
|
50
50
|
@string.should =~ /case \$hostname/
|
51
51
|
end
|
52
|
+
describe "multiple" do
|
53
|
+
before(:each) do
|
54
|
+
reset!
|
55
|
+
@cloud = cloud :multiple_conditionals do
|
56
|
+
execute_on_master do
|
57
|
+
has_file(:name => "/etc/frank.txt")
|
58
|
+
end
|
59
|
+
execute_on_master do
|
60
|
+
has_exec(:name => "feed frank")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
it "should have two conditional resources" do
|
65
|
+
@cloud.resource(:conditional).size.should == 2
|
66
|
+
end
|
67
|
+
end
|
52
68
|
end
|
53
69
|
end
|
54
70
|
end
|
@@ -19,17 +19,18 @@ describe "Cron" do
|
|
19
19
|
end
|
20
20
|
describe "as included" do
|
21
21
|
before(:each) do
|
22
|
+
reset_resources!
|
22
23
|
@cron = cron({:rent => "low"}) do
|
23
24
|
name "/www/conf/httpd.conf"
|
24
25
|
hour 23
|
25
26
|
minute 5
|
26
|
-
weekday 1
|
27
|
+
weekday 1
|
27
28
|
end
|
28
29
|
end
|
29
30
|
it "should use default values" do
|
30
31
|
@cron.name.should == "/www/conf/httpd.conf"
|
31
32
|
end
|
32
|
-
it "should keep the default values for the
|
33
|
+
it "should keep the default values for the cron" do
|
33
34
|
@cron.user.should == "root"
|
34
35
|
end
|
35
36
|
it "should also set options through a hash" do
|
@@ -8,7 +8,7 @@ describe "Exec" do
|
|
8
8
|
end
|
9
9
|
describe "instances" do
|
10
10
|
it "should turn the one hash instance into a string" do
|
11
|
-
@exec.to_string.should =~ /exec \{
|
11
|
+
@exec.to_string.should =~ /exec \{ "\/usr\/bin\/ifconfig"/
|
12
12
|
end
|
13
13
|
it "should turn the two hash instance into a string" do
|
14
14
|
@exec = exec({:name => "/usr/bin/ping 127.0.0.1"})
|
@@ -19,7 +19,7 @@ describe "Gem" do
|
|
19
19
|
@gem.name.should == "activesupport"
|
20
20
|
end
|
21
21
|
it "should have the 'rails' gem in the packages" do
|
22
|
-
@
|
22
|
+
@gem.to_string.should =~ /activesupport/
|
23
23
|
end
|
24
24
|
describe "with parent options" do
|
25
25
|
before(:each) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auser-poolparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.62
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Lerner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-18 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|