boxgrinder-build 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -0
- data/README.md +136 -0
- data/Rakefile +11 -6
- data/bin/boxgrinder-build +199 -0
- data/boxgrinder-build.gemspec +26 -14
- data/lib/boxgrinder-build/appliance.rb +6 -6
- data/lib/boxgrinder-build/helpers/guestfs-helper.rb +5 -3
- data/lib/boxgrinder-build/helpers/image-helper.rb +6 -0
- data/lib/boxgrinder-build/helpers/plugin-helper.rb +15 -4
- data/lib/boxgrinder-build/plugins/base-plugin.rb +1 -0
- data/lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb +280 -0
- data/lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb +66 -0
- data/lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb +242 -0
- data/lib/boxgrinder-build/plugins/delivery/s3/src/cert-ec2.pem +23 -0
- data/lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb +152 -0
- data/lib/boxgrinder-build/plugins/delivery/usb/usb-plugin.rb +43 -0
- data/lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb +46 -0
- data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +61 -0
- data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +67 -0
- data/lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb +118 -0
- data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb +202 -0
- data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-dependency-validator.rb +153 -0
- data/lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb +37 -0
- data/lib/boxgrinder-build/plugins/os/rpm-based/src/base.repo +4 -0
- data/lib/boxgrinder-build/plugins/os/rpm-based/src/motd.init +21 -0
- data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +239 -0
- data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit +7 -0
- data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit +7 -0
- data/lib/boxgrinder-build/plugins/platform/ec2/src/ifcfg-eth0 +7 -0
- data/lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst +6 -0
- data/lib/boxgrinder-build/plugins/platform/ec2/src/rc_local +19 -0
- data/lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb +62 -0
- data/lib/boxgrinder-build/plugins/platform/vmware/src/README-enterprise +18 -0
- data/lib/boxgrinder-build/plugins/platform/vmware/src/README-personal +16 -0
- data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk +20 -0
- data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx +45 -0
- data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +194 -0
- data/rubygem-boxgrinder-build.spec +73 -10
- data/spec/appliance-spec.rb +2 -2
- data/spec/helpers/guestfs-helper-spec.rb +4 -2
- data/spec/helpers/image-helper-spec.rb +4 -0
- data/spec/helpers/plugin-helper-spec.rb +0 -38
- data/spec/managers/plugin-manager-spec.rb +6 -6
- data/spec/plugins/delivery/ebs/ebs-plugin-spec.rb +230 -0
- data/spec/plugins/delivery/ebs/ebs.yaml +3 -0
- data/spec/plugins/delivery/local/local-plugin-spec.rb +133 -0
- data/spec/plugins/delivery/s3/s3-plugin-spec.rb +351 -0
- data/spec/plugins/delivery/sftp/sftp-plugin-spec.rb +26 -0
- data/spec/plugins/os/centos/centos-plugin-spec.rb +52 -0
- data/spec/plugins/os/fedora/fedora-plugin-spec.rb +73 -0
- data/spec/plugins/os/rhel/rhel-plugin-spec.rb +158 -0
- data/spec/plugins/os/rpm-based/kickstart-spec.rb +129 -0
- data/spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb +162 -0
- data/spec/plugins/os/rpm-based/rpm-dependency-validator-spec.rb +50 -0
- data/spec/plugins/os/rpm-based/src/jeos-f13-plain.ks +20 -0
- data/spec/plugins/os/rpm-based/src/jeos-f13-without-version.ks +22 -0
- data/spec/plugins/os/rpm-based/src/jeos-f13.ks +23 -0
- data/spec/plugins/platform/ec2/ec2-plugin-spec.rb +339 -0
- data/spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb +118 -0
- data/spec/plugins/platform/vmware/vmware-plugin-spec.rb +299 -0
- metadata +149 -25
- data/README +0 -7
- data/bin/boxgrinder +0 -128
- data/lib/boxgrinder-build/helpers/thor-helper.rb +0 -85
@@ -0,0 +1,194 @@
|
|
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/plugins/base-plugin'
|
20
|
+
require 'boxgrinder-build/helpers/appliance-customize-helper'
|
21
|
+
|
22
|
+
module BoxGrinder
|
23
|
+
class VMwarePlugin < BasePlugin
|
24
|
+
def after_init
|
25
|
+
set_default_config_value('thin_disk', false)
|
26
|
+
validate_plugin_config(['type'], 'http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#VMware_Platform_Plugin')
|
27
|
+
|
28
|
+
register_deliverable(:vmx => "#{@appliance_config.name}.vmx",
|
29
|
+
:readme => "README")
|
30
|
+
|
31
|
+
if @plugin_config['type'].eql?('personal') and @plugin_config['thin_disk']
|
32
|
+
register_deliverable(:disk => "#{@appliance_config.name}.vmdk")
|
33
|
+
else
|
34
|
+
register_deliverable(:disk => "#{@appliance_config.name}.raw",
|
35
|
+
:vmdk => "#{@appliance_config.name}.vmdk")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def execute
|
40
|
+
@log.info "Converting image to VMware #{@plugin_config['type']} format..."
|
41
|
+
|
42
|
+
case @plugin_config['type']
|
43
|
+
when 'personal'
|
44
|
+
build_vmware_personal
|
45
|
+
when 'enterprise'
|
46
|
+
build_vmware_enterprise
|
47
|
+
else
|
48
|
+
raise "Not known VMware format specified. Available are: personal and enterprise. See http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#VMware_Platform_Plugin for more info."
|
49
|
+
end
|
50
|
+
|
51
|
+
customize_image
|
52
|
+
|
53
|
+
File.open(@deliverables.readme, "w") { |f| f.write(create_readme) }
|
54
|
+
|
55
|
+
@log.info "Image converted to VMware format."
|
56
|
+
end
|
57
|
+
|
58
|
+
def create_readme
|
59
|
+
readme = File.open("#{File.dirname(__FILE__)}/src/README-#{@plugin_config['type']}").read
|
60
|
+
readme.gsub!(/#APPLIANCE_NAME#/, @appliance_config.name)
|
61
|
+
|
62
|
+
readme
|
63
|
+
end
|
64
|
+
|
65
|
+
# returns value of cylinders, heads and sector for selected disk size (in GB)
|
66
|
+
# http://kb.vmware.com/kb/1026254
|
67
|
+
def generate_scsi_chs(disk_size)
|
68
|
+
if disk_size < 1
|
69
|
+
h = 64
|
70
|
+
s = 32
|
71
|
+
else
|
72
|
+
if disk_size < 2
|
73
|
+
h = 128
|
74
|
+
s = 32
|
75
|
+
else
|
76
|
+
h = 255
|
77
|
+
s = 63
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# GB MB KB B
|
82
|
+
c = disk_size * 1024 * 1024 * 1024 / (h*s*512)
|
83
|
+
total_sectors = disk_size * 1024 * 1024 * 1024 / 512
|
84
|
+
|
85
|
+
[c.to_i, h.to_i, s.to_i, total_sectors.to_i]
|
86
|
+
end
|
87
|
+
|
88
|
+
def change_vmdk_values(type)
|
89
|
+
vmdk_data = File.open("#{File.dirname(__FILE__)}/src/base.vmdk").read
|
90
|
+
|
91
|
+
disk_size = 0.0
|
92
|
+
@appliance_config.hardware.partitions.values.each { |part| disk_size += part['size'].to_f }
|
93
|
+
|
94
|
+
c, h, s, total_sectors = generate_scsi_chs(disk_size)
|
95
|
+
|
96
|
+
is_enterprise = type.eql?("vmfs")
|
97
|
+
|
98
|
+
vmdk_data.gsub!(/#NAME#/, @appliance_config.name)
|
99
|
+
vmdk_data.gsub!(/#TYPE#/, type)
|
100
|
+
vmdk_data.gsub!(/#EXTENT_TYPE#/, is_enterprise ? "VMFS" : "FLAT")
|
101
|
+
vmdk_data.gsub!(/#NUMBER#/, is_enterprise ? "" : "0")
|
102
|
+
vmdk_data.gsub!(/#HW_VERSION#/, "7")
|
103
|
+
vmdk_data.gsub!(/#CYLINDERS#/, c.to_s)
|
104
|
+
vmdk_data.gsub!(/#HEADS#/, h.to_s)
|
105
|
+
vmdk_data.gsub!(/#SECTORS#/, s.to_s)
|
106
|
+
vmdk_data.gsub!(/#TOTAL_SECTORS#/, total_sectors.to_s)
|
107
|
+
vmdk_data.gsub!(/#THIN_PROVISIONED#/, @plugin_config['thin_disk'] ? "1" : "0")
|
108
|
+
|
109
|
+
vmdk_data
|
110
|
+
end
|
111
|
+
|
112
|
+
def change_common_vmx_values
|
113
|
+
vmx_data = File.open("#{File.dirname(__FILE__)}/src/base.vmx").read
|
114
|
+
|
115
|
+
# replace version with current appliance version
|
116
|
+
vmx_data.gsub!(/#VERSION#/, "#{@appliance_config.version}.#{@appliance_config.release}")
|
117
|
+
# change name
|
118
|
+
vmx_data.gsub!(/#NAME#/, @appliance_config.name.to_s)
|
119
|
+
# and summary
|
120
|
+
vmx_data.gsub!(/#SUMMARY#/, @appliance_config.summary.to_s)
|
121
|
+
# replace guestOS informations to: linux or otherlinux-64, this seems to be the savests values
|
122
|
+
vmx_data.gsub!(/#GUESTOS#/, "#{@appliance_config.hardware.arch == "x86_64" ? "otherlinux-64" : "linux"}")
|
123
|
+
# memory size
|
124
|
+
vmx_data.gsub!(/#MEM_SIZE#/, @appliance_config.hardware.memory.to_s)
|
125
|
+
# memory size
|
126
|
+
vmx_data.gsub!(/#VCPU#/, @appliance_config.hardware.cpus.to_s)
|
127
|
+
# network name
|
128
|
+
# vmx_data.gsub!( /#NETWORK_NAME#/, @image_config.network_name )
|
129
|
+
|
130
|
+
vmx_data
|
131
|
+
end
|
132
|
+
|
133
|
+
def customize_image
|
134
|
+
unless @appliance_config.post['vmware'].nil? or @appliance_config.post['vmware'].empty?
|
135
|
+
@image_helper.customize(@deliverables.disk) do |guestfs, guestfs_helper|
|
136
|
+
@appliance_config.post['vmware'].each do |cmd|
|
137
|
+
guestfs_helper.sh(cmd, :arch => @appliance_config.hardware.arch)
|
138
|
+
end
|
139
|
+
@log.debug "Post commands from appliance definition file executed."
|
140
|
+
end
|
141
|
+
else
|
142
|
+
@log.debug "No commands specified, skipping."
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def copy_raw_image
|
147
|
+
@log.debug "Copying VMware image file, this may take several minutes..."
|
148
|
+
@exec_helper.execute "cp '#{@previous_deliverables.disk}' '#{@deliverables.disk}'"
|
149
|
+
@log.debug "VMware image copied."
|
150
|
+
end
|
151
|
+
|
152
|
+
def build_vmware_personal
|
153
|
+
@log.debug "Building VMware personal image."
|
154
|
+
|
155
|
+
if @plugin_config['thin_disk']
|
156
|
+
@log.debug "Using qemu-img to convert the image..."
|
157
|
+
@image_helper.convert_disk(@previous_deliverables.disk, :vmdk, @deliverables.disk)
|
158
|
+
@log.debug "Conversion done."
|
159
|
+
else
|
160
|
+
copy_raw_image
|
161
|
+
|
162
|
+
# create disk descriptor file
|
163
|
+
File.open(@deliverables.vmdk, "w") { |f| f.write(change_vmdk_values("monolithicFlat")) }
|
164
|
+
end
|
165
|
+
|
166
|
+
# create .vmx file
|
167
|
+
File.open(@deliverables.vmx, "w") { |f| f.write(change_common_vmx_values) }
|
168
|
+
|
169
|
+
@log.debug "VMware personal image was built."
|
170
|
+
end
|
171
|
+
|
172
|
+
def build_vmware_enterprise
|
173
|
+
@log.debug "Building VMware enterprise image."
|
174
|
+
|
175
|
+
copy_raw_image
|
176
|
+
|
177
|
+
# defaults for ESXi (maybe for others too)
|
178
|
+
@appliance_config.hardware.network = "VM Network" if @appliance_config.hardware.network.eql?("NAT")
|
179
|
+
|
180
|
+
# create .vmx file
|
181
|
+
vmx_data = change_common_vmx_values
|
182
|
+
vmx_data += "ethernet0.networkName = \"#{@appliance_config.hardware.network}\""
|
183
|
+
|
184
|
+
File.open(@deliverables.vmx, "w") { |f| f.write(vmx_data) }
|
185
|
+
|
186
|
+
# create disk descriptor file
|
187
|
+
File.open(@deliverables.vmdk, "w") { |f| f.write(change_vmdk_values("vmfs")) }
|
188
|
+
|
189
|
+
@log.debug "VMware enterprise image was built."
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
plugin :class => BoxGrinder::VMwarePlugin, :type => :platform, :name => :vmware, :full_name => "VMware"
|
@@ -5,32 +5,81 @@
|
|
5
5
|
|
6
6
|
Summary: A tool for creating appliances from simple plain text files
|
7
7
|
Name: rubygem-%{gemname}
|
8
|
-
Version: 0.
|
8
|
+
Version: 0.9.0
|
9
9
|
Release: 1%{?dist}
|
10
10
|
Group: Development/Languages
|
11
11
|
License: LGPLv3+
|
12
12
|
URL: http://boxgrinder.org/
|
13
13
|
Source0: http://rubygems.org/gems/%{gemname}-%{version}.gem
|
14
|
-
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
15
14
|
|
16
15
|
Requires: ruby(abi) = %{rubyabi}
|
17
|
-
Requires: rubygem(
|
18
|
-
Requires: rubygem(boxgrinder-core)
|
19
|
-
Requires: rubygem(boxgrinder-core) < 0.3.0
|
16
|
+
Requires: rubygem(boxgrinder-core) >= 0.3.0
|
17
|
+
Requires: rubygem(boxgrinder-core) < 0.4.0
|
20
18
|
Requires: ruby-libguestfs
|
21
19
|
Requires: parted
|
22
20
|
Requires: e2fsprogs
|
23
21
|
|
22
|
+
# For EL5
|
23
|
+
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
|
24
|
+
BuildArch: noarch
|
25
|
+
|
24
26
|
BuildRequires: rubygem(rake)
|
25
27
|
BuildRequires: rubygem(rspec)
|
26
|
-
BuildRequires: rubygem(boxgrinder-core) >= 0.
|
27
|
-
BuildRequires: rubygem(boxgrinder-core) < 0.
|
28
|
+
BuildRequires: rubygem(boxgrinder-core) >= 0.3.0
|
29
|
+
BuildRequires: rubygem(boxgrinder-core) < 0.4.0
|
28
30
|
BuildRequires: rubygem(echoe)
|
29
31
|
BuildRequires: ruby-libguestfs
|
30
32
|
|
31
|
-
|
33
|
+
# EBS and S3
|
34
|
+
Requires: rubygem(amazon-ec2)
|
35
|
+
# Fixes blankslate error
|
36
|
+
Requires: rubygem(builder)
|
37
|
+
Requires: rubygem(aws)
|
38
|
+
Requires: euca2ools >= 1.3.1-4
|
39
|
+
|
40
|
+
BuildRequires: rubygem(amazon-ec2)
|
41
|
+
BuildRequires: rubygem(aws)
|
42
|
+
# Fixes blankslate error
|
43
|
+
BuildRequires: rubygem(builder)
|
44
|
+
|
45
|
+
# SFTP
|
46
|
+
Requires: rubygem(net-sftp)
|
47
|
+
Requires: rubygem(net-ssh)
|
48
|
+
Requires: rubygem(progressbar)
|
49
|
+
|
50
|
+
BuildRequires: rubygem(net-sftp)
|
51
|
+
BuildRequires: rubygem(net-ssh)
|
52
|
+
BuildRequires: rubygem(progressbar)
|
53
|
+
|
54
|
+
# RPM-BASED
|
55
|
+
Requires: appliance-tools
|
56
|
+
Requires: yum-utils
|
57
|
+
|
58
|
+
# EC2
|
59
|
+
Requires: rsync
|
60
|
+
Requires: wget
|
61
|
+
Requires: util-linux
|
62
|
+
|
32
63
|
Provides: rubygem(%{gemname}) = %{version}
|
33
64
|
|
65
|
+
Obsoletes: rubygem(boxgrinder-build-ebs-delivery-plugin) < 0.0.4-2
|
66
|
+
Obsoletes: rubygem(boxgrinder-build-s3-delivery-plugin) < 0.0.6-1
|
67
|
+
Obsoletes: rubygem(boxgrinder-build-local-delivery-plugin) < 0.0.6-2
|
68
|
+
Obsoletes: rubygem(boxgrinder-build-sftp-delivery-plugin) < 0.0.5-2
|
69
|
+
Obsoletes: rubygem(boxgrinder-build-fedora-os-plugin) < 0.0.6-2
|
70
|
+
Obsoletes: rubygem(boxgrinder-build-rpm-based-os-plugin) < 0.0.11-1
|
71
|
+
Obsoletes: rubygem(boxgrinder-build-ec2-platform-plugin) < 0.0.10-2
|
72
|
+
Obsoletes: rubygem(boxgrinder-build-vmware-platform-plugin) < 0.0.10-2
|
73
|
+
|
74
|
+
Provides: rubygem(boxgrinder-build-ebs-delivery-plugin) = %{version}-%{release}
|
75
|
+
Provides: rubygem(boxgrinder-build-s3-delivery-plugin) = %{version}-%{release}
|
76
|
+
Provides: rubygem(boxgrinder-build-local-delivery-plugin) = %{version}-%{release}
|
77
|
+
Provides: rubygem(boxgrinder-build-sftp-delivery-plugin) = %{version}-%{release}
|
78
|
+
Provides: rubygem(boxgrinder-build-fedora-os-plugin) = %{version}-%{release}
|
79
|
+
Provides: rubygem(boxgrinder-build-rpm-based-os-plugin) = %{version}-%{release}
|
80
|
+
Provides: rubygem(boxgrinder-build-ec2-platform-plugin) = %{version}-%{release}
|
81
|
+
Provides: rubygem(boxgrinder-build-vmware-platform-plugin) = %{version}-%{release}
|
82
|
+
|
34
83
|
%description
|
35
84
|
A tool for creating appliances from simple plain text files for various
|
36
85
|
virtual environments
|
@@ -68,13 +117,13 @@ popd
|
|
68
117
|
|
69
118
|
%files
|
70
119
|
%defattr(-, root, root, -)
|
71
|
-
%{_bindir}/boxgrinder
|
120
|
+
%{_bindir}/boxgrinder-build
|
72
121
|
%dir %{geminstdir}
|
73
122
|
%{geminstdir}/bin
|
74
123
|
%{geminstdir}/lib
|
75
124
|
%doc %{geminstdir}/CHANGELOG
|
76
125
|
%doc %{geminstdir}/LICENSE
|
77
|
-
%doc %{geminstdir}/README
|
126
|
+
%doc %{geminstdir}/README.md
|
78
127
|
%doc %{geminstdir}/Manifest
|
79
128
|
%{gemdir}/cache/%{gemname}-%{version}.gem
|
80
129
|
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
|
@@ -88,6 +137,20 @@ popd
|
|
88
137
|
%{gemdir}/doc/%{gemname}-%{version}
|
89
138
|
|
90
139
|
%changelog
|
140
|
+
* Tue Mar 01 2011 <msavy@redhat.com> - 0.9.0-1
|
141
|
+
- Upstream release: 0.9.0
|
142
|
+
- [BGBUILD-103] README to indicate supported operating systems / requirements
|
143
|
+
- [BGBUILD-169] S3 plugin temporary work-around for EL5
|
144
|
+
- [BGBUILD-174] Move plugins to boxgrinder-build gem
|
145
|
+
- [BGBUILD-175] Rewrite boxgrinder CLI to remove thor dependency
|
146
|
+
- [BGBUILD-81] post command execution w/ setarch breaks commands which are scripts
|
147
|
+
- [BGBUILD-173] Include setarch package in default package list for RPM-based OSes
|
148
|
+
- [BGBUILD-177] Fedora 13 builds have enabled firewall although they shouldn't have it
|
149
|
+
- [BGBUILD-178] Remove sensitive data from logs
|
150
|
+
- [BGBUILD-179] Boolean and numeric parameters in hash-like values are not recognized
|
151
|
+
- [BGBUILD-176] Fail the build with appropriate message if any of post section commands fails to execute
|
152
|
+
- [BGBUILD-183] Add support for Fedora 15
|
153
|
+
|
91
154
|
* Tue Feb 16 2011 <mgoldman@redhat.com> - 0.8.1-1
|
92
155
|
- Upstream release: 0.8.1
|
93
156
|
- [BGBUILD-141] Long delay after "Preparing guestfs" message when creating new image
|
data/spec/appliance-spec.rb
CHANGED
@@ -229,7 +229,7 @@ module BoxGrinder
|
|
229
229
|
|
230
230
|
lambda {
|
231
231
|
@appliance.validate_definition
|
232
|
-
}.should raise_error(RuntimeError, "No operating system plugins installed. Install one or more operating system plugin. See http://
|
232
|
+
}.should raise_error(RuntimeError, "No operating system plugins installed. Install one or more operating system plugin. See http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Operating_system_plugins for more info.")
|
233
233
|
end
|
234
234
|
|
235
235
|
it "should validate definition and fail because no supported operating system plugins is installed" do
|
@@ -248,7 +248,7 @@ module BoxGrinder
|
|
248
248
|
|
249
249
|
lambda {
|
250
250
|
@appliance.validate_definition
|
251
|
-
}.should raise_error(RuntimeError, "Not supported operating system selected: fedora. Make sure you have installed right operating system plugin, see http://
|
251
|
+
}.should raise_error(RuntimeError, "Not supported operating system selected: fedora. Make sure you have installed right operating system plugin, see http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Operating_system_plugins. Supported OSes are: rhel")
|
252
252
|
end
|
253
253
|
|
254
254
|
it "should validate definition and fail because no supported operating system version plugins is installed" do
|
@@ -80,6 +80,7 @@ module BoxGrinder
|
|
80
80
|
|
81
81
|
RbConfig::CONFIG.should_receive(:[]).with('host_cpu').and_return('x86_64')
|
82
82
|
|
83
|
+
File.should_receive(:exists?).with('/usr/bin/qemu-system-x86_64').and_return(true)
|
83
84
|
guestfs.should_receive(:set_qemu).with('/usr/bin/qemu-system-x86_64')
|
84
85
|
guestfs.should_receive(:add_drive).with('a/raw/disk')
|
85
86
|
guestfs.should_receive(:set_network).with(1)
|
@@ -104,6 +105,7 @@ module BoxGrinder
|
|
104
105
|
|
105
106
|
RbConfig::CONFIG.should_receive(:[]).with('host_cpu').and_return('i386')
|
106
107
|
|
108
|
+
File.should_receive(:exists?).with('/usr/bin/qemu').and_return(true)
|
107
109
|
guestfs.should_receive(:set_qemu).with('/usr/bin/qemu')
|
108
110
|
guestfs.should_receive(:add_drive).with('a/raw/disk')
|
109
111
|
guestfs.should_receive(:set_network).with(1)
|
@@ -249,7 +251,7 @@ module BoxGrinder
|
|
249
251
|
@helper.should_receive(:`).with('uname -m').and_return('bleh')
|
250
252
|
@helper.instance_variable_set(:@guestfs, guestfs)
|
251
253
|
|
252
|
-
guestfs.should_receive(:sh).with("setarch bleh << SETARCH_EOF\ncommand\nSETARCH_EOF
|
254
|
+
guestfs.should_receive(:sh).with("setarch bleh << 'SETARCH_EOF'\ncommand\nSETARCH_EOF")
|
253
255
|
|
254
256
|
@helper.sh("command")
|
255
257
|
end
|
@@ -258,7 +260,7 @@ module BoxGrinder
|
|
258
260
|
guestfs = mock('Guestfs')
|
259
261
|
@helper.instance_variable_set(:@guestfs, guestfs)
|
260
262
|
|
261
|
-
guestfs.should_receive(:sh).with("setarch arch << SETARCH_EOF\ncommand\nSETARCH_EOF
|
263
|
+
guestfs.should_receive(:sh).with("setarch arch << 'SETARCH_EOF'\ncommand\nSETARCH_EOF")
|
262
264
|
|
263
265
|
@helper.sh("command", :arch => 'arch')
|
264
266
|
end
|
@@ -55,6 +55,7 @@ module BoxGrinder
|
|
55
55
|
@exec_helper.should_receive(:execute).with("losetup -o 0 /dev/loop0 'disk.raw'")
|
56
56
|
@exec_helper.should_receive(:execute).with('e2label /dev/loop0').and_return('/')
|
57
57
|
@exec_helper.should_receive(:execute).with("mount /dev/loop0 'mount_dir'")
|
58
|
+
@helper.should_receive(:sleep).with(2)
|
58
59
|
|
59
60
|
@helper.mount_image('disk.raw', 'mount_dir').should == {"/"=>"/dev/loop0"}
|
60
61
|
end
|
@@ -71,6 +72,7 @@ module BoxGrinder
|
|
71
72
|
|
72
73
|
@exec_helper.should_receive(:execute).with("mount /dev/loop1 'mount_dir'")
|
73
74
|
@exec_helper.should_receive(:execute).with("mount /dev/loop0 'mount_dir/home'")
|
75
|
+
@helper.should_receive(:sleep).with(2)
|
74
76
|
|
75
77
|
@helper.mount_image('disk.raw', 'mount_dir').should == {"/"=>"/dev/loop1", "/home"=>"/dev/loop0"}
|
76
78
|
end
|
@@ -80,6 +82,8 @@ module BoxGrinder
|
|
80
82
|
@exec_helper.should_receive(:execute).ordered.with('umount -d /dev/loop1')
|
81
83
|
FileUtils.should_receive(:rm_rf).with('mount_dir')
|
82
84
|
|
85
|
+
@helper.should_receive(:sleep).with(2)
|
86
|
+
|
83
87
|
@helper.umount_image('disk.raw', 'mount_dir', {"/"=>"/dev/loop1", "/home"=>"/dev/loop0"})
|
84
88
|
end
|
85
89
|
|
@@ -22,46 +22,14 @@ require 'ostruct'
|
|
22
22
|
|
23
23
|
module BoxGrinder
|
24
24
|
describe PluginHelper do
|
25
|
-
before(:all) do
|
26
|
-
@plugin_array = %w(boxgrinder-build-fedora-os-plugin boxgrinder-build-rhel-os-plugin boxgrinder-build-centos-os-plugin boxgrinder-build-ec2-platform-plugin boxgrinder-build-vmware-platform-plugin boxgrinder-build-virtualbox-platform-plugin boxgrinder-build-s3-delivery-plugin boxgrinder-build-sftp-delivery-plugin boxgrinder-build-local-delivery-plugin boxgrinder-build-ebs-delivery-plugin)
|
27
|
-
end
|
28
|
-
|
29
25
|
before(:each) do
|
30
26
|
@log = LogHelper.new(:level => :trace, :type => :stdout)
|
31
27
|
@plugin_helper = PluginHelper.new(OpenStruct.new(:additional_plugins => []), :log => @log)
|
32
28
|
end
|
33
29
|
|
34
|
-
it "should require default plugins" do
|
35
|
-
@plugin_array.each do |plugin|
|
36
|
-
@plugin_helper.should_receive(:require).once.with(plugin)
|
37
|
-
end
|
38
|
-
|
39
|
-
@plugin_helper.read_and_require
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should require default plugins and fail silently" do
|
43
|
-
@log = mock('Logger')
|
44
|
-
|
45
|
-
@plugin_helper.instance_variable_set(:@log, @log)
|
46
|
-
|
47
|
-
@plugin_array.each do |plugin|
|
48
|
-
@log.should_receive(:trace).with("Loading plugin '#{plugin}'...")
|
49
|
-
@plugin_helper.should_receive(:require).once.with(plugin).and_raise(LoadError)
|
50
|
-
@log.should_receive(:trace).with("- Not found: LoadError")
|
51
|
-
end
|
52
|
-
|
53
|
-
@log.should_not_receive(:warn)
|
54
|
-
|
55
|
-
@plugin_helper.read_and_require
|
56
|
-
end
|
57
|
-
|
58
30
|
it "should read plugins specified in command line" do
|
59
31
|
@plugin_helper = PluginHelper.new(OpenStruct.new(:additional_plugins => ['abc', 'def']), :log => @log)
|
60
32
|
|
61
|
-
@plugin_array.each do |plugin|
|
62
|
-
@plugin_helper.should_receive(:require).once.with(plugin)
|
63
|
-
end
|
64
|
-
|
65
33
|
@plugin_helper.should_receive(:require).ordered.with('abc')
|
66
34
|
@plugin_helper.should_receive(:require).ordered.with('def')
|
67
35
|
|
@@ -72,12 +40,6 @@ module BoxGrinder
|
|
72
40
|
@log = mock('Logger')
|
73
41
|
@plugin_helper = PluginHelper.new(OpenStruct.new(:additional_plugins => ['abc']), :log => @log)
|
74
42
|
|
75
|
-
@plugin_array.each do |plugin|
|
76
|
-
@log.should_receive(:trace).with("Loading plugin '#{plugin}'...")
|
77
|
-
@plugin_helper.should_receive(:require).once.with(plugin)
|
78
|
-
@log.should_receive(:trace).with("- OK")
|
79
|
-
end
|
80
|
-
|
81
43
|
@log.should_receive(:trace).with("Loading plugin 'abc'...")
|
82
44
|
@plugin_helper.should_receive(:require).ordered.with('abc').and_raise(LoadError)
|
83
45
|
@log.should_receive(:trace).with("- Not found: LoadError")
|
@@ -28,18 +28,18 @@ module BoxGrinder
|
|
28
28
|
it "should register simple plugin" do
|
29
29
|
@manager.register_plugin({:class => PluginManager, :type => :delivery, :name => :abc, :full_name => "Amazon Simple Storage Service (Amazon S3)"})
|
30
30
|
|
31
|
-
@manager.plugins[:delivery].size.should ==
|
31
|
+
@manager.plugins[:delivery].size.should == 7
|
32
32
|
@manager.plugins[:delivery][:abc][:class].should == PluginManager
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should register plugin with many types" do
|
36
|
-
@manager.register_plugin({:class => PluginManager, :type => :delivery, :name => :
|
36
|
+
@manager.register_plugin({:class => PluginManager, :type => :delivery, :name => :def, :full_name => "Amazon Simple Storage Service (Amazon S3)", :types => [:aaa, :bbb, :ccc]})
|
37
37
|
|
38
|
-
@manager.plugins[:delivery].size.should ==
|
38
|
+
@manager.plugins[:delivery].size.should == 10
|
39
39
|
@manager.plugins[:delivery][:abc][:class].should == PluginManager
|
40
|
-
@manager.plugins[:delivery][:
|
41
|
-
@manager.plugins[:delivery][:
|
42
|
-
@manager.plugins[:delivery][:
|
40
|
+
@manager.plugins[:delivery][:aaa][:class].should == PluginManager
|
41
|
+
@manager.plugins[:delivery][:bbb][:class].should == PluginManager
|
42
|
+
@manager.plugins[:delivery][:ccc][:class].should == PluginManager
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should initialize a plugin" do
|