boxgrinder-build 0.9.8 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +15 -0
- data/Manifest +7 -22
- data/Rakefile +3 -1
- data/bin/boxgrinder-build +1 -1
- data/boxgrinder-build.gemspec +17 -13
- data/integ/appliances/jeos-centos6.appl +4 -0
- data/lib/boxgrinder-build/appliance.rb +61 -23
- data/lib/boxgrinder-build/helpers/ec2-helper.rb +18 -0
- data/lib/boxgrinder-build/helpers/linux-helper.rb +41 -2
- data/lib/boxgrinder-build/helpers/plugin-helper.rb +3 -0
- data/lib/boxgrinder-build/helpers/s3-helper.rb +18 -0
- data/lib/boxgrinder-build/helpers/sftp-helper.rb +124 -0
- data/lib/boxgrinder-build/managers/plugin-manager.rb +5 -3
- data/lib/boxgrinder-build/plugins/base-plugin.rb +2 -22
- data/lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb +26 -15
- data/lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb +2 -1
- data/lib/boxgrinder-build/plugins/delivery/libvirt/libvirt-capabilities.rb +164 -0
- data/lib/boxgrinder-build/plugins/delivery/libvirt/libvirt-plugin.rb +313 -0
- data/lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb +2 -1
- data/lib/boxgrinder-build/plugins/delivery/openstack/openstack-plugin.rb +133 -0
- data/lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb +15 -2
- data/lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb +20 -106
- data/lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb +3 -3
- data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +2 -1
- data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +2 -1
- data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb +6 -64
- data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-dependency-validator.rb +2 -1
- data/lib/boxgrinder-build/plugins/os/sl/sl-plugin.rb +1 -2
- data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +15 -1
- data/lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb +2 -1
- data/lib/boxgrinder-build/plugins/platform/virtualpc/virtualpc-plugin.rb +58 -0
- data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +2 -1
- data/rubygem-boxgrinder-build.spec +25 -1
- data/spec/appliance-spec.rb +1 -58
- data/spec/helpers/linux-helper-spec.rb +70 -0
- data/spec/managers/plugin-manager-spec.rb +4 -13
- data/spec/plugins/delivery/ebs/ebs-plugin-spec.rb +6 -14
- data/spec/plugins/delivery/elastichosts/elastichosts-plugin-spec.rb +5 -6
- data/spec/plugins/delivery/libvirt/libvirt-plugin-spec.rb +300 -0
- data/spec/plugins/delivery/libvirt/libvirt_modified.xml +25 -0
- data/spec/plugins/delivery/libvirt/libvirt_modify.sh +18 -0
- data/spec/plugins/delivery/libvirt/libvirt_test.xml +24 -0
- data/spec/plugins/delivery/local/local-plugin-spec.rb +3 -6
- data/spec/plugins/delivery/openstack/openstack-plugin-spec.rb +103 -0
- data/spec/plugins/delivery/s3/s3-plugin-spec.rb +16 -5
- data/spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb +2 -80
- data/spec/plugins/platform/ec2/ec2-plugin-spec.rb +15 -1
- data/spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb +6 -6
- data/spec/plugins/platform/virtualpc/virtualpc-plugin-spec.rb +90 -0
- data/spec/plugins/platform/vmware/vmware-plugin-spec.rb +5 -9
- data/spec/rspec-plugin-helper.rb +47 -0
- metadata +54 -10
@@ -72,7 +72,8 @@ module BoxGrinder
|
|
72
72
|
arches = "x86_64"
|
73
73
|
end
|
74
74
|
|
75
|
-
|
75
|
+
root = (@config.dir.root.end_with?('/') ? '' : @config.dir.root)
|
76
|
+
repoquery_output = @exec_helper.execute( "repoquery --quiet --disablerepo=* --enablerepo=#{@appliance_config.repos.collect {|r| "#{@magic_hash}#{r['name']}"}.join(",")} -c '#{root}/#{@yum_config_file}' list available #{package_list.join( ' ' )} --nevra --archlist=#{arches},noarch" )
|
76
77
|
|
77
78
|
invalid_names = []
|
78
79
|
|
@@ -20,6 +20,7 @@ require 'boxgrinder-build/plugins/os/rhel/rhel-plugin'
|
|
20
20
|
|
21
21
|
module BoxGrinder
|
22
22
|
class ScientificLinuxPlugin < RHELPlugin
|
23
|
+
plugin :type => :os, :name => :sl, :full_name => "Scientific Linux", :versions => ["5", "6"]
|
23
24
|
|
24
25
|
SL_REPOS = {
|
25
26
|
"5" => {
|
@@ -52,5 +53,3 @@ module BoxGrinder
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
plugin :class => BoxGrinder::ScientificLinuxPlugin, :type => :os, :name => :sl, :full_name => "Scientific Linux", :versions => ["5", "6"]
|
56
|
-
|
@@ -22,6 +22,8 @@ require 'tempfile'
|
|
22
22
|
|
23
23
|
module BoxGrinder
|
24
24
|
class EC2Plugin < BasePlugin
|
25
|
+
plugin :type => :platform, :name => :ec2, :full_name => "Amazon Elastic Compute Cloud (Amazon EC2)"
|
26
|
+
|
25
27
|
def after_init
|
26
28
|
register_deliverable(:disk => "#{@appliance_config.name}.ec2")
|
27
29
|
|
@@ -148,11 +150,24 @@ module BoxGrinder
|
|
148
150
|
@log.debug "Nosegneg enabled."
|
149
151
|
end
|
150
152
|
|
153
|
+
# Adds ec2-user will full sudo access without password per Fedora security guidelines.
|
154
|
+
# We should not use root access on AMIs as it is not secure and prohibited by AWS.
|
155
|
+
#
|
151
156
|
# https://issues.jboss.org/browse/BGBUILD-110
|
152
157
|
def add_ec2_user(guestfs)
|
153
158
|
@log.debug "Adding ec2-user user..."
|
159
|
+
|
160
|
+
# We need to add ec2-user only when it doesn't exists
|
161
|
+
#
|
162
|
+
# https://issues.jboss.org/browse/BGBUILD-313
|
163
|
+
unless guestfs.fgrep("ec2-user", "/etc/passwd").empty?
|
164
|
+
@log.debug("ec2-user already exists, skipping.")
|
165
|
+
return
|
166
|
+
end
|
167
|
+
|
154
168
|
guestfs.sh("useradd ec2-user")
|
155
169
|
guestfs.sh("echo -e 'ec2-user\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers")
|
170
|
+
|
156
171
|
@log.debug "User ec2-user added."
|
157
172
|
end
|
158
173
|
|
@@ -209,4 +224,3 @@ module BoxGrinder
|
|
209
224
|
end
|
210
225
|
end
|
211
226
|
|
212
|
-
plugin :class => BoxGrinder::EC2Plugin, :type => :platform, :name => :ec2, :full_name => "Amazon Elastic Compute Cloud (Amazon EC2)"
|
@@ -21,6 +21,8 @@ require 'boxgrinder-build/helpers/linux-helper'
|
|
21
21
|
|
22
22
|
module BoxGrinder
|
23
23
|
class VirtualBoxPlugin < BasePlugin
|
24
|
+
plugin :type => :platform, :name => :virtualbox, :full_name => "VirtualBox"
|
25
|
+
|
24
26
|
def after_init
|
25
27
|
register_deliverable(:disk => "#{@appliance_config.name}.vmdk")
|
26
28
|
end
|
@@ -70,4 +72,3 @@ module BoxGrinder
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
|
-
plugin :class => BoxGrinder::VirtualBoxPlugin, :type => :platform, :name => :virtualbox, :full_name => "VirtualBox"
|
@@ -0,0 +1,58 @@
|
|
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
|
+
|
21
|
+
module BoxGrinder
|
22
|
+
class VirtualPCPlugin < BasePlugin
|
23
|
+
plugin :type => :platform, :name => :virtualpc, :full_name => "VirtualPC"
|
24
|
+
|
25
|
+
def after_init
|
26
|
+
register_deliverable(:disk => "#{@appliance_config.name}.vhd")
|
27
|
+
end
|
28
|
+
|
29
|
+
def execute
|
30
|
+
@log.info "Converting image to VirtualPC format..."
|
31
|
+
|
32
|
+
convert
|
33
|
+
customize_image
|
34
|
+
|
35
|
+
@log.info "Image converted to VirtualPC format."
|
36
|
+
end
|
37
|
+
|
38
|
+
def customize_image
|
39
|
+
unless @appliance_config.post['virtualpc'].nil? or @appliance_config.post['virtualpc'].empty?
|
40
|
+
@image_helper.customize(@deliverables.disk) do |guestfs, guestfs_helper|
|
41
|
+
@appliance_config.post['virtualpc'].each do |cmd|
|
42
|
+
guestfs_helper.sh(cmd, :arch => @appliance_config.hardware.arch)
|
43
|
+
end
|
44
|
+
@log.debug "Post commands from appliance definition file executed."
|
45
|
+
end
|
46
|
+
else
|
47
|
+
@log.debug "No commands specified, skipping."
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def convert
|
52
|
+
@log.debug "Using qemu-img to convert the image..."
|
53
|
+
@image_helper.convert_disk(@previous_deliverables.disk, :vpc, @deliverables.disk)
|
54
|
+
@log.debug "Conversion done."
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -20,6 +20,8 @@ require 'boxgrinder-build/plugins/base-plugin'
|
|
20
20
|
|
21
21
|
module BoxGrinder
|
22
22
|
class VMwarePlugin < BasePlugin
|
23
|
+
plugin :type => :platform, :name => :vmware, :full_name => "VMware"
|
24
|
+
|
23
25
|
def after_init
|
24
26
|
register_deliverable(:vmx => "#{@appliance_config.name}.vmx",
|
25
27
|
:readme => "README")
|
@@ -190,4 +192,3 @@ module BoxGrinder
|
|
190
192
|
end
|
191
193
|
end
|
192
194
|
|
193
|
-
plugin :class => BoxGrinder::VMwarePlugin, :type => :platform, :name => :vmware, :full_name => "VMware"
|
@@ -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.
|
8
|
+
Version: 0.10.0
|
9
9
|
Release: 1%{?dist}
|
10
10
|
Group: Development/Languages
|
11
11
|
License: LGPLv3+
|
@@ -42,6 +42,15 @@ BuildRequires: rubygem(net-sftp)
|
|
42
42
|
BuildRequires: rubygem(net-ssh)
|
43
43
|
BuildRequires: rubygem(progressbar)
|
44
44
|
|
45
|
+
# libvirt
|
46
|
+
Requires: ruby-libvirt
|
47
|
+
Requires: rubygem(nokogiri)
|
48
|
+
Requires: rubygem(builder)
|
49
|
+
|
50
|
+
BuildRequires: ruby-libvirt
|
51
|
+
BuildRequires: rubygem(nokogiri)
|
52
|
+
BuildRequires: rubygem(builder)
|
53
|
+
|
45
54
|
# RPM-BASED
|
46
55
|
Requires: appliance-tools
|
47
56
|
Requires: yum-utils
|
@@ -130,6 +139,21 @@ popd
|
|
130
139
|
%{gemdir}/doc/%{gemname}-%{version}
|
131
140
|
|
132
141
|
%changelog
|
142
|
+
* Tue Nov 29 2011 Marek Goldmann <mgoldman@redhat.com> - 0.10.0-1
|
143
|
+
- Upstream release: 0.10.0
|
144
|
+
- [BGBUILD-313] boxgrinder build fails to build ec2 image if ec2-user already exists
|
145
|
+
- [BGBUILD-318] Add support for us-west-2 region
|
146
|
+
- [BGBUILD-308] Clearer error message when unrecognised file extension is used
|
147
|
+
- [BGBUILD-322] Allow selection of kernel and ramdisk for ec2 and ebs plugins
|
148
|
+
- [BGBUILD-302] Add support for VirtualPC platform
|
149
|
+
- [BGBUILD-195] Add support for OpenStack
|
150
|
+
- [BGBUILD-304] Standarize plugin callbacks
|
151
|
+
- [BGBUILD-325] Remove kickstart support
|
152
|
+
- [BGBUILD-323] Invalid kernel version recognition makes recreating initrd impossible
|
153
|
+
- [BGBUILD-326] Ensure building from root directory is successful
|
154
|
+
- [BGBUILD-211] Support for registering appliances with libvirt
|
155
|
+
- [BGBUILD-331] Add support for sa-east-1 EC2 region
|
156
|
+
|
133
157
|
* Fri Oct 14 2011 Marc Savy <msavy@redhat.com> - 0.9.8-1
|
134
158
|
- Upstream release: 0.9.8
|
135
159
|
- [BGBUILD-312] Only use root privileges when necessary
|
data/spec/appliance-spec.rb
CHANGED
@@ -81,7 +81,7 @@ module BoxGrinder
|
|
81
81
|
PluginManager.stub(:instance).and_return(OpenCascade.new(:plugins => {:os => {:centos => {}}}))
|
82
82
|
lambda {
|
83
83
|
@appliance.validate_definition
|
84
|
-
}.should raise_error(RuntimeError, "
|
84
|
+
}.should raise_error(RuntimeError, "Unsupported 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: centos")
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should NOT raise if we use supported OS" do
|
@@ -160,63 +160,6 @@ module BoxGrinder
|
|
160
160
|
|
161
161
|
@appliance.read_definition
|
162
162
|
end
|
163
|
-
|
164
|
-
it "should read definition with kickstart appliance definition file" do
|
165
|
-
prepare_appliance({}, "#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
|
166
|
-
|
167
|
-
appliance_config = ApplianceConfig.new
|
168
|
-
|
169
|
-
appliance_helper = mock(ApplianceDefinitionHelper)
|
170
|
-
appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
|
171
|
-
appliance_helper.should_receive(:appliance_configs).and_return([])
|
172
|
-
|
173
|
-
clazz = mock('PluginClass')
|
174
|
-
|
175
|
-
plugin_manager = mock(PluginManager)
|
176
|
-
plugin_manager.should_receive(:plugins).and_return({:os => {:fedora => {:class => clazz, :type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "14", "rawhide"]}}})
|
177
|
-
|
178
|
-
plugin = mock('Plugin')
|
179
|
-
plugin.should_receive(:respond_to?).with(:read_file).and_return(true)
|
180
|
-
plugin.should_receive(:read_file).and_return(appliance_config)
|
181
|
-
|
182
|
-
clazz.should_receive(:new).and_return(plugin)
|
183
|
-
|
184
|
-
PluginManager.should_receive(:instance).and_return(plugin_manager)
|
185
|
-
|
186
|
-
ApplianceDefinitionHelper.should_receive(:new).with(:log => @log).and_return(appliance_helper)
|
187
|
-
|
188
|
-
appliance_config_helper = mock(ApplianceConfigHelper)
|
189
|
-
|
190
|
-
appliance_config.should_receive(:clone).and_return(appliance_config)
|
191
|
-
appliance_config.should_receive(:init_arch).and_return(appliance_config)
|
192
|
-
appliance_config.should_receive(:initialize_paths).and_return(appliance_config)
|
193
|
-
|
194
|
-
appliance_config_helper.should_receive(:merge).with(appliance_config).and_return(appliance_config)
|
195
|
-
|
196
|
-
ApplianceConfigHelper.should_receive(:new).with([appliance_config]).and_return(appliance_config_helper)
|
197
|
-
|
198
|
-
@appliance.read_definition
|
199
|
-
end
|
200
|
-
|
201
|
-
it "should read definition with kickstart appliance definition file and fail because there was no plugin able to read .ks" do
|
202
|
-
prepare_appliance({}, "#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
|
203
|
-
|
204
|
-
appliance_helper = mock(ApplianceDefinitionHelper)
|
205
|
-
appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
|
206
|
-
appliance_helper.should_receive(:appliance_configs).and_return([])
|
207
|
-
|
208
|
-
plugin_manager = mock(PluginManager)
|
209
|
-
plugin_manager.should_receive(:plugins).and_return({:os => {}})
|
210
|
-
|
211
|
-
|
212
|
-
PluginManager.should_receive(:instance).and_return(plugin_manager)
|
213
|
-
|
214
|
-
ApplianceDefinitionHelper.should_receive(:new).with(:log => @log).and_return(appliance_helper)
|
215
|
-
|
216
|
-
lambda {
|
217
|
-
@appliance.read_definition
|
218
|
-
}.should raise_error(ValidationError, "Couldn't read appliance definition file: jeos-f13.ks.")
|
219
|
-
end
|
220
163
|
end
|
221
164
|
|
222
165
|
it "should remove old builds" do
|
@@ -29,6 +29,12 @@ module BoxGrinder
|
|
29
29
|
@log = @helper.instance_variable_get(:@log)
|
30
30
|
end
|
31
31
|
|
32
|
+
it "should not fail when no versions are found" do
|
33
|
+
guestfs = mock("guestfs")
|
34
|
+
guestfs.should_receive(:ls).with('/lib/modules').and_return([])
|
35
|
+
@helper.kernel_version(guestfs).should == nil
|
36
|
+
end
|
37
|
+
|
32
38
|
it "should return valid kernel version" do
|
33
39
|
guestfs = mock("guestfs")
|
34
40
|
guestfs.should_receive(:ls).with('/lib/modules').and_return(['2.6.33.6-147.fc13.i686'])
|
@@ -41,6 +47,24 @@ module BoxGrinder
|
|
41
47
|
@helper.kernel_version(guestfs).should == '2.6.33.6-147.fc13.i686.PAE'
|
42
48
|
end
|
43
49
|
|
50
|
+
it "should return valid xen kernel version" do
|
51
|
+
guestfs = mock("guestfs")
|
52
|
+
guestfs.should_receive(:ls).with('/lib/modules').and_return(['2.6.33.6-147.fc13.i686.xen', '2.6.40.6-147.fc13.i686'])
|
53
|
+
@helper.kernel_version(guestfs).should == '2.6.33.6-147.fc13.i686.xen'
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should return valid xen kernel version" do
|
57
|
+
guestfs = mock("guestfs")
|
58
|
+
guestfs.should_receive(:ls).with('/lib/modules').and_return(['2.6.45.6-147.fc13.i686', '2.6.40.6-147.fc13.i686'])
|
59
|
+
@helper.kernel_version(guestfs).should == '2.6.45.6-147.fc13.i686'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should fail when no kernel images could be found" do
|
63
|
+
@helper.should_receive(:kernel_version).and_return(nil)
|
64
|
+
|
65
|
+
lambda { @helper.recreate_kernel_image("guestfs", ['xennet']) }.should raise_error("Cannot find valid kernel installs in the appliance. Make sure you have your kernel installed in '/lib/modules'.")
|
66
|
+
end
|
67
|
+
|
44
68
|
it "should recreate initramfs kernel image using dracut and add xennet module" do
|
45
69
|
guestfs = mock("guestfs")
|
46
70
|
|
@@ -91,6 +115,52 @@ module BoxGrinder
|
|
91
115
|
@helper.partition_mount_points(hash).should == ['/', '/tmp-config', '/tmp-eventlog', '/var/www']
|
92
116
|
end
|
93
117
|
end
|
118
|
+
|
119
|
+
context "RPMVersion" do
|
120
|
+
before(:each) do
|
121
|
+
@version = RPMVersion.new
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should split the version" do
|
125
|
+
@version.split('2.6.18-274.7.1.el5').should == ["2", "6", "18", "274", "7", "1", "el5"]
|
126
|
+
end
|
127
|
+
|
128
|
+
describe ".compare" do
|
129
|
+
it "should compare two versions and return -1" do
|
130
|
+
@version.compare("2.6.18-274.7.1.el5", "2.6.18-8.el5").should == 1
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should compare two versions and return 1" do
|
134
|
+
@version.compare("2.6.18-8.el5", "2.6.18-274.7.1.el5").should == -1
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should compare two versions and return 0" do
|
138
|
+
@version.compare("2.6.18-8.el5", "2.6.18-8.el5").should == 0
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should compare two very similar versions" do
|
142
|
+
@version.compare("2.6.18-8.el5", "2.6.18-8.1.el5").should == -1
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should compare two very similar versions other way around" do
|
146
|
+
@version.compare("2.6.18-8.1.el5", "2.6.18-8.el5").should == 1
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe ".newest" do
|
151
|
+
it "should return first one as newer" do
|
152
|
+
@version.newest(["2.6.18-274.7.1.el5", "2.6.18-8.el5"]).should == "2.6.18-274.7.1.el5"
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should return last one as newer" do
|
156
|
+
@version.newest(["2.6.18-8.el5", "2.6.18-274.7.1.el5"]).should == "2.6.18-274.7.1.el5"
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should return version 3 as newer" do
|
160
|
+
@version.newest(["3.1.0-0.rc1", "2.6.18-274.7.1.el5"]).should == "3.1.0-0.rc1"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
94
164
|
end
|
95
165
|
end
|
96
166
|
|
@@ -28,16 +28,16 @@ module BoxGrinder
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should register simple plugin" do
|
31
|
-
@manager.register_plugin(
|
31
|
+
@manager.register_plugin(PluginManager, {:type => :delivery, :name => :abc, :full_name => "Amazon Simple Storage Service (Amazon S3)"})
|
32
32
|
|
33
|
-
@manager.plugins[:delivery].size.should ==
|
33
|
+
@manager.plugins[:delivery].size.should == 10
|
34
34
|
@manager.plugins[:delivery][:abc][:class].should == PluginManager
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should register plugin with many types" do
|
38
|
-
@manager.register_plugin(
|
38
|
+
@manager.register_plugin(PluginManager, {:type => :delivery, :name => :def, :full_name => "Amazon Simple Storage Service (Amazon S3)", :types => [:aaa, :bbb, :ccc]})
|
39
39
|
|
40
|
-
@manager.plugins[:delivery].size.should ==
|
40
|
+
@manager.plugins[:delivery].size.should == 13
|
41
41
|
@manager.plugins[:delivery][:abc][:class].should == PluginManager
|
42
42
|
@manager.plugins[:delivery][:aaa][:class].should == PluginManager
|
43
43
|
@manager.plugins[:delivery][:bbb][:class].should == PluginManager
|
@@ -65,14 +65,5 @@ module BoxGrinder
|
|
65
65
|
@manager.initialize_plugin(:os, :fedora)
|
66
66
|
}.should raise_error("Error while initializing 'Fedora' plugin.")
|
67
67
|
end
|
68
|
-
|
69
|
-
it "should register the plugin with 'plugin' method" do
|
70
|
-
plugin_manager = mock(PluginManager)
|
71
|
-
plugin_manager.should_receive(:register_plugin).with(:class => String, :type => :platform, :name => :ec2, :full_name => "Amazon Elastic Compute Cloud (Amazon EC2)")
|
72
|
-
|
73
|
-
PluginManager.should_receive(:instance).and_return(plugin_manager)
|
74
|
-
|
75
|
-
plugin :class => String, :type => :platform, :name => :ec2, :full_name => "Amazon Elastic Compute Cloud (Amazon EC2)"
|
76
|
-
end
|
77
68
|
end
|
78
69
|
end
|
@@ -31,10 +31,6 @@ module BoxGrinder
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def prepare_plugin
|
34
|
-
@plugin = EBSPlugin.new
|
35
|
-
|
36
|
-
yield @plugin if block_given?
|
37
|
-
|
38
34
|
@config = Config.new('plugins' => { 'ebs' => {
|
39
35
|
'access_key' => 'access_key',
|
40
36
|
'secret_access_key' => 'secret_access_key',
|
@@ -50,14 +46,10 @@ module BoxGrinder
|
|
50
46
|
@appliance_config.stub!(:hardware).and_return(OpenCascade.new({:arch => 'x86_64', :base_arch => 'x86_64'}))
|
51
47
|
@appliance_config.stub!(:path).and_return(OpenCascade.new({:build => '/a/build/path'}))
|
52
48
|
|
53
|
-
@plugin.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
@appliance_config,
|
58
|
-
{:class => BoxGrinder::EBSPlugin, :type => :delivery, :name => :ebs, :full_name => "Elastic Block Storage"},
|
59
|
-
:log => LogHelper.new(:level => :trace, :type => :stdout)
|
60
|
-
)
|
49
|
+
@plugin = RSpecPluginHelper.new(EBSPlugin, :skip => [:validate]).prepare(@config, @appliance_config,
|
50
|
+
:previous_plugin => OpenCascade.new(:type => :os, :deliverables => {:disk => "a_disk.raw", :metadata => 'metadata.xml'}),
|
51
|
+
:plugin_info => {:class => BoxGrinder::EBSPlugin, :type => :delivery, :name => :ebs, :full_name => "Elastic Block Storage"}
|
52
|
+
) { |plugin| yield plugin if block_given? }
|
61
53
|
|
62
54
|
#Set convenient dummies
|
63
55
|
@ec2 = mock(AWS::EC2)
|
@@ -125,7 +117,7 @@ module BoxGrinder
|
|
125
117
|
it "should return true if on EC2" do
|
126
118
|
prepare_plugin do |plugin|
|
127
119
|
plugin.stub!(:after_init)
|
128
|
-
|
120
|
+
plugin.instance_variable_set(:@ec2_endpoints, EC2Helper::endpoints)
|
129
121
|
EC2Helper::stub!(:current_availability_zone).and_return('eu-west-1a')
|
130
122
|
EC2Helper::stub!(:availability_zone_to_region).with('eu-west-1a').and_return('eu-west-1')
|
131
123
|
end
|
@@ -135,7 +127,7 @@ module BoxGrinder
|
|
135
127
|
it "should return false if NOT on EC2" do
|
136
128
|
prepare_plugin do |plugin|
|
137
129
|
plugin.stub!(:after_init)
|
138
|
-
|
130
|
+
plugin.instance_variable_set(:@ec2_endpoints, EC2Helper::endpoints)
|
139
131
|
EC2Helper::stub!(:current_availability_zone).and_raise(Timeout::Error)
|
140
132
|
end
|
141
133
|
@plugin.valid_platform?.should == false
|