boxgrinder-build 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +12 -0
- data/boxgrinder-build.gemspec +4 -4
- data/lib/boxgrinder-build/helpers/guestfs-helper.rb +86 -102
- data/lib/boxgrinder-build/helpers/qemu.wrapper +15 -0
- data/lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb +6 -3
- data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb +80 -4
- data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +0 -9
- data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +8 -10
- data/rubygem-boxgrinder-build.spec +28 -15
- data/spec/helpers/guestfs-helper-spec.rb +121 -93
- data/spec/plugins/delivery/elastichosts/elastichosts-plugin-spec.rb +26 -0
- data/spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb +125 -3
- data/spec/plugins/os/rpm-based/src/jeos-f13.ks +1 -0
- data/spec/plugins/platform/ec2/ec2-plugin-spec.rb +0 -10
- data/spec/plugins/platform/vmware/vmware-plugin-spec.rb +25 -12
- metadata +6 -4
@@ -41,9 +41,6 @@ module BoxGrinder
|
|
41
41
|
@image_helper.sync_filesystem(guestfs, guestfs_helper)
|
42
42
|
|
43
43
|
if (@appliance_config.os.name == 'rhel' or @appliance_config.os.name == 'centos') and @appliance_config.os.version == '5'
|
44
|
-
# Not sure why it's messed but this prevents booting on AWS
|
45
|
-
recreate_journal(guestfs)
|
46
|
-
|
47
44
|
# Remove normal kernel
|
48
45
|
guestfs.sh("yum -y remove kernel")
|
49
46
|
# because we need to install kernel-xen package
|
@@ -87,12 +84,6 @@ module BoxGrinder
|
|
87
84
|
end
|
88
85
|
end
|
89
86
|
|
90
|
-
def recreate_journal(guestfs)
|
91
|
-
@log.debug "Recreating EXT3 journal on root partition."
|
92
|
-
guestfs.sh("tune2fs -j #{guestfs.list_devices.first}")
|
93
|
-
@log.debug "Journal recreated."
|
94
|
-
end
|
95
|
-
|
96
87
|
def create_devices(guestfs)
|
97
88
|
return if guestfs.exists('/sbin/MAKEDEV') == 0
|
98
89
|
|
@@ -63,12 +63,14 @@ module BoxGrinder
|
|
63
63
|
|
64
64
|
# returns value of cylinders, heads and sector for selected disk size (in GB)
|
65
65
|
# http://kb.vmware.com/kb/1026254
|
66
|
-
def generate_scsi_chs
|
67
|
-
|
66
|
+
def generate_scsi_chs
|
67
|
+
disk_size = File.stat(@previous_deliverables.disk).size
|
68
|
+
|
69
|
+
if disk_size < 1073741824
|
68
70
|
h = 64
|
69
71
|
s = 32
|
70
72
|
else
|
71
|
-
if disk_size <
|
73
|
+
if disk_size < 2147483648
|
72
74
|
h = 128
|
73
75
|
s = 32
|
74
76
|
else
|
@@ -77,9 +79,8 @@ module BoxGrinder
|
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
-
total_sectors = disk_size * 1024 * 1024 * 1024 / 512
|
82
|
+
c = disk_size / (h*s*512)
|
83
|
+
total_sectors = disk_size / 512
|
83
84
|
|
84
85
|
[c.to_i, h.to_i, s.to_i, total_sectors.to_i]
|
85
86
|
end
|
@@ -87,10 +88,7 @@ module BoxGrinder
|
|
87
88
|
def change_vmdk_values(type)
|
88
89
|
vmdk_data = File.open("#{File.dirname(__FILE__)}/src/base.vmdk").read
|
89
90
|
|
90
|
-
|
91
|
-
@appliance_config.hardware.partitions.values.each { |part| disk_size += part['size'].to_f }
|
92
|
-
|
93
|
-
c, h, s, total_sectors = generate_scsi_chs(disk_size)
|
91
|
+
c, h, s, total_sectors = generate_scsi_chs
|
94
92
|
|
95
93
|
is_enterprise = type.eql?("vmfs")
|
96
94
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Summary: A tool for creating appliances from simple plain text files
|
7
7
|
Name: rubygem-%{gemname}
|
8
|
-
Version: 0.9.
|
8
|
+
Version: 0.9.2
|
9
9
|
Release: 1%{?dist}
|
10
10
|
Group: Development/Languages
|
11
11
|
License: LGPLv3+
|
@@ -115,7 +115,7 @@ mkdir -p %{_builddir}%{gemdir}
|
|
115
115
|
mkdir -p %{buildroot}/%{_bindir}
|
116
116
|
mkdir -p %{buildroot}/%{gemdir}
|
117
117
|
|
118
|
-
gem install --local --install-dir %{_builddir}%{gemdir} \
|
118
|
+
/usr/bin/gem install --local --install-dir %{_builddir}%{gemdir} \
|
119
119
|
--force --rdoc %{SOURCE0}
|
120
120
|
mv %{_builddir}%{gemdir}/bin/* %{buildroot}/%{_bindir}
|
121
121
|
find %{_builddir}%{geminstdir}/bin -type f | xargs chmod a+x
|
@@ -136,6 +136,7 @@ popd
|
|
136
136
|
%doc %{geminstdir}/LICENSE
|
137
137
|
%doc %{geminstdir}/README.md
|
138
138
|
%doc %{geminstdir}/Manifest
|
139
|
+
%attr(755, root, root) %{geminstdir}/lib/boxgrinder-build/helpers/qemu.wrapper
|
139
140
|
%{gemdir}/cache/%{gemname}-%{version}.gem
|
140
141
|
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
|
141
142
|
|
@@ -148,7 +149,19 @@ popd
|
|
148
149
|
%{gemdir}/doc/%{gemname}-%{version}
|
149
150
|
|
150
151
|
%changelog
|
151
|
-
* Thu
|
152
|
+
* Thu May 05 2011 Marek Goldmann <mgoldman@redhat.com> - 0.9.2-1
|
153
|
+
- Upstream release: 0.9.2
|
154
|
+
- [BGBUILD-148] Add support for building CentOS/RHEL images on Fedora
|
155
|
+
- [BGBUILD-204] Fedora 15 appliance networking start on boot failed
|
156
|
+
- [BGBUILD-208] Kickstart files not working with 0.9.1
|
157
|
+
- [BGBUILD-205] Error while converting to EC2 when guest OS is CentOS/RHEL 5
|
158
|
+
- [BGBUILD-213] CloudSigma support
|
159
|
+
- [BGBUILD-209] Wrong /etc/mtab on Fedora 15 appliances causes errors
|
160
|
+
- [BGBUILD-203] Vmware vmdk disk size is wrong when installing via kickstart files
|
161
|
+
- [BGBUILD-207] Guestfs dies on Fedora 15 with 'KVM not supported for this target' message
|
162
|
+
- [BGBUILD-83] Enable libguestfs log callback to redirect guestfs output to logger
|
163
|
+
|
164
|
+
* Thu Mar 17 2011 Marek Goldmann <mgoldman@redhat.com> - 0.9.1-1
|
152
165
|
- Upstream release: 0.9.1
|
153
166
|
- [BGBUILD-188] Use libuestfs instead mounting partitions manually for EC2 appliances
|
154
167
|
- [BGBUILD-97] some filesystems dont get unmounted on BG interruption
|
@@ -159,7 +172,7 @@ popd
|
|
159
172
|
- [BGBUILD-194] Add support for ElasticHosts cloud
|
160
173
|
- [BGBUILD-202] Unable to get valid context for ec2-user after login on AMI
|
161
174
|
|
162
|
-
* Tue Mar 01 2011 <msavy@redhat.com> - 0.9.0-1
|
175
|
+
* Tue Mar 01 2011 Marc Savy <msavy@redhat.com> - 0.9.0-1
|
163
176
|
- Upstream release: 0.9.0
|
164
177
|
- [BGBUILD-103] README to indicate supported operating systems / requirements
|
165
178
|
- [BGBUILD-169] S3 plugin temporary work-around for EL5
|
@@ -173,13 +186,13 @@ popd
|
|
173
186
|
- [BGBUILD-176] Fail the build with appropriate message if any of post section commands fails to execute
|
174
187
|
- [BGBUILD-183] Add support for Fedora 15
|
175
188
|
|
176
|
-
* Tue Feb 16 2011
|
189
|
+
* Tue Feb 16 2011 Marek Goldmann <mgoldman@redhat.com> - 0.8.1-1
|
177
190
|
- Upstream release: 0.8.1
|
178
191
|
- [BGBUILD-141] Long delay after "Preparing guestfs" message when creating new image
|
179
192
|
- [BGBUILD-150] Cyclical inclusion dependencies in appliance definition files are not detected/handled
|
180
193
|
- [BGBUILD-165] Use version in dependencies in gem and in RPM only where necessary
|
181
194
|
|
182
|
-
* Tue Jan 04 2011
|
195
|
+
* Tue Jan 04 2011 Marek Goldmann <mgoldman@redhat.com> - 0.8.0-1
|
183
196
|
- Upstream release: 0.8.0
|
184
197
|
- Added BuildRoot tag to build for EPEL 5
|
185
198
|
- [BGBUILD-128] Allow to specify plugin configuration using CLI
|
@@ -193,12 +206,12 @@ popd
|
|
193
206
|
- [BGBUILD-138] enablerepo path is not escaped when calling repoquery
|
194
207
|
- [BGBUILD-147] Allow to list installed plugins and version information
|
195
208
|
|
196
|
-
* Mon Dec 20 2010
|
209
|
+
* Mon Dec 20 2010 Marek Goldmann <mgoldman@redhat.com> - 0.7.1-1
|
197
210
|
- Upstream release: 0.7.1
|
198
211
|
- [BGBUILD-123] Remove RPM database recreation code
|
199
212
|
- [BGBUILD-124] Guestfs fails while mounting multiple partitions with '_' prefix
|
200
213
|
|
201
|
-
* Fri Dec 17 2010
|
214
|
+
* Fri Dec 17 2010 Marek Goldmann <mgoldman@redhat.com> - 0.7.0-1
|
202
215
|
- Updated to upstream version: 0.7.0
|
203
216
|
- [BGBUILD-113] Allow to specify supported file formats for operating system plugin
|
204
217
|
- [BGBUILD-73] Add support for kickstart files
|
@@ -206,17 +219,17 @@ popd
|
|
206
219
|
- [BGBUILD-118] Enable SElinux in guestfs
|
207
220
|
- [BGBUILD-119] Fix SElinux issues on EC2 appliances
|
208
221
|
|
209
|
-
* Thu Dec 02 2010
|
222
|
+
* Thu Dec 02 2010 Marek Goldmann <mgoldman@redhat.com> - 0.6.5-1
|
210
223
|
- Updated to new upstream release: 0.6.5
|
211
224
|
|
212
|
-
* Mon Nov 22 2010
|
225
|
+
* Mon Nov 22 2010 Marek Goldmann <mgoldman@redhat.com> - 0.6.4-3
|
213
226
|
- Changelog rewritten
|
214
227
|
- Added Require: parted and e2fsprogs
|
215
228
|
|
216
|
-
* Sat Nov 20 2010
|
229
|
+
* Sat Nov 20 2010 Marek Goldmann <mgoldman@redhat.com> - 0.6.4-2
|
217
230
|
- Small set of spec file adjustments
|
218
231
|
|
219
|
-
* Mon Nov 15 2010
|
232
|
+
* Mon Nov 15 2010 Marek Goldmann <mgoldman@redhat.com> - 0.6.4-1
|
220
233
|
- Updated to new upstream release: 0.6.4
|
221
234
|
- Removed BuildRoot tag
|
222
235
|
- Adjusted Requires and BuildRequires
|
@@ -226,12 +239,12 @@ popd
|
|
226
239
|
- [BGBUILD-92] Enable --trace switch by default
|
227
240
|
- [BGBUILD-91] Log exceptions to log file
|
228
241
|
|
229
|
-
* Tue Nov 09 2010
|
242
|
+
* Tue Nov 09 2010 Marek Goldmann <mgoldman@redhat.com> - 0.6.3-1
|
230
243
|
- [BGBUILD-94] Check if set_network call is avaialbe in libguestfs
|
231
244
|
- Added 'check' section that executes tests
|
232
245
|
|
233
|
-
* Wed Nov 03 2010
|
246
|
+
* Wed Nov 03 2010 Marek Goldmann <mgoldman@redhat.com> - 0.6.2-1
|
234
247
|
- [BGBUILD-84] Don't use in libguestfs qemu-kvm where hardware accleration isn't available
|
235
248
|
|
236
|
-
* Mon Oct 18 2010
|
249
|
+
* Mon Oct 18 2010 Marek Goldmann <mgoldman@redhat.com> - 0.6.1-1
|
237
250
|
- Initial package
|
@@ -32,153 +32,132 @@ module BoxGrinder
|
|
32
32
|
@helper = GuestFSHelper.new('a/raw/disk', @appliance_config, @config, :log => @log)
|
33
33
|
end
|
34
34
|
|
35
|
-
describe ".
|
36
|
-
it "should prepare
|
35
|
+
describe ".prepare_guestfs" do
|
36
|
+
it "should prepare guestfs with normal disk" do
|
37
37
|
guestfs = mock('Guestfs')
|
38
|
+
@helper.instance_variable_set(:@guestfs, guestfs)
|
39
|
+
|
38
40
|
guestfs.should_receive(:set_append).with('noapic')
|
39
41
|
guestfs.should_receive(:set_verbose)
|
40
42
|
guestfs.should_receive(:set_trace)
|
41
43
|
guestfs.should_receive(:set_selinux).with(1)
|
42
44
|
|
43
45
|
@helper.should_receive(:hw_virtualization_available?).and_return(true)
|
44
|
-
@helper.should_receive(:load_selinux_policy)
|
45
46
|
|
46
47
|
guestfs.should_receive(:add_drive).with('a/raw/disk')
|
47
48
|
guestfs.should_receive(:set_network).with(1)
|
48
|
-
guestfs.should_receive(:launch)
|
49
|
-
|
50
|
-
guestfs.should_receive(:list_devices).and_return(['/dev/vda'])
|
51
|
-
guestfs.should_receive(:list_partitions).and_return(['/dev/vda1', '/dev/vda2'])
|
52
|
-
|
53
|
-
Guestfs.should_receive(:create).and_return(guestfs)
|
54
49
|
|
55
|
-
@helper.
|
56
|
-
|
50
|
+
@helper.prepare_guestfs(:a => :b) do
|
51
|
+
end
|
57
52
|
end
|
58
53
|
|
59
54
|
it "should prepare and run guestfs wid IDE disk" do
|
60
55
|
guestfs = mock('Guestfs')
|
56
|
+
@helper.instance_variable_set(:@guestfs, guestfs)
|
57
|
+
|
61
58
|
guestfs.should_receive(:set_append).with('noapic')
|
62
59
|
guestfs.should_receive(:set_verbose)
|
63
60
|
guestfs.should_receive(:set_trace)
|
64
61
|
guestfs.should_receive(:set_selinux).with(1)
|
65
62
|
|
66
63
|
@helper.should_receive(:hw_virtualization_available?).and_return(true)
|
67
|
-
@helper.should_receive(:load_selinux_policy)
|
68
64
|
|
69
65
|
guestfs.should_receive(:add_drive_with_if).with('a/raw/disk', 'ide')
|
70
66
|
guestfs.should_receive(:set_network).with(1)
|
71
|
-
guestfs.should_receive(:launch)
|
72
|
-
guestfs.should_receive(:list_devices).and_return(['/dev/vda'])
|
73
|
-
guestfs.should_receive(:list_partitions).and_return(['/dev/vda1', '/dev/vda2'])
|
74
|
-
|
75
|
-
Guestfs.should_receive(:create).and_return(guestfs)
|
76
67
|
|
77
|
-
@helper.
|
78
|
-
@helper.execute(nil, :ide_disk => true).should == @helper
|
68
|
+
@helper.prepare_guestfs(:ide_disk => true) {}
|
79
69
|
end
|
80
70
|
|
81
|
-
it "should prepare
|
71
|
+
it "should prepare guestfs without HW accelerarion enabled" do
|
82
72
|
guestfs = mock('Guestfs')
|
73
|
+
@helper.instance_variable_set(:@guestfs, guestfs)
|
74
|
+
|
83
75
|
guestfs.should_receive(:set_append).with('noapic')
|
84
76
|
guestfs.should_receive(:set_verbose)
|
85
77
|
guestfs.should_receive(:set_trace)
|
86
78
|
guestfs.should_receive(:set_selinux).with(1)
|
87
79
|
|
88
80
|
@helper.should_receive(:hw_virtualization_available?).and_return(false)
|
89
|
-
@helper.should_receive(:load_selinux_policy)
|
90
81
|
|
91
|
-
|
92
|
-
|
93
|
-
File.should_receive(:exists?).with('/usr/bin/qemu-system-x86_64').and_return(true)
|
94
|
-
guestfs.should_receive(:set_qemu).with('/usr/bin/qemu-system-x86_64')
|
82
|
+
guestfs.should_receive(:set_qemu).with(/\/qemu\.wrapper$/)
|
95
83
|
guestfs.should_receive(:add_drive).with('a/raw/disk')
|
96
84
|
guestfs.should_receive(:set_network).with(1)
|
97
|
-
guestfs.should_receive(:launch)
|
98
|
-
guestfs.should_receive(:list_devices).and_return(['/dev/vda'])
|
99
|
-
guestfs.should_receive(:list_partitions).and_return([])
|
100
85
|
|
101
|
-
|
102
|
-
|
103
|
-
@helper.should_receive(:mount_partition).with('/dev/vda', '/', '')
|
104
|
-
@helper.execute.should == @helper
|
86
|
+
@helper.prepare_guestfs {}
|
105
87
|
end
|
88
|
+
end
|
106
89
|
|
107
|
-
|
90
|
+
describe ".initialize_guestfs" do
|
91
|
+
it "should initialize the guestfs env with callback support" do
|
108
92
|
guestfs = mock('Guestfs')
|
109
|
-
guestfs.should_receive(:
|
110
|
-
|
111
|
-
guestfs.should_receive(:set_trace)
|
112
|
-
guestfs.should_receive(:set_selinux).with(1)
|
93
|
+
guestfs.should_receive(:respond_to?).with(:set_event_callback).and_return(true)
|
94
|
+
@helper.should_receive(:log_callback)
|
113
95
|
|
114
|
-
|
115
|
-
|
96
|
+
FileUtils.should_receive(:mkdir_p).with('/tmp')
|
97
|
+
Guestfs.should_receive(:create).and_return(guestfs)
|
116
98
|
|
117
|
-
|
99
|
+
@helper.initialize_guestfs
|
100
|
+
end
|
118
101
|
|
119
|
-
|
120
|
-
guestfs
|
121
|
-
guestfs.should_receive(:
|
122
|
-
|
123
|
-
guestfs.should_receive(:launch)
|
124
|
-
guestfs.should_receive(:list_devices).and_return(['/dev/vda'])
|
125
|
-
guestfs.should_receive(:list_partitions).and_return(['/dev/vda1', '/dev/vda2'])
|
102
|
+
it "should initialize the guestfs env without callback support" do
|
103
|
+
guestfs = mock('Guestfs')
|
104
|
+
guestfs.should_receive(:respond_to?).with(:set_event_callback).and_return(false)
|
105
|
+
@helper.should_receive(:log_hack)
|
126
106
|
|
107
|
+
FileUtils.should_receive(:mkdir_p).with('/tmp')
|
127
108
|
Guestfs.should_receive(:create).and_return(guestfs)
|
128
109
|
|
129
|
-
@helper.
|
130
|
-
@helper.execute.should == @helper
|
110
|
+
@helper.initialize_guestfs
|
131
111
|
end
|
112
|
+
end
|
132
113
|
|
133
|
-
|
114
|
+
describe ".execute" do
|
115
|
+
it "should run guestfs with one partition" do
|
134
116
|
@appliance_config.stub!(:hardware).and_return(:partitions => {'/' => nil})
|
135
117
|
|
136
118
|
guestfs = mock('Guestfs')
|
137
|
-
|
138
|
-
guestfs.should_receive(:set_verbose)
|
139
|
-
guestfs.should_receive(:set_trace)
|
140
|
-
guestfs.should_receive(:set_selinux).with(1)
|
141
|
-
|
142
|
-
@helper.should_receive(:hw_virtualization_available?).and_return(true)
|
143
|
-
@helper.should_receive(:load_selinux_policy)
|
119
|
+
@helper.instance_variable_set(:@guestfs, guestfs)
|
144
120
|
|
145
|
-
guestfs.should_receive(:add_drive).with('a/raw/disk')
|
146
|
-
guestfs.should_receive(:set_network).with(1)
|
147
121
|
guestfs.should_receive(:launch)
|
148
122
|
guestfs.should_receive(:list_devices).and_return(['/dev/vda'])
|
149
123
|
guestfs.should_receive(:list_partitions).and_return(['/dev/vda1'])
|
150
124
|
|
151
|
-
|
152
|
-
|
153
|
-
guestfs.should_receive(:list_partitions).and_return(['/dev/vda1'])
|
154
|
-
@helper.should_receive(:mount_partition).with("/dev/vda1", "/", '')
|
155
|
-
|
156
|
-
guestfs.should_receive(:set_e2label).with("/dev/vda1", "79d3d2d4")
|
125
|
+
@helper.should_receive(:mount_partitions).with("/dev/vda", '')
|
126
|
+
@helper.should_receive(:load_selinux_policy)
|
157
127
|
|
158
|
-
@helper.execute
|
128
|
+
@helper.execute
|
159
129
|
end
|
160
130
|
|
161
|
-
it "should
|
131
|
+
it "should run guestfs with two partitions" do
|
132
|
+
@appliance_config.stub!(:hardware).and_return(:partitions => {'/' => nil, '/home' => nil})
|
133
|
+
|
162
134
|
guestfs = mock('Guestfs')
|
163
|
-
|
164
|
-
guestfs.should_receive(:set_verbose)
|
165
|
-
guestfs.should_receive(:set_trace)
|
166
|
-
guestfs.should_receive(:set_selinux).with(1)
|
135
|
+
@helper.instance_variable_set(:@guestfs, guestfs)
|
167
136
|
|
168
|
-
|
137
|
+
guestfs.should_receive(:launch)
|
138
|
+
guestfs.should_receive(:list_devices).and_return(['/dev/vda'])
|
139
|
+
guestfs.should_receive(:list_partitions).and_return(['/dev/vda1', '/dev/vda2'])
|
140
|
+
|
141
|
+
@helper.should_receive(:mount_partitions).with("/dev/vda", "")
|
169
142
|
@helper.should_receive(:load_selinux_policy)
|
170
143
|
|
171
|
-
|
172
|
-
|
144
|
+
@helper.execute
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should run guestfs with no partitions and don't load selinux" do
|
148
|
+
@appliance_config.stub!(:hardware).and_return(:partitions => {'/' => nil, '/home' => nil})
|
149
|
+
|
150
|
+
guestfs = mock('Guestfs')
|
151
|
+
@helper.instance_variable_set(:@guestfs, guestfs)
|
152
|
+
|
173
153
|
guestfs.should_receive(:launch)
|
154
|
+
guestfs.should_receive(:list_devices).and_return(['/dev/vda'])
|
174
155
|
guestfs.should_receive(:list_partitions).and_return([])
|
175
156
|
|
176
|
-
|
177
|
-
|
178
|
-
guestfs.should_receive(:list_devices).and_return(['/dev/sda'])
|
179
|
-
@helper.should_receive(:mount_partition).with("/dev/sda", "/", '')
|
157
|
+
@helper.should_receive(:mount_partition).with("/dev/vda", "/", "")
|
158
|
+
@helper.should_not_receive(:load_selinux_policy)
|
180
159
|
|
181
|
-
@helper.execute
|
160
|
+
@helper.execute(:load_selinux_policy => false)
|
182
161
|
end
|
183
162
|
end
|
184
163
|
|
@@ -194,26 +173,37 @@ module BoxGrinder
|
|
194
173
|
@helper.clean_close
|
195
174
|
end
|
196
175
|
|
197
|
-
|
198
|
-
|
176
|
+
describe ".mount_partition" do
|
177
|
+
it "should mount root partition" do
|
178
|
+
guestfs = mock('Guestfs')
|
199
179
|
|
200
|
-
|
180
|
+
guestfs.should_receive(:mount_options).with("", "/dev/sda", "/")
|
181
|
+
guestfs.should_receive(:set_e2label).with("/dev/sda", "79d3d2d4")
|
201
182
|
|
202
|
-
|
203
|
-
|
183
|
+
@helper.instance_variable_set(:@guestfs, guestfs)
|
184
|
+
@helper.mount_partition("/dev/sda", "/")
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should mount home partition" do
|
188
|
+
guestfs = mock('Guestfs')
|
189
|
+
|
190
|
+
guestfs.should_receive(:mount_options).with("", "/dev/sda", "/home")
|
191
|
+
guestfs.should_receive(:set_e2label).with("/dev/sda", "d5219c04")
|
192
|
+
|
193
|
+
@helper.instance_variable_set(:@guestfs, guestfs)
|
194
|
+
@helper.mount_partition("/dev/sda", "/home")
|
195
|
+
end
|
204
196
|
end
|
205
197
|
|
206
198
|
describe ".mount_partitions" do
|
207
|
-
it "should mount partitions" do
|
199
|
+
it "should mount two partitions" do
|
208
200
|
guestfs = mock('Guestfs')
|
209
201
|
|
210
202
|
@appliance_config.stub!(:hardware).and_return(:partitions => {'/' => nil, '/home' => nil})
|
211
203
|
guestfs.should_receive(:list_partitions).and_return(['/dev/vda1', '/dev/vda2'])
|
212
204
|
|
213
205
|
@helper.should_receive(:mount_partition).with('/dev/vda1', '/', '')
|
214
|
-
guestfs.should_receive(:set_e2label).with("/dev/vda1", "79d3d2d4")
|
215
206
|
@helper.should_receive(:mount_partition).with('/dev/vda2', '/home', '')
|
216
|
-
guestfs.should_receive(:set_e2label).with("/dev/vda2", "d5219c04")
|
217
207
|
|
218
208
|
@helper.instance_variable_set(:@guestfs, guestfs)
|
219
209
|
@helper.mount_partitions('/dev/vda')
|
@@ -226,13 +216,9 @@ module BoxGrinder
|
|
226
216
|
guestfs.should_receive(:list_partitions).and_return(['/dev/vda1', '/dev/vda2', '/dev/vda3', '/dev/vda4', '/dev/vda5'])
|
227
217
|
|
228
218
|
@helper.should_receive(:mount_partition).with('/dev/vda1', '/', '')
|
229
|
-
guestfs.should_receive(:set_e2label).with("/dev/vda1", "79d3d2d4")
|
230
219
|
@helper.should_receive(:mount_partition).with('/dev/vda2', '/home', '')
|
231
|
-
guestfs.should_receive(:set_e2label).with("/dev/vda2", "d5219c04")
|
232
220
|
@helper.should_receive(:mount_partition).with('/dev/vda3', '/var/www', '')
|
233
|
-
guestfs.should_receive(:set_e2label).with("/dev/vda3", "8d86efc1")
|
234
221
|
@helper.should_receive(:mount_partition).with('/dev/vda5', '/var/mock', '')
|
235
|
-
guestfs.should_receive(:set_e2label).with("/dev/vda5", "e7b3b1f2")
|
236
222
|
|
237
223
|
@helper.instance_variable_set(:@guestfs, guestfs)
|
238
224
|
@helper.mount_partitions('/dev/vda')
|
@@ -262,13 +248,13 @@ module BoxGrinder
|
|
262
248
|
describe ".hw_virtualization_available?" do
|
263
249
|
it "should return true if HW acceleration is available" do
|
264
250
|
Resolv.should_receive(:getname).with("169.254.169.254").and_return("blah")
|
265
|
-
@helper.should_receive(:`).with('
|
251
|
+
@helper.should_receive(:`).with("egrep '^flags.*(vmx|svm)' /proc/cpuinfo | wc -l").and_return("2")
|
266
252
|
@helper.hw_virtualization_available?.should == true
|
267
253
|
end
|
268
254
|
|
269
255
|
it "should return false if no vmx flag is present" do
|
270
256
|
Resolv.should_receive(:getname).with("169.254.169.254").and_return("blah")
|
271
|
-
@helper.should_receive(:`).with('
|
257
|
+
@helper.should_receive(:`).with("egrep '^flags.*(vmx|svm)' /proc/cpuinfo | wc -l").and_return("0")
|
272
258
|
@helper.hw_virtualization_available?.should == false
|
273
259
|
end
|
274
260
|
|
@@ -332,5 +318,47 @@ module BoxGrinder
|
|
332
318
|
@helper.umount_partition('/dev/vda1')
|
333
319
|
end
|
334
320
|
end
|
321
|
+
|
322
|
+
describe ".customize" do
|
323
|
+
it "should execute customize wihout issues" do
|
324
|
+
@helper.should_receive(:initialize_guestfs).and_yield
|
325
|
+
@helper.should_receive(:clean_close)
|
326
|
+
@helper.should_receive(:execute).with(:a => :b)
|
327
|
+
|
328
|
+
@helper.customize(:a => :b) do |guestfs, guestfs_helper|
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
describe ".log_callback" do
|
334
|
+
it "should register callback for all 3 events" do
|
335
|
+
guestfs = mock('Guestfs')
|
336
|
+
@helper.instance_variable_set(:@guestfs, guestfs)
|
337
|
+
guestfs.should_receive(:set_event_callback).with(an_instance_of(Proc), 16 | 32 | 64)
|
338
|
+
@helper.log_callback
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
describe ".log_hack" do
|
343
|
+
it "should register callback for all 3 events" do
|
344
|
+
guestfs = mock('Guestfs')
|
345
|
+
pread = ['a', 'b']
|
346
|
+
pwrite = mock('pwrite')
|
347
|
+
old_stderr = mock('old_stderr')
|
348
|
+
|
349
|
+
IO.should_receive(:pipe).and_return([pread, pwrite])
|
350
|
+
STDERR.should_receive(:clone).and_return(old_stderr)
|
351
|
+
STDERR.should_receive(:reopen).with(pwrite)
|
352
|
+
STDERR.should_receive(:reopen).with(old_stderr)
|
353
|
+
|
354
|
+
pread.should_receive(:close)
|
355
|
+
pwrite.should_receive(:close)
|
356
|
+
|
357
|
+
Process.should_receive(:wait)
|
358
|
+
|
359
|
+
@helper.should_receive(:fork)
|
360
|
+
@helper.log_hack
|
361
|
+
end
|
362
|
+
end
|
335
363
|
end
|
336
364
|
end
|