boxgrinder-build 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/CHANGELOG +11 -0
  2. data/README.md +32 -34
  3. data/Rakefile +7 -1
  4. data/bin/boxgrinder-build +10 -17
  5. data/boxgrinder-build.gemspec +7 -4
  6. data/lib/boxgrinder-build/appliance.rb +13 -16
  7. data/lib/boxgrinder-build/helpers/guestfs-helper.rb +84 -40
  8. data/lib/boxgrinder-build/helpers/image-helper.rb +54 -85
  9. data/lib/boxgrinder-build/helpers/linux-helper.rb +29 -9
  10. data/lib/boxgrinder-build/helpers/plugin-helper.rb +1 -0
  11. data/lib/boxgrinder-build/plugins/base-plugin.rb +3 -2
  12. data/lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb +13 -42
  13. data/lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb +209 -0
  14. data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +8 -4
  15. data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +0 -7
  16. data/lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb +4 -1
  17. data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb +52 -9
  18. data/lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb +6 -2
  19. data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +4 -44
  20. data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit +1 -1
  21. data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit +1 -1
  22. data/lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst +2 -2
  23. data/lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb +24 -13
  24. data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx +2 -2
  25. data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +0 -1
  26. data/rubygem-boxgrinder-build.spec +23 -1
  27. data/spec/appliance-spec.rb +5 -79
  28. data/spec/helpers/augeas-helper-spec.rb +1 -0
  29. data/spec/helpers/guestfs-helper-spec.rb +79 -62
  30. data/spec/helpers/image-helper-spec.rb +88 -129
  31. data/spec/helpers/linux-helper-spec.rb +22 -5
  32. data/spec/helpers/package-helper-spec.rb +1 -0
  33. data/spec/helpers/plugin-helper-spec.rb +1 -0
  34. data/spec/managers/plugin-manager-spec.rb +3 -2
  35. data/spec/plugins/base-plugin-spec.rb +1 -1
  36. data/spec/plugins/delivery/ebs/ebs-plugin-spec.rb +21 -13
  37. data/spec/plugins/delivery/elastichosts/elastichosts-plugin-spec.rb +320 -0
  38. data/spec/plugins/delivery/local/local-plugin-spec.rb +1 -0
  39. data/spec/plugins/delivery/s3/s3-plugin-spec.rb +1 -0
  40. data/spec/plugins/delivery/sftp/sftp-plugin-spec.rb +1 -0
  41. data/spec/plugins/os/centos/centos-plugin-spec.rb +1 -0
  42. data/spec/plugins/os/fedora/fedora-plugin-spec.rb +13 -1
  43. data/spec/plugins/os/rhel/rhel-plugin-spec.rb +1 -15
  44. data/spec/plugins/os/rpm-based/kickstart-spec.rb +1 -0
  45. data/spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb +75 -15
  46. data/spec/plugins/os/rpm-based/rpm-dependency-validator-spec.rb +1 -0
  47. data/spec/plugins/platform/ec2/ec2-plugin-spec.rb +10 -43
  48. data/spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb +89 -10
  49. data/spec/plugins/platform/vmware/vmware-plugin-spec.rb +3 -2
  50. metadata +21 -7
  51. data/lib/boxgrinder-build/helpers/appliance-customize-helper.rb +0 -45
  52. data/spec/helpers/appliance-customize-helper-spec.rb +0 -74
@@ -16,6 +16,7 @@
16
16
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
+ require 'rubygems'
19
20
  require 'logger'
20
21
  require 'boxgrinder-build/plugins/delivery/ebs/ebs-plugin'
21
22
  require 'hashery/opencascade'
@@ -70,6 +71,8 @@ module BoxGrinder
70
71
  end
71
72
 
72
73
  it "should register all operating systems with specific versions" do
74
+ Resolv.stub!(:getname).with("169.254.169.254").and_return([".ec2.internal"])
75
+
73
76
  prepare_plugin do |plugin|
74
77
  avaibility_zone = mock('AZ')
75
78
  avaibility_zone.should_receive(:string).and_return('avaibility-zone1')
@@ -87,6 +90,8 @@ module BoxGrinder
87
90
 
88
91
  describe ".after_init" do
89
92
  it "should set default avaibility zone to current one" do
93
+ Resolv.stub!(:getname).with("169.254.169.254").and_return([".ec2.internal"])
94
+
90
95
  prepare_plugin do |plugin|
91
96
  avaibility_zone = mock('AZ')
92
97
  avaibility_zone.should_receive(:string).and_return('avaibility-zone1')
@@ -98,15 +103,16 @@ module BoxGrinder
98
103
  end
99
104
 
100
105
  it "should not set default avaibility zone because we're not on EC2" do
101
- prepare_plugin do |plugin|
102
- plugin.should_receive(:open).with('http://169.254.169.254/latest/meta-data/placement/availability-zone').and_raise("Bleh")
103
- end
106
+ Resolv.stub!(:getname).with("169.254.169.254").and_return(["bleh"])
107
+
108
+ prepare_plugin
104
109
 
105
110
  @plugin.instance_variable_get(:@plugin_config)['availability_zone'].should == nil
106
111
  end
107
112
  end
108
113
 
109
114
  describe '.already_registered?' do
115
+
110
116
  it "should check if image is already registered and return false if there are no images registered for this account" do
111
117
  prepare_plugin { |plugin| plugin.stub!(:after_init) }
112
118
 
@@ -140,6 +146,8 @@ module BoxGrinder
140
146
  end
141
147
 
142
148
  it "should check if image is already registered and return true image is registered" do
149
+ Resolv.stub!(:getname).with("169.254.169.254").and_return([".ec2.internal"])
150
+
143
151
  prepare_plugin { |plugin| plugin.stub!(:after_init) }
144
152
 
145
153
  plugin_config = mock('PluginConfiig')
@@ -159,12 +167,12 @@ module BoxGrinder
159
167
  it "should adjust fstab" do
160
168
  prepare_plugin { |plugin| plugin.stub!(:after_init) }
161
169
 
162
- exec_helper = @plugin.instance_variable_get(:@exec_helper)
170
+ guestfs = mock('GuestFS')
163
171
 
164
- exec_helper.should_receive(:execute).with("cat a/dir/etc/fstab | grep -v '/mnt' | grep -v '/data' | grep -v 'swap' > a/dir/etc/fstab.new")
165
- exec_helper.should_receive(:execute).with("mv a/dir/etc/fstab.new a/dir/etc/fstab")
172
+ guestfs.should_receive(:sh).with("cat /etc/fstab | grep -v '/mnt' | grep -v '/data' | grep -v 'swap' > /etc/fstab.new")
173
+ guestfs.should_receive(:mv).with("/etc/fstab.new", "/etc/fstab")
166
174
 
167
- @plugin.adjust_fstab('a/dir')
175
+ @plugin.adjust_fstab(guestfs)
168
176
  end
169
177
 
170
178
  it "should get a new free device" do
@@ -187,18 +195,18 @@ module BoxGrinder
187
195
  @plugin.free_device_suffix.should == "g"
188
196
  end
189
197
 
190
- it "should should return true if on EC2" do
191
- prepare_plugin { |plugin| plugin.stub!(:after_init) }
198
+ it "should return true if on EC2" do
199
+ Resolv.stub!(:getname).with("169.254.169.254").and_return([".ec2.internal"])
192
200
 
193
- @plugin.should_receive(:open).with("http://169.254.169.254/1.0/meta-data/local-ipv4")
201
+ prepare_plugin { |plugin| plugin.stub!(:after_init) }
194
202
 
195
203
  @plugin.valid_platform?.should == true
196
204
  end
197
205
 
198
- it "should should return true if NOT on EC2" do
199
- prepare_plugin { |plugin| plugin.stub!(:after_init) }
206
+ it "should return false if NOT on EC2" do
207
+ Resolv.stub!(:getname).with("169.254.169.254").and_return(["bleh"])
200
208
 
201
- @plugin.should_receive(:open).with("http://169.254.169.254/1.0/meta-data/local-ipv4").and_raise("Bleh")
209
+ prepare_plugin { |plugin| plugin.stub!(:after_init) }
202
210
 
203
211
  @plugin.valid_platform?.should == false
204
212
  end
@@ -0,0 +1,320 @@
1
+ #
2
+ # Copyright 2010 Red Hat, Inc.
3
+ #
4
+ # This is free software; you can redistribute it and/or modify it
5
+ # under the terms of the GNU Lesser General Public License as
6
+ # published by the Free Software Foundation; either version 3 of
7
+ # the License, or (at your option) any later version.
8
+ #
9
+ # This software is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this software; if not, write to the Free
16
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
+
19
+ require 'rubygems'
20
+ require 'boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin'
21
+ require 'hashery/opencascade'
22
+
23
+ module BoxGrinder
24
+ describe ElasticHostsPlugin do
25
+
26
+ def merge_config(config = {})
27
+ @plugin_config = @plugin.instance_variable_get(:@plugin_config).merge(config)
28
+ @plugin.instance_variable_set(:@plugin_config, @plugin_config)
29
+ end
30
+
31
+ before(:each) do
32
+ @config = mock('Config')
33
+ @config.stub!(:delivery_config).and_return({})
34
+ @config.stub!(:file).and_return('configfile')
35
+ plugins = mock('Plugins')
36
+ plugins.stub!(:[]).with('elastichosts').and_return({})
37
+ @config.stub!(:[]).with(:plugins).and_return(plugins)
38
+
39
+ @appliance_config = mock('ApplianceConfig')
40
+
41
+ @appliance_config.stub!(:path).and_return(OpenCascade.new({:build => 'build/path'}))
42
+ @appliance_config.stub!(:name).and_return('appliance')
43
+ @appliance_config.stub!(:version).and_return(1)
44
+ @appliance_config.stub!(:cpus).and_return(1)
45
+ @appliance_config.stub!(:release).and_return(0)
46
+ @appliance_config.stub!(:os).and_return(OpenCascade.new({:name => :fedora, :version => '13'}))
47
+ @appliance_config.stub!(:hardware).and_return(OpenCascade.new(:cpus => 1, :arch => 'x86_64', :partitions => {'/' => {'size' => 1}, '/home' => {'size' => 2}}, :memory => 512))
48
+
49
+ @plugin = ElasticHostsPlugin.new.init(@config, @appliance_config,
50
+ :log => LogHelper.new(:level => :trace, :type => :stdout),
51
+ :plugin_info => {:class => BoxGrinder::ElasticHostsPlugin, :type => :delivery, :name => :elastichosts, :full_name => "ElasticHosts"}
52
+ )
53
+
54
+ @plugin.instance_variable_set(:@previous_plugin_info, :type => :os)
55
+
56
+ @config = @plugin.instance_variable_get(:@config)
57
+ @appliance_config = @plugin.instance_variable_get(:@appliance_config)
58
+ @exec_helper = @plugin.instance_variable_get(:@exec_helper)
59
+ @log = @plugin.instance_variable_get(:@log)
60
+ @dir = @plugin.instance_variable_get(:@dir)
61
+
62
+ merge_config('username' => '12345', 'password' => 'secret_access_key', 'endpoint' => 'one.endpoint.somewhere.com')
63
+ end
64
+
65
+ describe ".elastichosts_api_url" do
66
+ it "should return valid url for default schema" do
67
+ @plugin.api_url('/drive/1').should == 'http://12345:secret_access_key@one.endpoint.somewhere.com/drive/1'
68
+ end
69
+
70
+ it "should return valid url for SSL" do
71
+ merge_config('ssl' => true)
72
+ @plugin.api_url('/drive/1').should == 'https://12345:secret_access_key@one.endpoint.somewhere.com/drive/1'
73
+ end
74
+ end
75
+
76
+ it "should return valid disk_size" do
77
+ @plugin.disk_size.should == 3
78
+ end
79
+
80
+ describe ".execute" do
81
+ it "should fail because we try to upload a non-base appliance" do
82
+ @plugin.instance_variable_set(:@previous_plugin_info, :type => :platform)
83
+ @plugin.should_not_receive(:upload)
84
+ @plugin.should_not_receive(:create_server)
85
+
86
+ lambda {
87
+ @plugin.execute
88
+ }.should raise_error(PluginValidationError, 'You can use ElasticHosts plugin with base appliances (appliances created with operating system plugins) only, see http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#ElasticHosts_Delivery_Plugin.')
89
+ end
90
+
91
+ it "should upload the appliance" do
92
+ @plugin.should_receive(:upload)
93
+ @plugin.should_receive(:create_server)
94
+ @plugin.execute
95
+ end
96
+ end
97
+
98
+ it "should convert hash to request" do
99
+ @plugin.hash_to_request('abc' => 'def', 'one' => 1234).should == "abc def\none 1234\n"
100
+ end
101
+
102
+ describe ".create_remote_disk" do
103
+ it "should create remote disk with default name" do
104
+ @plugin.should_receive(:hash_to_request).with('size' => 3221225472, 'name' => 'appliance').and_return("json")
105
+
106
+ RestClient.should_receive(:post).with("http://12345:secret_access_key@one.endpoint.somewhere.com/drives/create",
107
+ "json").and_return("drive abc-1234567890-abc\n")
108
+ @plugin.create_remote_disk.should == 'abc-1234567890-abc'
109
+ end
110
+
111
+ it "should create remote disk with custom name" do
112
+ merge_config('drive_name' => 'thisisadrivename')
113
+
114
+ @plugin.should_receive(:hash_to_request).with('size' => 3221225472, 'name' => 'thisisadrivename').and_return("json")
115
+
116
+ RestClient.should_receive(:post).with("http://12345:secret_access_key@one.endpoint.somewhere.com/drives/create",
117
+ "json").and_return("drive abc-1234567890-abc\n")
118
+ @plugin.create_remote_disk.should == 'abc-1234567890-abc'
119
+ end
120
+
121
+ it "should catch remote disk creation error" do
122
+ @plugin.should_receive(:hash_to_request).with('size' => 3221225472, 'name' => 'appliance').and_return("json")
123
+
124
+ RestClient.should_receive(:post).with("http://12345:secret_access_key@one.endpoint.somewhere.com/drives/create",
125
+ "json").and_raise('boom')
126
+
127
+ lambda {
128
+ @plugin.create_remote_disk
129
+ }.should raise_error(PluginError, 'An error occured while creating the drive, boom. See logs for more info.')
130
+ end
131
+ end
132
+
133
+ describe ".upload" do
134
+ it "create the disk and upload" do
135
+ @plugin.should_receive(:create_remote_disk)
136
+ @plugin.should_receive(:upload_chunks)
137
+ @plugin.upload
138
+ end
139
+
140
+ it "upload using existing disk" do
141
+ merge_config('drive_uuid' => 'thisisadrivename')
142
+
143
+ @plugin.should_not_receive(:create_remote_disk)
144
+ @plugin.should_receive(:upload_chunks)
145
+ @plugin.upload
146
+ end
147
+ end
148
+
149
+ it "should compress data chunk" do
150
+ stringio = mock(StringIO)
151
+ stringio.should_receive(:string).and_return("compressed_data")
152
+ stringio.should_receive(:size).and_return(2048)
153
+
154
+ gzipwriter = mock(Zlib::GzipWriter)
155
+ gzipwriter.should_receive(:write).with("data")
156
+ gzipwriter.should_receive(:close)
157
+
158
+ StringIO.should_receive(:new).and_return(stringio)
159
+ Zlib::GzipWriter.should_receive(:new).with(stringio, Zlib::DEFAULT_COMPRESSION, Zlib::FINISH).and_return(gzipwriter)
160
+
161
+ @plugin.compress("data").should == "compressed_data"
162
+ end
163
+
164
+ describe ".upload_chunks" do
165
+ it "should upload chunks in 2 parts" do
166
+ @plugin.instance_variable_set(:@previous_deliverables, {:disk => 'a/disk'})
167
+
168
+ f = mock(File)
169
+ f.should_receive(:eof?).ordered.and_return(false)
170
+ f.should_receive(:seek).ordered.with(0, File::SEEK_SET)
171
+ f.should_receive(:read).ordered.with(67108864).and_return("data")
172
+
173
+ @plugin.should_receive(:compress).ordered.with("data").and_return("compressed_data")
174
+ @plugin.should_receive(:upload_chunk).ordered.with("compressed_data", 0)
175
+
176
+ f.should_receive(:eof?).ordered.and_return(false)
177
+ f.should_receive(:seek).ordered.with(67108864, File::SEEK_SET)
178
+ f.should_receive(:read).ordered.with(67108864).and_return("data")
179
+
180
+ @plugin.should_receive(:compress).ordered.with("data").and_return("compressed_data")
181
+ @plugin.should_receive(:upload_chunk).ordered.with("compressed_data", 1)
182
+
183
+ f.should_receive(:eof?).ordered.and_return(true)
184
+
185
+ File.should_receive(:open).with('a/disk', 'rb').and_yield(f)
186
+ @plugin.upload_chunks
187
+ end
188
+
189
+ it "should upload 1 chunk with custom chunk size" do
190
+ merge_config('chunk' => 128)
191
+ @plugin.instance_variable_set(:@previous_deliverables, {:disk => 'a/disk'})
192
+
193
+ f = mock(File)
194
+ f.should_receive(:eof?).ordered.and_return(false)
195
+ f.should_receive(:seek).ordered.with(0, File::SEEK_SET)
196
+ f.should_receive(:read).ordered.with(134217728).and_return("data")
197
+
198
+ @plugin.should_receive(:compress).ordered.with("data").and_return("compressed_data")
199
+ @plugin.should_receive(:upload_chunk).ordered.with("compressed_data", 0)
200
+
201
+ f.should_receive(:eof?).ordered.and_return(true)
202
+
203
+ File.should_receive(:open).with('a/disk', 'rb').and_yield(f)
204
+ @plugin.upload_chunks
205
+ end
206
+ end
207
+
208
+ describe ".upload_chunk" do
209
+ before :each do
210
+ merge_config('drive_uuid' => 'drive-uuid')
211
+ @plugin.instance_variable_set(:@step, 134217728)
212
+ end
213
+
214
+ it "should upload a chunk of data" do
215
+ @plugin.should_receive(:api_url).with('/drives/drive-uuid/write/134217728').and_return('url')
216
+ RestClient.should_receive(:post).with('url', 'data', :content_type=>"application/octet-stream", "Content-Encoding"=>"gzip")
217
+ @plugin.upload_chunk("data", 1)
218
+ end
219
+
220
+ it "should upload a chunk of data and be succesful after 1 retry" do
221
+ @plugin.should_receive(:api_url).with('/drives/drive-uuid/write/0').and_return('url')
222
+ RestClient.should_receive(:post).with('url', 'data', :content_type=>"application/octet-stream", "Content-Encoding"=>"gzip").and_raise('boom')
223
+ @plugin.should_receive(:sleep).with(5)
224
+ RestClient.should_receive(:post).with('url', 'data', :content_type=>"application/octet-stream", "Content-Encoding"=>"gzip")
225
+
226
+ @plugin.upload_chunk("data", 0)
227
+ end
228
+
229
+ it "should fail the upload after 3 retries" do
230
+ @plugin.should_receive(:api_url).with('/drives/drive-uuid/write/0').and_return('url')
231
+ RestClient.should_receive(:post).exactly(3).times.with('url', 'data', :content_type=>"application/octet-stream", "Content-Encoding"=>"gzip").and_raise('boom')
232
+ @plugin.should_receive(:sleep).exactly(2).times.with(5)
233
+
234
+ lambda {
235
+ @plugin.upload_chunk("data", 0)
236
+ }.should raise_error(PluginError, "Couldn't upload appliance, boom.")
237
+ end
238
+
239
+ it "should fail the upload after custom sleep time and retry count" do
240
+ merge_config('retry' => 5, 'wait' => 30)
241
+
242
+ @plugin.should_receive(:api_url).with('/drives/drive-uuid/write/0').and_return('url')
243
+ RestClient.should_receive(:post).exactly(5).times.with('url', 'data', :content_type=>"application/octet-stream", "Content-Encoding"=>"gzip").and_raise('boom')
244
+ @plugin.should_receive(:sleep).exactly(4).times.with(30)
245
+
246
+ lambda {
247
+ @plugin.upload_chunk("data", 0)
248
+ }.should raise_error(PluginError, "Couldn't upload appliance, boom.")
249
+ end
250
+ end
251
+
252
+ describe ".create_server" do
253
+ before(:each) do
254
+ merge_config('drive_uuid' => '12345-asdf')
255
+
256
+ @plugin.should_receive(:hash_to_request).with(
257
+ 'name' => "appliance-1.0",
258
+ 'cpu' => 1000,
259
+ 'smp' => 'auto',
260
+ 'mem' => 512,
261
+ 'persistent' => 'true',
262
+ 'ide:0:0' => '12345-asdf',
263
+ 'boot' => 'ide:0:0',
264
+ 'nic:0:model' => 'e1000',
265
+ 'nic:0:dhcp' => 'auto',
266
+ 'vnc:ip' => 'auto',
267
+ 'vnc:password' => an_instance_of(String)
268
+ ).and_return("json")
269
+ end
270
+
271
+ it "should create the server without issues" do
272
+ RestClient.should_receive(:post).with("http://12345:secret_access_key@one.endpoint.somewhere.com/servers/create/stopped",
273
+ "json").and_return("server abc-1234567890-abc\nname appliance-1.0\n")
274
+
275
+ @plugin.create_server
276
+ end
277
+
278
+ it "should create the server with 512 MB of ram for instances to be uploaded to cloudsigma" do
279
+ merge_config('endpoint' => 'api.cloudsigma.com')
280
+
281
+ @appliance_config.stub!(:hardware).and_return(OpenCascade.new(:cpus => 1, :arch => 'x86_64', :partitions => {'/' => {'size' => 1}, '/home' => {'size' => 2}}, :memory => 256))
282
+
283
+ RestClient.should_receive(:post).with("http://12345:secret_access_key@api.cloudsigma.com/servers/create",
284
+ "json").and_return("server abc-1234567890-abc\nname appliance-1.0\n")
285
+
286
+ @plugin.create_server
287
+ end
288
+
289
+ it "should create the server without issues for cloudsigma cloud" do
290
+ merge_config('endpoint' => 'api.cloudsigma.com')
291
+
292
+ RestClient.should_receive(:post).with("http://12345:secret_access_key@api.cloudsigma.com/servers/create",
293
+ "json").and_return("server abc-1234567890-abc\nname appliance-1.0\n")
294
+
295
+ @plugin.create_server
296
+ end
297
+
298
+ it "should catch remote disk creation error" do
299
+ RestClient.should_receive(:post).with("http://12345:secret_access_key@one.endpoint.somewhere.com/servers/create/stopped",
300
+ "json").and_raise('boom')
301
+
302
+ lambda {
303
+ @plugin.create_server
304
+ }.should raise_error(PluginError, 'An error occured while creating the server, boom. See logs for more info.')
305
+ end
306
+ end
307
+
308
+ describe ".is_cloudsigma?" do
309
+ it "should return true if we're talking to cloudsigma endpoint" do
310
+ merge_config('endpoint' => 'api.cloudsigma.com')
311
+ @plugin.is_cloudsigma?.should == true
312
+ end
313
+
314
+ it "should return false if we're NOT talking to cloudsigma endpoint" do
315
+ @plugin.is_cloudsigma?.should == false
316
+ end
317
+ end
318
+ end
319
+ end
320
+
@@ -16,6 +16,7 @@
16
16
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
+ require 'rubygems'
19
20
  require 'boxgrinder-build/plugins/delivery/local/local-plugin'
20
21
  require 'hashery/opencascade'
21
22
 
@@ -16,6 +16,7 @@
16
16
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
+ require 'rubygems'
19
20
  require 'boxgrinder-build/plugins/delivery/s3/s3-plugin'
20
21
  require 'hashery/opencascade'
21
22
  # TODO remove this when it'll become not necessary
@@ -16,6 +16,7 @@
16
16
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
+ require 'rubygems'
19
20
  require 'boxgrinder-build/plugins/delivery/sftp/sftp-plugin'
20
21
 
21
22
  module BoxGrinder
@@ -16,6 +16,7 @@
16
16
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
+ require 'rubygems'
19
20
  require 'boxgrinder-build/plugins/os/centos/centos-plugin'
20
21
  require 'hashery/opencascade'
21
22
 
@@ -16,6 +16,7 @@
16
16
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
+ require 'rubygems'
19
20
  require 'boxgrinder-build/plugins/os/fedora/fedora-plugin'
20
21
  require 'hashery/opencascade'
21
22
 
@@ -46,7 +47,7 @@ module BoxGrinder
46
47
  @log = @plugin.instance_variable_get(:@log)
47
48
  end
48
49
 
49
- it "should normalize packages for 32bit" do
50
+ it "should normalize packages for 32bit for pae enabled system" do
50
51
  packages = ['abc', 'def', 'kernel']
51
52
 
52
53
  @appliance_config.should_receive(:is64bit?).and_return(false)
@@ -55,6 +56,17 @@ module BoxGrinder
55
56
  packages.should == ["abc", "def", "@core", "system-config-firewall-base", "dhclient", "kernel-PAE"]
56
57
  end
57
58
 
59
+ it "should normalize packages for 32bit for pae enabled system" do
60
+ @appliance_config.stub!(:os).and_return(OpenCascade.new(:name => 'fedora', :version => '13', :pae => false))
61
+
62
+ packages = ['abc', 'def', 'kernel']
63
+
64
+ @appliance_config.should_receive(:is64bit?).and_return(false)
65
+
66
+ @plugin.normalize_packages(packages)
67
+ packages.should == ["abc", "def", "@core", "system-config-firewall-base", "dhclient", "kernel"]
68
+ end
69
+
58
70
  it "should normalize packages for 64bit" do
59
71
  packages = ['abc', 'def', 'kernel']
60
72
 
@@ -16,6 +16,7 @@
16
16
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
+ require 'rubygems'
19
20
  require 'boxgrinder-build/plugins/os/rhel/rhel-plugin'
20
21
  require 'hashery/opencascade'
21
22
 
@@ -99,7 +100,6 @@ module BoxGrinder
99
100
 
100
101
  @appliance_config.stub!(:packages).and_return([])
101
102
 
102
- @plugin.should_receive(:adjust_partition_table).ordered
103
103
  @plugin.should_receive(:normalize_packages).ordered
104
104
 
105
105
  guestfs = mock('guestfs')
@@ -117,7 +117,6 @@ module BoxGrinder
117
117
 
118
118
  @appliance_config.stub!(:packages).and_return(['kernel-xen'])
119
119
 
120
- @plugin.should_receive(:adjust_partition_table).ordered
121
120
  @plugin.should_receive(:normalize_packages).ordered
122
121
 
123
122
  guestfs = mock('guestfs')
@@ -133,7 +132,6 @@ module BoxGrinder
133
132
  it "should build the appliance" do
134
133
  @appliance_config.should_receive(:packages).and_return(['kernel'])
135
134
 
136
- @plugin.should_receive(:adjust_partition_table).ordered
137
135
  @plugin.should_receive(:normalize_packages).ordered
138
136
  @plugin.should_receive(:build_with_appliance_creator).ordered
139
137
 
@@ -142,17 +140,5 @@ module BoxGrinder
142
140
  @plugin.execute('file')
143
141
  end
144
142
  end
145
-
146
- it "should adjust partition table for RHEL 5" do
147
- @appliance_config.stub!(:os).and_return(OpenCascade.new({:name => 'rhel', :version => '5'}))
148
-
149
- @appliance_config.stub!(:hardware).and_return(OpenCascade.new(:partitions => {'/' => {'size' => 2}}))
150
-
151
- @plugin.adjust_partition_table
152
-
153
- @appliance_config.hardware.partitions.size.should == 2
154
- @appliance_config.hardware.partitions['/']['size'].should == 2
155
- @appliance_config.hardware.partitions['/boot']['size'].should == 0.1
156
- end
157
143
  end
158
144
  end
@@ -16,6 +16,7 @@
16
16
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
+ require 'rubygems'
19
20
  require 'boxgrinder-build/plugins/os/rpm-based/kickstart'
20
21
  require 'hashery/opencascade'
21
22