auser-poolparty 0.2.60 → 0.2.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. data/Manifest.txt +2 -0
  2. data/README.txt +2 -0
  3. data/bin/cloud-ensure-provisioning +8 -2
  4. data/bin/cloud-provision +1 -0
  5. data/bin/pool-list +10 -2
  6. data/bin/server-send-command +18 -0
  7. data/bin/server-update-hosts +47 -0
  8. data/lib/poolparty.rb +1 -1
  9. data/lib/poolparty/aska/aska.rb +1 -1
  10. data/lib/poolparty/base_packages/haproxy.rb +2 -2
  11. data/lib/poolparty/base_packages/poolparty.rb +14 -19
  12. data/lib/poolparty/core/object.rb +7 -4
  13. data/lib/poolparty/helpers/console.rb +4 -0
  14. data/lib/poolparty/helpers/optioner.rb +3 -0
  15. data/lib/poolparty/helpers/provisioners/master.rb +18 -15
  16. data/lib/poolparty/helpers/provisioners/slave.rb +2 -1
  17. data/lib/poolparty/modules/cloud_resourcer.rb +27 -8
  18. data/lib/poolparty/modules/method_missing_sugar.rb +1 -1
  19. data/lib/poolparty/net/remote.rb +3 -0
  20. data/lib/poolparty/net/remote_bases/ec2.rb +6 -3
  21. data/lib/poolparty/net/remote_instance.rb +9 -3
  22. data/lib/poolparty/net/remoter.rb +8 -39
  23. data/lib/poolparty/net/remoter_base.rb +4 -9
  24. data/lib/poolparty/pool/base.rb +4 -3
  25. data/lib/poolparty/pool/cloud.rb +19 -23
  26. data/lib/poolparty/pool/plugin.rb +3 -27
  27. data/lib/poolparty/pool/plugin_model.rb +6 -8
  28. data/lib/poolparty/pool/pool.rb +15 -4
  29. data/lib/poolparty/pool/resource.rb +5 -10
  30. data/lib/poolparty/pool/resources/class_package.rb +6 -4
  31. data/lib/poolparty/pool/resources/conditional.rb +2 -3
  32. data/lib/poolparty/templates/puppetrerun +1 -13
  33. data/lib/poolparty/templates/puppetrunner +1 -12
  34. data/lib/poolparty/version.rb +1 -1
  35. data/poolparty.gemspec +6 -2
  36. data/spec/poolparty/aska/aska_spec.rb +0 -8
  37. data/spec/poolparty/helpers/provisioner_base_spec.rb +2 -0
  38. data/spec/poolparty/modules/cloud_resourcer_spec.rb +2 -2
  39. data/spec/poolparty/net/remoter_spec.rb +0 -106
  40. data/spec/poolparty/pool/base_spec.rb +0 -3
  41. data/spec/poolparty/pool/cloud_spec.rb +10 -19
  42. data/spec/poolparty/pool/plugin_spec.rb +2 -2
  43. data/spec/poolparty/pool/pool_spec.rb +16 -1
  44. data/spec/poolparty/pool/resource_spec.rb +1 -1
  45. metadata +6 -2
@@ -108,10 +108,13 @@ module PoolParty
108
108
  # Take the options of the parents
109
109
  set_vars_from_options(opts) unless opts.empty?
110
110
  set_resource_parent(parent)
111
- self.run_in_context &block if block
111
+
112
+ run_setup(parent, false, &block) if block
113
+ # self.run_in_context &block if block
112
114
  loaded(opts, @parent)
113
115
  end
114
116
 
117
+ # Helper to set the containing parent on the resource
115
118
  def set_resource_parent(parent=nil)
116
119
  if parent && parent != self
117
120
  @parent = parent
@@ -149,15 +152,7 @@ module PoolParty
149
152
  def custom_function(str)
150
153
  self.class.custom_functions << str
151
154
  end
152
-
153
- def cloud
154
- @p = parent
155
- while !@p.is_a?(PoolParty::Cloud)
156
- @p = @p.parent
157
- end
158
- @p
159
- end
160
-
155
+
161
156
  def self.custom_functions_to_string(pre="")
162
157
  returning Array.new do |output|
163
158
  PoolParty::Resources.available_custom_resources.each do |resource|
@@ -4,7 +4,7 @@ module PoolParty
4
4
  # Wrap all the resources into a class package from
5
5
  def classpackage_with_self(parent=self, &block)
6
6
  @cp = PoolParty::Resources::Classpackage.new(parent.options, parent, &block)
7
- @cp.instance_eval {@resources = parent.resources}
7
+ @cp.run_in_context {@resources = parent.resources}
8
8
  # parent.instance_eval {@resources = nil}
9
9
  @cp
10
10
  end
@@ -17,9 +17,11 @@ module PoolParty
17
17
 
18
18
  def initialize(opts={}, parent=self, &block)
19
19
  # Take the options of the parents
20
- set_parent(parent, false) if parent
20
+ # set_parent(parent, false) if parent
21
21
  set_vars_from_options(opts) unless opts.empty?
22
- self.instance_eval &block if block
22
+ # self.instance_eval &block if block
23
+ run_setup(parent, &block) if block
24
+ # self.run_in_context &block if block
23
25
  # store_block(&block)
24
26
  loaded
25
27
  end
@@ -38,7 +40,7 @@ module PoolParty
38
40
  end
39
41
 
40
42
  def name(*args)
41
- args.empty? ? (@name || parent.name || "custom_#{Time.now.to_i}") : @name ||= args.first
43
+ args.empty? ? (@name || (!parent.nil? && parent.name) || "custom_#{Time.now.to_i}") : @name ||= args.first
42
44
  end
43
45
  def printable?
44
46
  false
@@ -12,10 +12,9 @@ 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.options.merge!(opts) : opts
15
+ options = (parent.respond_to?(:options) && parent) ? parent.options.merge!(opts) : opts
16
16
  # @c = PoolParty::Resources::Conditional.new(options, parent, &block)
17
- parent.add_resource(:conditional, options, parent, &block)
18
- # @c
17
+ conditional(options, parent, &block)
19
18
  end
20
19
 
21
20
  class Conditional < Resource
@@ -1,16 +1,4 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  . /etc/profile
4
- if [ $(/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master) ];
5
- then
6
- echo '';
7
- else
8
- ps aux | grep puppetmaster | awk '{print $2}' | xargs kill; /etc/init.d/puppetmaster stop; rm -rf /etc/puppet/ssl; /etc/init.d/puppetmaster start
9
- if [ $(/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master) ];
10
- then
11
- echo '';
12
- else
13
- # Try again
14
- /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master 2>&1
15
- fi
16
- fi
4
+ /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
@@ -1,15 +1,4 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  . /etc/profile
4
- # rm -rf /etc/puppet/ssl
5
- if [ $(hostname) -eq "master"];
6
- then
7
- /bin/sh puppetrerun
8
- else
9
- if [ $(/usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master) ];
10
- then
11
- echo '';
12
- else
13
- /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
14
- fi
15
- fi
4
+ /usr/sbin/puppetd --onetime --no-daemonize --logdest syslog --server master
@@ -2,7 +2,7 @@ module PoolParty
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 60
5
+ TINY = 61
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
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.60
4
+ version: 0.2.61
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-14 00:00:00 -08:00
12
+ date: 2008-11-17 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -87,6 +87,7 @@ executables:
87
87
  - server-list-active
88
88
  - server-list-responding
89
89
  - server-rerun
90
+ - server-send-command
90
91
  - server-show-stats
91
92
  - server-start-client
92
93
  - server-start-master
@@ -94,6 +95,7 @@ executables:
94
95
  - server-stop-client
95
96
  - server-stop-master
96
97
  - server-stop-node
98
+ - server-update-hosts
97
99
  extensions: []
98
100
 
99
101
  extra_rdoc_files:
@@ -143,6 +145,7 @@ files:
143
145
  - bin/server-list-active
144
146
  - bin/server-list-responding
145
147
  - bin/server-rerun
148
+ - bin/server-send-command
146
149
  - bin/server-show-stats
147
150
  - bin/server-start-client
148
151
  - bin/server-start-master
@@ -150,6 +153,7 @@ files:
150
153
  - bin/server-stop-client
151
154
  - bin/server-stop-master
152
155
  - bin/server-stop-node
156
+ - bin/server-update-hosts
153
157
  - config/hoe.rb
154
158
  - config/requirements.rb
155
159
  - examples/basic.rb
@@ -13,14 +13,6 @@ describe "Rules" do
13
13
  @car = Car.new
14
14
  end
15
15
  describe "malformed rules" do
16
- it "should not put a malformed rule in the rules" do
17
- lambda {
18
- @plaster = Class.new do
19
- include Aska
20
- rules :names, "x runs b"
21
- end
22
- }.should raise_error()
23
- end
24
16
  [
25
17
  "k > 10",
26
18
  "x == 2",
@@ -100,6 +100,8 @@ describe "ProvisionerBase" do
100
100
  stub_list_from_remote_for(@cloud)
101
101
  @cloud.stub!(:keypair).and_return "fake_keypair"
102
102
  @cloud.stub!(:keypair_path).and_return "~/.ec2/fake_keypair"
103
+ @cloud.stub!(:other_clouds).and_return []
104
+ @cloud.stub!(:expand_when).and_return "cpu > 10"
103
105
  Provisioner::Master.stub!(:new).and_return @provisioner
104
106
  @cloud.stub!(:copy_file_to_storage_directory).and_return true
105
107
  @cloud.stub!(:rsync_storage_files_to).and_return true
@@ -98,12 +98,12 @@ describe "CloudResourcer" do
98
98
  @tc.should_receive(:configure).with(@testparent.options)
99
99
  end
100
100
  after do
101
- @tc.set_parent(@testparent)
101
+ @tc.run_setup(@testparent)
102
102
  end
103
103
  end
104
104
  describe "parent's services" do
105
105
  before(:each) do
106
- @tc.set_parent(@testparent)
106
+ @tc.run_setup(@testparent)
107
107
  end
108
108
  it "should set the parent" do
109
109
  @tc.parent.should == @testparent
@@ -91,111 +91,5 @@ describe "Remoter" do
91
91
  @tc.launch_and_configure_master!
92
92
  end
93
93
  end
94
- describe "listing" do
95
- before(:each) do
96
- @loc = Base.storage_directory + "/tc-instances.list"
97
- @locations = [@loc]
98
- @tc.stub!(:local_instances_list_file_locations).and_return @locations
99
- end
100
- it "should have the method list_from_local available" do
101
- TestClass.respond_to?(:list_from_local).should == true
102
- end
103
- it "should have the method list_from_remote available" do
104
- TestClass.respond_to?(:list_from_remote).should == true
105
- end
106
- describe "remote" do
107
- before(:each) do
108
- @tc.stub!(:list_of_instances).and_return @sample_instances_list
109
- @tc.stub!(:local_instances_list_file_locations).and_return [
110
- "#{Base.storage_directory}/tc-instances.list"
111
- ]
112
- end
113
- it "should call list_of_instances when trying to list from remote" do
114
- TestClass.should_receive(:list_of_instances).once.and_return @sample_instances_list
115
- TestClass.list_from_remote
116
- end
117
- it "should create a new RemoteInstance for each hashed instance" do
118
- PoolParty::Remote::RemoteInstance.should_receive(:new).exactly(2).and_return @ri
119
- @tc.list_from_remote
120
- end
121
- it "should return a string" do
122
- @tc.list_from_remote.class.should == Array
123
- end
124
- it "should contain the master in the listing" do
125
- @tc.list_from_remote.first.name.should == "master"
126
- @tc.list_from_remote.first.master?.should == true
127
- end
128
- it "should write to the first (preferred) local instances list file location for next time" do
129
- @tc.list_from_remote(:cache => true)
130
- ::File.file?(@tc.local_instances_list_file_locations.first).should == true
131
- end
132
- after(:all) do
133
- # Cleanup after ourselves
134
- # FileUtils.rm @loc if ::File.file?(@loc)
135
- end
136
- end
137
- describe "local" do
138
- describe "listing" do
139
- before(:each) do
140
- stub_list_from_remote_for(@tc)
141
- @tc.stub!(:list_of_instances).and_return([@ri])
142
- end
143
- it "should call local_instances_list_file_locations" do
144
- @tc.should_receive(:local_instances_list_file_locations).at_least(1).and_return [@loc]
145
- end
146
- it "should call File.file? on the local_instances_list_file_locations locations" do
147
- File.should_receive(:file?).with(@loc).at_least(1).and_return false
148
- end
149
- it "should call get_working_listing_file to get the working local instance file" do
150
- @tc.should_receive(:get_working_listing_file).at_least(1).and_return nil
151
- end
152
- after(:each) do
153
- @tc.list_from_local
154
- end
155
- end
156
- describe "with listing" do
157
- before(:each) do
158
- str = "master 192.168.0.1
159
- node1 192.168.0.2"
160
- @loc.stub!(:read).and_return str
161
- TestClass.stub!(:open).and_return @loc
162
- TestClass.stub!(:get_working_listing_file).and_return @loc
163
- @ri = PoolParty::Remote::RemoteInstance.new({:ip => "192.168.0.1", :name => "master"})
164
- PoolParty::Remote::RemoteInstance.stub!(:new).and_return @ri
165
- stub_list_from_remote_for(@tc)
166
- end
167
- it "should call open on the get_working_listing_file" do
168
- @tc.should_receive(:open).with(@loc).at_least(1).and_return @loc
169
- @tc.list_from_local
170
- end
171
- it "should create a new RemoteInstance for each line in the file" do
172
- PoolParty::Remote::RemoteInstance.should_receive(:new).at_least(2)
173
- @tc.list_from_local
174
- end
175
- it "should return a string" do
176
- @tc.list_from_local.class.should == Array
177
- end
178
- it "should have the name of the master and the ip in the list_from_local" do
179
- @tc.list_from_local[0].name.should == "master"
180
- end
181
- it "should have name in the listing" do
182
- @ri.should_receive(:name).at_least(1).and_return "node0"
183
- @ri.to_s
184
- end
185
- it "should have the ip in the listing" do
186
- @ri.should_receive(:ip).at_least(1).and_return "127.0.0.1"
187
- @ri.to_s
188
- end
189
- it "should call to_s on the RemoteInstance instances" do
190
- PoolParty::Remote::RemoteInstance.should_receive(:new).at_least(2).and_return @ri
191
- @ri.should_receive(:to_s).at_least(1)
192
- @ri.to_s
193
- end
194
- end
195
- after(:each) do
196
- @tc.list_from_local
197
- end
198
- end
199
- end
200
94
 
201
95
  end
@@ -5,9 +5,6 @@ describe "Base" do
5
5
  ENV.stub!(:[]).with("AWS_ACCESS_KEY_ID").and_return "KEY"
6
6
  ENV.stub!(:[]).with("AWS_SECRET_ACCESS_KEY").and_return "SECRET"
7
7
  end
8
- it "should set the environment, if not set to production" do
9
- Base.environment.should == "production"
10
- end
11
8
  it "should set the user to root" do
12
9
  Base.user.should == "root"
13
10
  end
@@ -185,6 +185,10 @@ describe "Cloud" do
185
185
  it "should it should have the method build_manifest" do
186
186
  @cloud.respond_to?(:build_manifest).should == true
187
187
  end
188
+ it "should make a new 'haproxy' class" do
189
+ PoolPartyHaproxyClass.should_receive(:new).once
190
+ @cloud.add_poolparty_base_requirements
191
+ end
188
192
  it "should have 3 resources" do
189
193
  @cloud.add_poolparty_base_requirements
190
194
  @cloud.number_of_resources.should > 2
@@ -223,7 +227,7 @@ describe "Cloud" do
223
227
  describe "after adding" do
224
228
  before(:each) do
225
229
  stub_list_from_remote_for(@cloud)
226
- @cloud.add_poolparty_base_requirements
230
+ @cloud.add_poolparty_base_requirements
227
231
  end
228
232
  it "should add resources onto the heartbeat class inside the cloud" do
229
233
  @cloud.services.size.should > 0
@@ -260,7 +264,9 @@ describe "Cloud" do
260
264
  node1 192.168.0.2"
261
265
  @sample_instances_list = [{:ip => "192.168.0.1", :name => "master"}, {:ip => "192.168.0.2", :name => "node1"}]
262
266
  @ris = @sample_instances_list.map {|h| PoolParty::Remote::RemoteInstance.new(h, @cloud) }
263
-
267
+
268
+ stub_remoter_for(@cloud)
269
+
264
270
  @manifest = @cloud.build_manifest
265
271
  end
266
272
  it "should return a string when calling build_manifest" do
@@ -272,8 +278,8 @@ describe "Cloud" do
272
278
  it "should have the comment of a package in the manifest" do
273
279
  @manifest.should =~ /package \{/
274
280
  end
275
- it "should have the comment for heartbeat in the manifest" do
276
- @manifest.should =~ /class heartbeat/
281
+ it "should have the comment for haproxy in the manifest" do
282
+ @manifest.should =~ /haproxy/
277
283
  end
278
284
  it "should include the poolparty gem" do
279
285
  @manifest.should =~ /package \{/
@@ -317,21 +323,6 @@ describe "Cloud" do
317
323
  @cloud3.master.should_not be_nil
318
324
  end
319
325
  end
320
-
321
- describe "provisioning" do
322
- it "should be able to tell that it is provisioning when setting the provisioning flag" do
323
- @cloud.provisioning?.should == false
324
- end
325
- it "should be able to set it as provisioning" do
326
- @cloud.provisioning_in_progress
327
- @cloud.provisioning?.should == true
328
- end
329
- it "should be able to unset itself as provisioning" do
330
- @cloud.provisioning_in_progress
331
- @cloud.provisioning_complete
332
- @cloud.provisioning?.should == false
333
- end
334
- end
335
326
  end
336
327
  end
337
328
  end
@@ -28,8 +28,8 @@ describe "Plugin" do
28
28
  @c.parent.should == @p
29
29
  end
30
30
  describe "instance" do
31
- before(:each) do
32
- @plugin = "apache".class_constant.new(@c)
31
+ before(:each) do
32
+ @plugin = @c.apache
33
33
  end
34
34
  it "should not be empty" do
35
35
  @plugin.class.should == PoolPartyApacheClass
@@ -78,6 +78,21 @@ describe "Pool" do
78
78
  @pool.maximum_instances.should == 5
79
79
  end
80
80
  end
81
- end
81
+ end
82
+ describe "with clouds" do
83
+ before(:each) do
84
+ reset!
85
+ @pool = Pool.new :test do
86
+ cloud :app
87
+ cloud :db
88
+ end
89
+ end
90
+ it "should have 2 clouds in the pool when there are 2 described" do
91
+ @pool.clouds.size.should == 2
92
+ end
93
+ it "should be able to tel the other clouds from within one cloud" do
94
+ cloud(:app).other_clouds.should == [cloud(:db)]
95
+ end
96
+ end
82
97
  end
83
98
  end
@@ -225,7 +225,7 @@ describe "Resource" do
225
225
  end
226
226
  describe "parent" do
227
227
  before(:each) do
228
- @cloud = cloud :app do
228
+ @cloud = cloud :orange do
229
229
  tangerine "orange"
230
230
  file(:name => "file.txt")
231
231
  end