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.
- data/CHANGELOG +11 -0
- data/README.md +32 -34
- data/Rakefile +7 -1
- data/bin/boxgrinder-build +10 -17
- data/boxgrinder-build.gemspec +7 -4
- data/lib/boxgrinder-build/appliance.rb +13 -16
- data/lib/boxgrinder-build/helpers/guestfs-helper.rb +84 -40
- data/lib/boxgrinder-build/helpers/image-helper.rb +54 -85
- data/lib/boxgrinder-build/helpers/linux-helper.rb +29 -9
- data/lib/boxgrinder-build/helpers/plugin-helper.rb +1 -0
- data/lib/boxgrinder-build/plugins/base-plugin.rb +3 -2
- data/lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb +13 -42
- data/lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb +209 -0
- data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +8 -4
- data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +0 -7
- data/lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb +4 -1
- data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb +52 -9
- data/lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb +6 -2
- data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +4 -44
- data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit +1 -1
- data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit +1 -1
- data/lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst +2 -2
- data/lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb +24 -13
- data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx +2 -2
- data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +0 -1
- data/rubygem-boxgrinder-build.spec +23 -1
- data/spec/appliance-spec.rb +5 -79
- data/spec/helpers/augeas-helper-spec.rb +1 -0
- data/spec/helpers/guestfs-helper-spec.rb +79 -62
- data/spec/helpers/image-helper-spec.rb +88 -129
- data/spec/helpers/linux-helper-spec.rb +22 -5
- data/spec/helpers/package-helper-spec.rb +1 -0
- data/spec/helpers/plugin-helper-spec.rb +1 -0
- data/spec/managers/plugin-manager-spec.rb +3 -2
- data/spec/plugins/base-plugin-spec.rb +1 -1
- data/spec/plugins/delivery/ebs/ebs-plugin-spec.rb +21 -13
- data/spec/plugins/delivery/elastichosts/elastichosts-plugin-spec.rb +320 -0
- data/spec/plugins/delivery/local/local-plugin-spec.rb +1 -0
- data/spec/plugins/delivery/s3/s3-plugin-spec.rb +1 -0
- data/spec/plugins/delivery/sftp/sftp-plugin-spec.rb +1 -0
- data/spec/plugins/os/centos/centos-plugin-spec.rb +1 -0
- data/spec/plugins/os/fedora/fedora-plugin-spec.rb +13 -1
- data/spec/plugins/os/rhel/rhel-plugin-spec.rb +1 -15
- data/spec/plugins/os/rpm-based/kickstart-spec.rb +1 -0
- data/spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb +75 -15
- data/spec/plugins/os/rpm-based/rpm-dependency-validator-spec.rb +1 -0
- data/spec/plugins/platform/ec2/ec2-plugin-spec.rb +10 -43
- data/spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb +89 -10
- data/spec/plugins/platform/vmware/vmware-plugin-spec.rb +3 -2
- metadata +21 -7
- data/lib/boxgrinder-build/helpers/appliance-customize-helper.rb +0 -45
- 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 'boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin'
|
20
21
|
require 'hashery/opencascade'
|
21
22
|
|
@@ -27,21 +28,24 @@ module BoxGrinder
|
|
27
28
|
plugins = mock('Plugins')
|
28
29
|
plugins.stub!(:[]).with('rpm_based').and_return({})
|
29
30
|
@config.stub!(:[]).with(:plugins).and_return(plugins)
|
31
|
+
@config.stub!(:dir).and_return(OpenCascade.new(:tmp => 'tmpdir', :cache => 'cachedir'))
|
30
32
|
|
31
|
-
@appliance_config.stub!(:path).and_return(OpenCascade.new({:build => 'build/path'}))
|
32
33
|
@appliance_config.stub!(:name).and_return('full')
|
33
34
|
@appliance_config.stub!(:version).and_return(1)
|
34
35
|
@appliance_config.stub!(:release).and_return(0)
|
35
36
|
@appliance_config.stub!(:os).and_return(OpenCascade.new({:name => 'fedora', :version => '11'}))
|
37
|
+
@appliance_config.stub!(:hardware).and_return(OpenCascade.new(:cpus => 1, :memory => 512, :partitions => {'/' => nil, '/home' => nil}))
|
38
|
+
@appliance_config.stub!(:path).and_return(OpenCascade.new(:build => 'build/path', :main => 'mainpath'))
|
36
39
|
|
37
40
|
@plugin = RPMBasedOSPlugin.new
|
38
41
|
|
39
42
|
@plugin.stub!(:merge_plugin_config)
|
40
43
|
|
41
|
-
@plugin.init(@config, @appliance_config, :log =>
|
44
|
+
@plugin.init(@config, @appliance_config, :log => LogHelper.new(:level => :trace, :type => :stdout), :plugin_info => {:name => :rpm_based})
|
42
45
|
|
43
46
|
@config = @plugin.instance_variable_get(:@config)
|
44
47
|
@appliance_config = @plugin.instance_variable_get(:@appliance_config)
|
48
|
+
@image_helper = @plugin.instance_variable_get(:@image_helper)
|
45
49
|
@exec_helper = @plugin.instance_variable_get(:@exec_helper)
|
46
50
|
@log = @plugin.instance_variable_get(:@log)
|
47
51
|
end
|
@@ -104,19 +108,6 @@ module BoxGrinder
|
|
104
108
|
end
|
105
109
|
end
|
106
110
|
|
107
|
-
it "should fix partition labels" do
|
108
|
-
guestfs = mock("guestfs")
|
109
|
-
|
110
|
-
guestfs.should_receive(:list_partitions).and_return(['/dev/vda1', '/dev/vda2'])
|
111
|
-
guestfs.should_receive(:vfs_label).with('/dev/vda1').and_return('_/')
|
112
|
-
guestfs.should_receive(:vfs_label).with('/dev/vda2').and_return('_/boot')
|
113
|
-
|
114
|
-
guestfs.should_receive(:sh).with('/sbin/e2label /dev/vda1 /')
|
115
|
-
guestfs.should_receive(:sh).with('/sbin/e2label /dev/vda2 /boot')
|
116
|
-
|
117
|
-
@plugin.fix_partition_labels(guestfs)
|
118
|
-
end
|
119
|
-
|
120
111
|
describe ".use_labels_for_partitions" do
|
121
112
|
it "should use labels for partitions instead of paths" do
|
122
113
|
guestfs = mock("guestfs")
|
@@ -157,6 +148,75 @@ module BoxGrinder
|
|
157
148
|
|
158
149
|
@plugin.disable_firewall(guestfs)
|
159
150
|
end
|
151
|
+
|
152
|
+
describe ".build_with_appliance_creator" do
|
153
|
+
it "should build appliance" do
|
154
|
+
kickstart = mock(Kickstart)
|
155
|
+
kickstart.should_receive(:create).and_return('kickstart.ks')
|
156
|
+
|
157
|
+
validator = mock(RPMDependencyValidator)
|
158
|
+
validator.should_receive(:resolve_packages)
|
159
|
+
|
160
|
+
Kickstart.should_receive(:new).with(@config, @appliance_config, {}, {:tmp=>"build/path/rpm_based-plugin/tmp", :base=>"build/path/rpm_based-plugin"}, :log => @log).and_return(kickstart)
|
161
|
+
RPMDependencyValidator.should_receive(:new).and_return(validator)
|
162
|
+
|
163
|
+
@exec_helper.should_receive(:execute).with("appliance-creator -d -v -t 'build/path/rpm_based-plugin/tmp' --cache=cachedir/rpms-cache/mainpath --config 'kickstart.ks' -o 'build/path/rpm_based-plugin/tmp' --name 'full' --vmem 512 --vcpu 1 --format raw")
|
164
|
+
|
165
|
+
FileUtils.should_receive(:mv)
|
166
|
+
FileUtils.should_receive(:rm_rf)
|
167
|
+
|
168
|
+
@image_helper.should_receive(:customize).with(["build/path/rpm_based-plugin/tmp/full-sda.raw"])
|
169
|
+
|
170
|
+
@plugin.build_with_appliance_creator('jeos.appl')
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe ".execute_appliance_creator" do
|
175
|
+
it "should execute appliance creator successfuly" do
|
176
|
+
@exec_helper.should_receive(:execute).with("appliance-creator -d -v -t 'build/path/rpm_based-plugin/tmp' --cache=cachedir/rpms-cache/mainpath --config 'kickstart.ks' -o 'build/path/rpm_based-plugin/tmp' --name 'full' --vmem 512 --vcpu 1 --format raw")
|
177
|
+
@plugin.execute_appliance_creator('kickstart.ks')
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should catch the interrupt and unmount the appliance-creator mounts" do
|
181
|
+
@exec_helper.should_receive(:execute).with("appliance-creator -d -v -t 'build/path/rpm_based-plugin/tmp' --cache=cachedir/rpms-cache/mainpath --config 'kickstart.ks' -o 'build/path/rpm_based-plugin/tmp' --name 'full' --vmem 512 --vcpu 1 --format raw").and_raise(InterruptionError.new(12345))
|
182
|
+
@plugin.should_receive(:cleanup_after_appliance_creator).with(12345)
|
183
|
+
@plugin.should_receive(:abort)
|
184
|
+
@plugin.execute_appliance_creator('kickstart.ks')
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe ".cleanup_after_appliance_creator" do
|
189
|
+
it "should cleanup after appliance creator (surprisngly!)" do
|
190
|
+
Process.should_receive(:kill).with("TERM", 12345)
|
191
|
+
Process.should_receive(:wait).with(12345)
|
192
|
+
|
193
|
+
Dir.should_receive(:[]).with('build/path/rpm_based-plugin/tmp/imgcreate-*').and_return(['adir'])
|
194
|
+
|
195
|
+
@exec_helper.should_receive(:execute).ordered.with("mount | grep adir | awk '{print $1}'").and_return("/dev/mapper/loop0p1
|
196
|
+
/dev/mapper/loop0p2
|
197
|
+
/sys
|
198
|
+
/proc
|
199
|
+
/dev/pts
|
200
|
+
/dev/shm
|
201
|
+
/var/cache/boxgrinder/rpms-cache/x86_64/fedora/14")
|
202
|
+
|
203
|
+
@exec_helper.should_receive(:execute).ordered.with('umount -d adir/install_root/var/cache/yum')
|
204
|
+
@exec_helper.should_receive(:execute).ordered.with('umount -d adir/install_root/dev/shm')
|
205
|
+
@exec_helper.should_receive(:execute).ordered.with('umount -d adir/install_root/dev/pts')
|
206
|
+
@exec_helper.should_receive(:execute).ordered.with('umount -d adir/install_root/proc')
|
207
|
+
@exec_helper.should_receive(:execute).ordered.with('umount -d adir/install_root/sys')
|
208
|
+
@exec_helper.should_receive(:execute).ordered.with('umount -d adir/install_root/home')
|
209
|
+
@exec_helper.should_receive(:execute).ordered.with('umount -d adir/install_root/')
|
210
|
+
|
211
|
+
@exec_helper.should_receive(:execute).ordered.with("/sbin/kpartx -d /dev/loop0")
|
212
|
+
@exec_helper.should_receive(:execute).ordered.with("losetup -d /dev/loop0")
|
213
|
+
|
214
|
+
@exec_helper.should_receive(:execute).ordered.with("rm /dev/loop01")
|
215
|
+
@exec_helper.should_receive(:execute).ordered.with("rm /dev/loop02")
|
216
|
+
|
217
|
+
@plugin.cleanup_after_appliance_creator(12345)
|
218
|
+
end
|
219
|
+
end
|
160
220
|
end
|
161
221
|
end
|
162
222
|
|
@@ -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/rpm-dependency-validator'
|
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/platform/ec2/ec2-plugin'
|
20
21
|
require 'boxgrinder-core/helpers/log-helper'
|
21
22
|
require 'hashery/opencascade'
|
@@ -144,7 +145,7 @@ module BoxGrinder
|
|
144
145
|
@plugin.instance_variable_set(:@linux_helper, linux_helper)
|
145
146
|
|
146
147
|
tempfile = mock(Tempfile)
|
147
|
-
tempfile.should_receive(:<<).with("default=0\ntimeout=0\ntitle full\n root (hd0)\n kernel /boot/vmlinuz-2.6.18 ro root=LABEL
|
148
|
+
tempfile.should_receive(:<<).with("default=0\ntimeout=0\ntitle full\n root (hd0)\n kernel /boot/vmlinuz-2.6.18 ro root=LABEL=79d3d2d4 rd_NO_PLYMOUTH\n initrd /boot/vmlinuz-2.6.18.img\n")
|
148
149
|
tempfile.should_receive(:flush)
|
149
150
|
tempfile.should_receive(:path).and_return('path/menu.lst')
|
150
151
|
tempfile.should_receive(:close)
|
@@ -196,24 +197,17 @@ module BoxGrinder
|
|
196
197
|
|
197
198
|
LinuxHelper.should_receive(:new).with(:log => @log).and_return(linux_helper)
|
198
199
|
|
199
|
-
@image_helper.should_receive(:convert_disk).with("a/disk.raw").with("a/disk.raw", "raw", "build/path/ec2-plugin/tmp/full.raw")
|
200
|
-
|
201
|
-
@image_helper.should_receive(:create_disk).with("build/path/ec2-plugin/tmp/full.ec2", 10)
|
202
|
-
@image_helper.should_receive(:create_filesystem).with("build/path/ec2-plugin/tmp/full.ec2")
|
203
|
-
@image_helper.should_receive(:mount_image).twice
|
204
|
-
@image_helper.should_receive(:sync_files)
|
205
|
-
@image_helper.should_receive(:umount_image).twice
|
206
|
-
|
207
200
|
guestfs = mock("guestfs")
|
208
201
|
guestfs_helper = mock("guestfsHelper")
|
209
202
|
|
210
|
-
@image_helper.should_receive(:customize).with("build/path/ec2-plugin/tmp/full.ec2").and_yield(guestfs, guestfs_helper)
|
203
|
+
@image_helper.should_receive(:customize).with(["a/disk.raw", "build/path/ec2-plugin/tmp/full.ec2"], :automount => false).and_yield(guestfs, guestfs_helper)
|
204
|
+
@image_helper.should_receive(:sync_filesystem).with(guestfs, guestfs_helper)
|
205
|
+
@image_helper.should_receive(:create_disk).with("build/path/ec2-plugin/tmp/full.ec2", 10)
|
211
206
|
|
212
207
|
guestfs.should_receive(:upload).with("/etc/resolv.conf", "/etc/resolv.conf")
|
213
208
|
@plugin.should_receive(:create_devices).with(guestfs)
|
214
209
|
@plugin.should_receive(:upload_fstab).with(guestfs)
|
215
210
|
|
216
|
-
|
217
211
|
@plugin.should_receive(:enable_networking).with(guestfs)
|
218
212
|
@plugin.should_receive(:upload_rc_local).with(guestfs)
|
219
213
|
@plugin.should_receive(:enable_nosegneg_flag).with(guestfs)
|
@@ -235,18 +229,12 @@ module BoxGrinder
|
|
235
229
|
|
236
230
|
LinuxHelper.should_receive(:new).with(:log => @log).and_return(linux_helper)
|
237
231
|
|
238
|
-
@image_helper.should_receive(:convert_disk).with("a/disk.raw").with("a/disk.raw", "raw", "build/path/ec2-plugin/tmp/full.raw")
|
239
|
-
|
240
|
-
@image_helper.should_receive(:create_disk).with("build/path/ec2-plugin/tmp/full.ec2", 10)
|
241
|
-
@image_helper.should_receive(:create_filesystem).with("build/path/ec2-plugin/tmp/full.ec2")
|
242
|
-
@image_helper.should_receive(:mount_image).twice
|
243
|
-
@image_helper.should_receive(:sync_files)
|
244
|
-
@image_helper.should_receive(:umount_image).twice
|
245
|
-
|
246
232
|
guestfs = mock("guestfs")
|
247
233
|
guestfs_helper = mock("guestfsHelper")
|
248
234
|
|
249
|
-
@image_helper.should_receive(:customize).with("build/path/ec2-plugin/tmp/full.ec2").and_yield(guestfs, guestfs_helper)
|
235
|
+
@image_helper.should_receive(:customize).with(["a/disk.raw", "build/path/ec2-plugin/tmp/full.ec2"], :automount => false).and_yield(guestfs, guestfs_helper)
|
236
|
+
@image_helper.should_receive(:sync_filesystem).with(guestfs, guestfs_helper)
|
237
|
+
@image_helper.should_receive(:create_disk).with("build/path/ec2-plugin/tmp/full.ec2", 10)
|
250
238
|
|
251
239
|
guestfs.should_receive(:upload).with("/etc/resolv.conf", "/etc/resolv.conf")
|
252
240
|
guestfs.should_receive(:mkdir).with("/data")
|
@@ -276,33 +264,12 @@ module BoxGrinder
|
|
276
264
|
|
277
265
|
LinuxHelper.should_receive(:new).with(:log => @log).and_return(linux_helper)
|
278
266
|
|
279
|
-
@image_helper.should_receive(:create_disk).
|
280
|
-
@image_helper.should_not_receive(:create_filesystem)
|
281
|
-
@image_helper.should_not_receive(:mount_image)
|
282
|
-
|
283
|
-
@image_helper.should_not_receive(:customize)
|
284
|
-
|
285
|
-
lambda {
|
286
|
-
@plugin.execute
|
287
|
-
}.should raise_error(RuntimeError, "Error while preparing EC2 disk image. See logs for more info.")
|
288
|
-
end
|
289
|
-
|
290
|
-
it "should fail because mounting or unmounting failed" do
|
291
|
-
linux_helper = mock(LinuxHelper)
|
292
|
-
|
293
|
-
LinuxHelper.should_receive(:new).with(:log => @log).and_return(linux_helper)
|
294
|
-
|
295
|
-
@image_helper.should_receive(:convert_disk).with("a/disk.raw").with("a/disk.raw", "raw", "build/path/ec2-plugin/tmp/full.raw")
|
296
|
-
|
297
|
-
@image_helper.should_receive(:create_disk).with("build/path/ec2-plugin/tmp/full.ec2", 10)
|
298
|
-
@image_helper.should_receive(:create_filesystem).with("build/path/ec2-plugin/tmp/full.ec2")
|
299
|
-
@image_helper.should_receive(:mount_image).and_raise("This error is expected!")
|
300
|
-
|
267
|
+
@image_helper.should_receive(:create_disk).with("build/path/ec2-plugin/tmp/full.ec2", 10).and_raise("Boom")
|
301
268
|
@image_helper.should_not_receive(:customize)
|
302
269
|
|
303
270
|
lambda {
|
304
271
|
@plugin.execute
|
305
|
-
}.should raise_error(RuntimeError, "
|
272
|
+
}.should raise_error(RuntimeError, "Boom")
|
306
273
|
end
|
307
274
|
end
|
308
275
|
|
@@ -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/platform/virtualbox/virtualbox-plugin'
|
20
21
|
require 'hashery/opencascade'
|
21
22
|
|
@@ -59,6 +60,7 @@ module BoxGrinder
|
|
59
60
|
|
60
61
|
@exec_helper = @plugin.instance_variable_get(:@exec_helper)
|
61
62
|
@image_helper = @plugin.instance_variable_get(:@image_helper)
|
63
|
+
@log = @plugin.instance_variable_get(:@log)
|
62
64
|
end
|
63
65
|
|
64
66
|
describe ".build_virtualbox" do
|
@@ -79,40 +81,117 @@ module BoxGrinder
|
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
84
|
+
describe ".is_os_old?" do
|
85
|
+
it "should return false for fedora 14" do
|
86
|
+
prepare_image
|
87
|
+
@appliance_config.stub!(:os).and_return(OpenCascade.new({:name => 'fedora', :version => '14'}))
|
88
|
+
@plugin.is_os_old?.should == false
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should return false for rhel 6" do
|
92
|
+
prepare_image
|
93
|
+
@appliance_config.stub!(:os).and_return(OpenCascade.new({:name => 'rhel', :version => '6'}))
|
94
|
+
@plugin.is_os_old?.should == false
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should return true for centos 5" do
|
98
|
+
prepare_image
|
99
|
+
@appliance_config.stub!(:os).and_return(OpenCascade.new({:name => 'centos', :version => '5'}))
|
100
|
+
@plugin.is_os_old?.should == true
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
82
104
|
describe ".customize" do
|
83
105
|
it "should customize the image" do
|
84
106
|
prepare_image
|
85
107
|
|
86
108
|
@appliance_config.post['virtualbox'] = ["one", "two", "three"]
|
87
109
|
|
88
|
-
guestfs_mock = mock("GuestFS")
|
89
110
|
guestfs_helper_mock = mock("GuestFSHelper")
|
90
111
|
|
91
|
-
@image_helper.should_receive(:customize).with("build/path/virtualbox-plugin/tmp/full.vmdk").and_yield(guestfs_mock, guestfs_helper_mock)
|
112
|
+
# @image_helper.should_receive(:customize).with("build/path/virtualbox-plugin/tmp/full.vmdk").and_yield(guestfs_mock, guestfs_helper_mock)
|
92
113
|
|
93
114
|
guestfs_helper_mock.should_receive(:sh).once.ordered.with("one", :arch => 'i686')
|
94
115
|
guestfs_helper_mock.should_receive(:sh).once.ordered.with("two", :arch => 'i686')
|
95
116
|
guestfs_helper_mock.should_receive(:sh).once.ordered.with("three", :arch => 'i686')
|
96
117
|
|
97
|
-
@plugin.customize
|
118
|
+
@plugin.customize(guestfs_helper_mock)
|
98
119
|
end
|
120
|
+
end
|
99
121
|
|
100
|
-
|
122
|
+
describe ".execute" do
|
123
|
+
it "should execute the conversion" do
|
101
124
|
prepare_image
|
102
125
|
|
126
|
+
@plugin.should_receive(:build_virtualbox)
|
127
|
+
|
103
128
|
@image_helper.should_not_receive(:customize)
|
129
|
+
@plugin.should_not_receive(:recreate_kernel)
|
130
|
+
@plugin.should_not_receive(:customize)
|
104
131
|
|
105
|
-
@plugin.
|
132
|
+
@plugin.execute
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should execute the conversion with post operations" do
|
136
|
+
prepare_image
|
137
|
+
|
138
|
+
@appliance_config.post['virtualbox'] = ["one", "two", "three"]
|
139
|
+
|
140
|
+
@plugin.should_receive(:build_virtualbox)
|
141
|
+
|
142
|
+
guestfs_mock = mock("GuestFS")
|
143
|
+
guestfs_helper_mock = mock("GuestFSHelper")
|
144
|
+
|
145
|
+
@image_helper.should_receive(:customize).with(["build/path/virtualbox-plugin/tmp/full.vmdk"]).and_yield(guestfs_mock, guestfs_helper_mock)
|
146
|
+
|
147
|
+
@plugin.should_not_receive(:recreate_kernel)
|
148
|
+
@plugin.should_receive(:customize).with(guestfs_helper_mock)
|
149
|
+
|
150
|
+
@plugin.execute
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should execute the conversion with post operations for rhel 5" do
|
154
|
+
prepare_image
|
155
|
+
|
156
|
+
@appliance_config.post['virtualbox'] = ["one", "two", "three"]
|
157
|
+
@appliance_config.stub!(:os).and_return(OpenCascade.new({:name => 'rhel', :version => '5'}))
|
158
|
+
|
159
|
+
@plugin.should_receive(:build_virtualbox)
|
160
|
+
|
161
|
+
guestfs_mock = mock("GuestFS")
|
162
|
+
guestfs_helper_mock = mock("GuestFSHelper")
|
163
|
+
|
164
|
+
@image_helper.should_receive(:customize).with(["build/path/virtualbox-plugin/tmp/full.vmdk"]).and_yield(guestfs_mock, guestfs_helper_mock)
|
165
|
+
|
166
|
+
@plugin.should_receive(:recreate_kernel).with(guestfs_mock)
|
167
|
+
@plugin.should_receive(:customize).with(guestfs_helper_mock)
|
168
|
+
|
169
|
+
@plugin.execute
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should not customize the image if no commands are specified and the appliance os version is old" do
|
173
|
+
prepare_image
|
174
|
+
|
175
|
+
@plugin.should_receive(:build_virtualbox)
|
176
|
+
@plugin.should_receive(:is_os_old?).and_return(false)
|
177
|
+
@image_helper.should_not_receive(:customize)
|
178
|
+
|
179
|
+
@plugin.execute
|
106
180
|
end
|
107
181
|
end
|
108
182
|
|
109
|
-
|
110
|
-
|
183
|
+
describe ".recreate_kernel" do
|
184
|
+
it "should recreate the kernel" do
|
185
|
+
prepare_image
|
111
186
|
|
112
|
-
|
113
|
-
|
187
|
+
guestfs_mock = mock("GuestFS")
|
188
|
+
linux_helper_mock = mock(LinuxHelper)
|
189
|
+
linux_helper_mock.should_receive(:recreate_kernel_image).with(guestfs_mock, ['ahci'])
|
114
190
|
|
115
|
-
|
191
|
+
LinuxHelper.should_receive(:new).with(:log => @log).and_return(linux_helper_mock)
|
192
|
+
|
193
|
+
@plugin.recreate_kernel(guestfs_mock)
|
194
|
+
end
|
116
195
|
end
|
117
196
|
end
|
118
197
|
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/platform/vmware/vmware-plugin'
|
20
21
|
require 'hashery/opencascade'
|
21
22
|
|
@@ -168,9 +169,9 @@ module BoxGrinder
|
|
168
169
|
|
169
170
|
vmx_file.scan(/^guestOS = "(.*)"\s?$/).to_s.should == "linux"
|
170
171
|
vmx_file.scan(/^displayName = "(.*)"\s?$/).to_s.should == "full"
|
171
|
-
vmx_file.scan(/^annotation = "(.*)"\s?$/).to_s.scan(/^
|
172
|
+
vmx_file.scan(/^annotation = "(.*)"\s?$/).to_s.scan(/^full | Version: 1\.0 | Built by: BoxGrinder 1\.0\.0/).should_not == nil
|
172
173
|
vmx_file.scan(/^guestinfo.vmware.product.long = "(.*)"\s?$/).to_s.should == "full"
|
173
|
-
vmx_file.scan(/^guestinfo.vmware.product.url = "(.*)"\s?$/).to_s.should == "http://
|
174
|
+
vmx_file.scan(/^guestinfo.vmware.product.url = "(.*)"\s?$/).to_s.should == "http://boxgrinder.org"
|
174
175
|
vmx_file.scan(/^numvcpus = "(.*)"\s?$/).to_s.should == "1"
|
175
176
|
vmx_file.scan(/^memsize = "(.*)"\s?$/).to_s.should == "256"
|
176
177
|
vmx_file.scan(/^log.fileName = "(.*)"\s?$/).to_s.should == "full.log"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxgrinder-build
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 1
|
10
|
+
version: 0.9.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marek Goldmann
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-27 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -104,6 +104,20 @@ dependencies:
|
|
104
104
|
version: "0"
|
105
105
|
type: :runtime
|
106
106
|
version_requirements: *id006
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: rest-client
|
109
|
+
prerelease: false
|
110
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
119
|
+
type: :runtime
|
120
|
+
version_requirements: *id007
|
107
121
|
description: A tool for creating appliances from simple plain text files for various virtual environments.
|
108
122
|
email: info@boxgrinder.org
|
109
123
|
executables:
|
@@ -117,7 +131,6 @@ extra_rdoc_files:
|
|
117
131
|
- bin/boxgrinder-build
|
118
132
|
- lib/boxgrinder-build.rb
|
119
133
|
- lib/boxgrinder-build/appliance.rb
|
120
|
-
- lib/boxgrinder-build/helpers/appliance-customize-helper.rb
|
121
134
|
- lib/boxgrinder-build/helpers/augeas-helper.rb
|
122
135
|
- lib/boxgrinder-build/helpers/guestfs-helper.rb
|
123
136
|
- lib/boxgrinder-build/helpers/image-helper.rb
|
@@ -127,6 +140,7 @@ extra_rdoc_files:
|
|
127
140
|
- lib/boxgrinder-build/managers/plugin-manager.rb
|
128
141
|
- lib/boxgrinder-build/plugins/base-plugin.rb
|
129
142
|
- lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb
|
143
|
+
- lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb
|
130
144
|
- lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb
|
131
145
|
- lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb
|
132
146
|
- lib/boxgrinder-build/plugins/delivery/s3/src/cert-ec2.pem
|
@@ -163,7 +177,6 @@ files:
|
|
163
177
|
- boxgrinder-build.gemspec
|
164
178
|
- lib/boxgrinder-build.rb
|
165
179
|
- lib/boxgrinder-build/appliance.rb
|
166
|
-
- lib/boxgrinder-build/helpers/appliance-customize-helper.rb
|
167
180
|
- lib/boxgrinder-build/helpers/augeas-helper.rb
|
168
181
|
- lib/boxgrinder-build/helpers/guestfs-helper.rb
|
169
182
|
- lib/boxgrinder-build/helpers/image-helper.rb
|
@@ -173,6 +186,7 @@ files:
|
|
173
186
|
- lib/boxgrinder-build/managers/plugin-manager.rb
|
174
187
|
- lib/boxgrinder-build/plugins/base-plugin.rb
|
175
188
|
- lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb
|
189
|
+
- lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb
|
176
190
|
- lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb
|
177
191
|
- lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb
|
178
192
|
- lib/boxgrinder-build/plugins/delivery/s3/src/cert-ec2.pem
|
@@ -202,7 +216,6 @@ files:
|
|
202
216
|
- rubygem-boxgrinder-build.spec
|
203
217
|
- spec/Rakefile
|
204
218
|
- spec/appliance-spec.rb
|
205
|
-
- spec/helpers/appliance-customize-helper-spec.rb
|
206
219
|
- spec/helpers/augeas-helper-spec.rb
|
207
220
|
- spec/helpers/guestfs-helper-spec.rb
|
208
221
|
- spec/helpers/image-helper-spec.rb
|
@@ -213,6 +226,7 @@ files:
|
|
213
226
|
- spec/plugins/base-plugin-spec.rb
|
214
227
|
- spec/plugins/delivery/ebs/ebs-plugin-spec.rb
|
215
228
|
- spec/plugins/delivery/ebs/ebs.yaml
|
229
|
+
- spec/plugins/delivery/elastichosts/elastichosts-plugin-spec.rb
|
216
230
|
- spec/plugins/delivery/local/local-plugin-spec.rb
|
217
231
|
- spec/plugins/delivery/s3/s3-plugin-spec.rb
|
218
232
|
- spec/plugins/delivery/sftp/sftp-plugin-spec.rb
|
@@ -1,45 +0,0 @@
|
|
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/helpers/guestfs-helper'
|
21
|
-
require 'boxgrinder-core/helpers/exec-helper'
|
22
|
-
require 'boxgrinder-core/helpers/log-helper'
|
23
|
-
|
24
|
-
module BoxGrinder
|
25
|
-
class ApplianceCustomizeHelper
|
26
|
-
|
27
|
-
def initialize( config, appliance_config, disk, options = {} )
|
28
|
-
@config = config
|
29
|
-
@appliance_config = appliance_config
|
30
|
-
@disk = disk
|
31
|
-
|
32
|
-
@log = options[:log] || LogHelper.new
|
33
|
-
@exec_helper = options[:exec_helper] || ExecHelper.new( { :log => @log } )
|
34
|
-
end
|
35
|
-
|
36
|
-
def customize
|
37
|
-
@guestfs_helper = GuestFSHelper.new( @disk, :log => @log ).run
|
38
|
-
@guestfs = @guestfs_helper.guestfs
|
39
|
-
|
40
|
-
yield @guestfs, @guestfs_helper
|
41
|
-
|
42
|
-
@guestfs_helper.clean_close
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,74 +0,0 @@
|
|
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 'boxgrinder-build/helpers/appliance-customize-helper'
|
20
|
-
|
21
|
-
module BoxGrinder
|
22
|
-
describe ApplianceCustomizeHelper do
|
23
|
-
|
24
|
-
before(:each) do
|
25
|
-
@config = mock('Config')
|
26
|
-
@config.stub!(:name).and_return('BoxGrinder')
|
27
|
-
@config.stub!(:version_with_release).and_return('0.1.2')
|
28
|
-
|
29
|
-
@appliance_config = mock('ApplianceConfig')
|
30
|
-
|
31
|
-
@appliance_config.stub!(:path).and_return(OpenCascade.new({:build => 'build/path'}))
|
32
|
-
@appliance_config.stub!(:name).and_return('full')
|
33
|
-
@appliance_config.stub!(:summary).and_return('asd')
|
34
|
-
@appliance_config.stub!(:version).and_return(1)
|
35
|
-
@appliance_config.stub!(:release).and_return(0)
|
36
|
-
@appliance_config.stub!(:os).and_return(OpenCascade.new({:name => 'fedora', :version => '11'}))
|
37
|
-
@appliance_config.stub!(:post).and_return(OpenCascade.new({:vmware => []}))
|
38
|
-
|
39
|
-
@appliance_config.stub!(:hardware).and_return(
|
40
|
-
OpenCascade.new({
|
41
|
-
:partitions =>
|
42
|
-
{
|
43
|
-
'/' => {'size' => 2},
|
44
|
-
'/home' => {'size' => 3},
|
45
|
-
},
|
46
|
-
:arch => 'i686',
|
47
|
-
:base_arch => 'i386',
|
48
|
-
:cpus => 1,
|
49
|
-
:memory => 256,
|
50
|
-
})
|
51
|
-
)
|
52
|
-
|
53
|
-
@helper = ApplianceCustomizeHelper.new(@config, @appliance_config, 'a/disk', :log => Logger.new('/dev/null'))
|
54
|
-
|
55
|
-
@log = @helper.instance_variable_get(:@log)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should properly prepare guestfs for customization" do
|
59
|
-
|
60
|
-
guestfs_helper = mock('guestfs_helper')
|
61
|
-
guestfs = mock('guestfs')
|
62
|
-
guestfs_helper.should_receive(:run).and_return(guestfs_helper)
|
63
|
-
guestfs_helper.should_receive(:guestfs).and_return(guestfs)
|
64
|
-
guestfs_helper.should_receive(:clean_close)
|
65
|
-
|
66
|
-
GuestFSHelper.should_receive(:new).with('a/disk', :log => @log).and_return(guestfs_helper)
|
67
|
-
|
68
|
-
@helper.customize do |gf, gf_helper|
|
69
|
-
gf_helper.should == guestfs_helper
|
70
|
-
gf.should == guestfs
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|