boxgrinder-build 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/CHANGELOG +11 -0
  2. data/README.md +32 -34
  3. data/Rakefile +7 -1
  4. data/bin/boxgrinder-build +10 -17
  5. data/boxgrinder-build.gemspec +7 -4
  6. data/lib/boxgrinder-build/appliance.rb +13 -16
  7. data/lib/boxgrinder-build/helpers/guestfs-helper.rb +84 -40
  8. data/lib/boxgrinder-build/helpers/image-helper.rb +54 -85
  9. data/lib/boxgrinder-build/helpers/linux-helper.rb +29 -9
  10. data/lib/boxgrinder-build/helpers/plugin-helper.rb +1 -0
  11. data/lib/boxgrinder-build/plugins/base-plugin.rb +3 -2
  12. data/lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb +13 -42
  13. data/lib/boxgrinder-build/plugins/delivery/elastichosts/elastichosts-plugin.rb +209 -0
  14. data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +8 -4
  15. data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +0 -7
  16. data/lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb +4 -1
  17. data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb +52 -9
  18. data/lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb +6 -2
  19. data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +4 -44
  20. data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit +1 -1
  21. data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit +1 -1
  22. data/lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst +2 -2
  23. data/lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb +24 -13
  24. data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx +2 -2
  25. data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +0 -1
  26. data/rubygem-boxgrinder-build.spec +23 -1
  27. data/spec/appliance-spec.rb +5 -79
  28. data/spec/helpers/augeas-helper-spec.rb +1 -0
  29. data/spec/helpers/guestfs-helper-spec.rb +79 -62
  30. data/spec/helpers/image-helper-spec.rb +88 -129
  31. data/spec/helpers/linux-helper-spec.rb +22 -5
  32. data/spec/helpers/package-helper-spec.rb +1 -0
  33. data/spec/helpers/plugin-helper-spec.rb +1 -0
  34. data/spec/managers/plugin-manager-spec.rb +3 -2
  35. data/spec/plugins/base-plugin-spec.rb +1 -1
  36. data/spec/plugins/delivery/ebs/ebs-plugin-spec.rb +21 -13
  37. data/spec/plugins/delivery/elastichosts/elastichosts-plugin-spec.rb +320 -0
  38. data/spec/plugins/delivery/local/local-plugin-spec.rb +1 -0
  39. data/spec/plugins/delivery/s3/s3-plugin-spec.rb +1 -0
  40. data/spec/plugins/delivery/sftp/sftp-plugin-spec.rb +1 -0
  41. data/spec/plugins/os/centos/centos-plugin-spec.rb +1 -0
  42. data/spec/plugins/os/fedora/fedora-plugin-spec.rb +13 -1
  43. data/spec/plugins/os/rhel/rhel-plugin-spec.rb +1 -15
  44. data/spec/plugins/os/rpm-based/kickstart-spec.rb +1 -0
  45. data/spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb +75 -15
  46. data/spec/plugins/os/rpm-based/rpm-dependency-validator-spec.rb +1 -0
  47. data/spec/plugins/platform/ec2/ec2-plugin-spec.rb +10 -43
  48. data/spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb +89 -10
  49. data/spec/plugins/platform/vmware/vmware-plugin-spec.rb +3 -2
  50. metadata +21 -7
  51. data/lib/boxgrinder-build/helpers/appliance-customize-helper.rb +0 -45
  52. data/spec/helpers/appliance-customize-helper-spec.rb +0 -74
@@ -75,12 +75,12 @@ module BoxGrinder
75
75
 
76
76
  @log.info "Building #{@appliance_config.name} appliance..."
77
77
 
78
- @exec_helper.execute "appliance-creator -d -v -t '#{@dir.tmp}' --cache=#{@config.dir.cache}/rpms-cache/#{@appliance_config.path.main} --config '#{kickstart_file}' -o '#{@dir.tmp}' --name '#{@appliance_config.name}' --vmem #{@appliance_config.hardware.memory} --vcpu #{@appliance_config.hardware.cpus} --format #{@plugin_config['format']}"
78
+ execute_appliance_creator(kickstart_file)
79
79
 
80
80
  FileUtils.mv(Dir.glob("#{@dir.tmp}/#{@appliance_config.name}/*"), @dir.tmp)
81
81
  FileUtils.rm_rf("#{@dir.tmp}/#{@appliance_config.name}/")
82
82
 
83
- @image_helper.customize(@deliverables.disk) do |guestfs, guestfs_helper|
83
+ @image_helper.customize([@deliverables.disk]) do |guestfs, guestfs_helper|
84
84
  # TODO is this really needed?
85
85
  @log.debug "Uploading '/etc/resolv.conf'..."
86
86
  guestfs.upload("/etc/resolv.conf", "/etc/resolv.conf")
@@ -89,7 +89,6 @@ module BoxGrinder
89
89
  change_configuration(guestfs_helper)
90
90
  # TODO check if this is still required
91
91
  apply_root_password(guestfs)
92
- fix_partition_labels(guestfs)
93
92
  use_labels_for_partitions(guestfs)
94
93
  disable_firewall(guestfs)
95
94
  set_motd(guestfs)
@@ -116,6 +115,56 @@ module BoxGrinder
116
115
  @log.info "Base image for #{@appliance_config.name} appliance was built successfully."
117
116
  end
118
117
 
118
+ def execute_appliance_creator(kickstart_file)
119
+ begin
120
+ @exec_helper.execute "appliance-creator -d -v -t '#{@dir.tmp}' --cache=#{@config.dir.cache}/rpms-cache/#{@appliance_config.path.main} --config '#{kickstart_file}' -o '#{@dir.tmp}' --name '#{@appliance_config.name}' --vmem #{@appliance_config.hardware.memory} --vcpu #{@appliance_config.hardware.cpus} --format #{@plugin_config['format']}"
121
+ rescue InterruptionError => e
122
+ cleanup_after_appliance_creator(e.pid)
123
+ abort
124
+ end
125
+ end
126
+
127
+ def cleanup_after_appliance_creator(pid)
128
+ @log.debug "Sending TERM signal to process '#{pid}'..."
129
+ Process.kill("TERM", pid)
130
+
131
+ @log.debug "Waiting for process to be terminated..."
132
+ Process.wait(pid)
133
+
134
+ @log.debug "Cleaning appliance-creator mount points..."
135
+
136
+ Dir["#{@dir.tmp}/imgcreate-*"].each do |dir|
137
+ dev_mapper = @exec_helper.execute "mount | grep #{dir} | awk '{print $1}'"
138
+
139
+ mappings = {}
140
+
141
+ dev_mapper.each do |mapping|
142
+ if mapping =~ /(loop\d+)p(\d+)/
143
+ mappings[$1] = [] if mappings[$1].nil?
144
+ mappings[$1] << $2 unless mappings[$1].include?($2)
145
+ end
146
+ end
147
+
148
+ (['/var/cache/yum', '/dev/shm', '/dev/pts', '/proc', '/sys'] + @appliance_config.hardware.partitions.keys.reverse).each do |mount_point|
149
+ @log.trace "Unmounting '#{mount_point}'..."
150
+ @exec_helper.execute "umount -d #{dir}/install_root#{mount_point}"
151
+ end
152
+
153
+ mappings.each do |loop, partitions|
154
+ @log.trace "Removing mappings from loop device #{loop}..."
155
+ @exec_helper.execute "/sbin/kpartx -d /dev/#{loop}"
156
+ @exec_helper.execute "losetup -d /dev/#{loop}"
157
+
158
+ partitions.each do |part|
159
+ @log.trace "Removing mapping for partition #{part} from loop device #{loop}..."
160
+ @exec_helper.execute "rm /dev/#{loop}#{part}"
161
+ end
162
+ end
163
+ end
164
+
165
+ @log.debug "Cleaned up after appliance-creator."
166
+ end
167
+
119
168
  # https://issues.jboss.org/browse/BGBUILD-177
120
169
  def disable_firewall(guestfs)
121
170
  @log.debug "Disabling firewall..."
@@ -123,12 +172,6 @@ module BoxGrinder
123
172
  @log.debug "Firewall disabled."
124
173
  end
125
174
 
126
- def fix_partition_labels(guestfs)
127
- guestfs.list_partitions.each do |partition|
128
- guestfs.sh("/sbin/e2label #{partition} #{read_label(guestfs, partition)}")
129
- end
130
- end
131
-
132
175
  def use_labels_for_partitions(guestfs)
133
176
  device = guestfs.list_devices.first
134
177
 
@@ -17,8 +17,12 @@ services --enabled=network
17
17
 
18
18
  rootpw --iscrypted <%= appliance_config.os.password.crypt((0...8).map { 65.+(rand(25)).chr }.join) %>
19
19
 
20
- <% appliance_config.hardware.partitions.each do |root, partition| %>
21
- part <%= root %> --size <%= (partition['size'].to_f * 1024).to_i %> --fstype <%= partition['type'] %> <% unless partition['options'].nil? %> --fsoptions '<%= partition['options'] %>' <% end %> <% if partition['passphrase'] %> --encrypted --passphrase='<%= partition['passphrase'] %>' <% end %> --ondisk sda --label <%= root %><% end %>
20
+ # appliance-creator doesn't support labels...
21
+ # --label Zlib.crc32(root).to_s(16)
22
+
23
+ <% mount_points.each do |root| %>
24
+ <% partition = appliance_config.hardware.partitions[root]%>
25
+ part <%= root %> --size <%= (partition['size'].to_f * 1024).to_i %> --fstype <%= partition['type'] %> <% unless partition['options'].nil? %> --fsoptions '<%= partition['options'] %>' <% end %> <% if partition['passphrase'] %> --encrypted --passphrase='<%= partition['passphrase'] %>' <% end %> --ondisk sda<% end %>
22
26
 
23
27
  <% for repo in repos %>
24
28
  <%= repo %><% end %>
@@ -35,10 +35,11 @@ module BoxGrinder
35
35
 
36
36
  @log.info "Converting #{@appliance_config.name} appliance image to EC2 format..."
37
37
 
38
- create_ec2_disk
39
- sync_files
38
+ @image_helper.create_disk(@deliverables.disk, 10) # 10 GB destination disk
39
+
40
+ @image_helper.customize([@previous_deliverables.disk, @deliverables.disk], :automount => false) do |guestfs, guestfs_helper|
41
+ @image_helper.sync_filesystem(guestfs, guestfs_helper)
40
42
 
41
- @image_helper.customize(@deliverables.disk) do |guestfs, guestfs_helper|
42
43
  if (@appliance_config.os.name == 'rhel' or @appliance_config.os.name == 'centos') and @appliance_config.os.version == '5'
43
44
  # Not sure why it's messed but this prevents booting on AWS
44
45
  recreate_journal(guestfs)
@@ -75,47 +76,6 @@ module BoxGrinder
75
76
  @log.info "Image converted to EC2 format."
76
77
  end
77
78
 
78
- def sync_files
79
- ec2_disk_mount_dir = "#{@dir.tmp}/ec2-#{rand(9999999999).to_s.center(10, rand(9).to_s)}"
80
- raw_disk_mount_dir = "#{@dir.tmp}/raw-#{rand(9999999999).to_s.center(10, rand(9).to_s)}"
81
-
82
- tmp_disk = "#{@dir.tmp}/#{@appliance_config.name}.raw"
83
-
84
- @log.debug "Conveting disk to RAW format..."
85
- @image_helper.convert_disk(@previous_deliverables.disk, 'raw', tmp_disk)
86
-
87
- begin
88
- ec2_mounts = @image_helper.mount_image(@deliverables.disk, ec2_disk_mount_dir)
89
- raw_mounts = @image_helper.mount_image(tmp_disk, raw_disk_mount_dir)
90
- rescue => e
91
- @log.error e
92
- @log.error "Mouting failed, trying to clean up."
93
-
94
- @image_helper.umount_image(tmp_disk, raw_disk_mount_dir, raw_mounts) unless raw_mounts.nil?
95
- @image_helper.umount_image(@deliverables.disk, ec2_disk_mount_dir, ec2_mounts) unless ec2_mounts.nil?
96
-
97
- raise "Error while mounting image. See logs for more info."
98
- end
99
-
100
- @image_helper.sync_files(raw_disk_mount_dir, ec2_disk_mount_dir)
101
-
102
- @image_helper.umount_image(tmp_disk, raw_disk_mount_dir, raw_mounts)
103
- @image_helper.umount_image(@deliverables.disk, ec2_disk_mount_dir, ec2_mounts)
104
-
105
- FileUtils.rm_rf tmp_disk
106
- end
107
-
108
- def create_ec2_disk
109
- begin
110
- # TODO using whole 10GB is fine?
111
- @image_helper.create_disk(@deliverables.disk, 10)
112
- @image_helper.create_filesystem(@deliverables.disk)
113
- rescue => e
114
- @log.error e
115
- raise "Error while preparing EC2 disk image. See logs for more info."
116
- end
117
- end
118
-
119
79
  def execute_post(guestfs_helper)
120
80
  unless @appliance_config.post['ec2'].nil?
121
81
  @appliance_config.post['ec2'].each do |cmd|
@@ -1,4 +1,4 @@
1
- LABEL=/ / #FILESYSTEM_TYPE# defaults 1 1
1
+ LABEL=79d3d2d4 / #FILESYSTEM_TYPE# defaults 1 1
2
2
  /dev/#DISK_DEVICE_PREFIX#da2 /mnt ext3 defaults 1 2
3
3
  /dev/#DISK_DEVICE_PREFIX#da3 swap swap defaults 0 0
4
4
  none /dev/pts devpts gid=5,mode=620 0 0
@@ -1,4 +1,4 @@
1
- LABEL=/ / #FILESYSTEM_TYPE# defaults 1 1
1
+ LABEL=79d3d2d4 / #FILESYSTEM_TYPE# defaults 1 1
2
2
  /dev/#DISK_DEVICE_PREFIX#db /mnt ext3 defaults 0 0
3
3
  /dev/#DISK_DEVICE_PREFIX#dc /data ext3 defaults 0 0
4
4
  none /dev/pts devpts gid=5,mode=620 0 0
@@ -2,5 +2,5 @@ default=0
2
2
  timeout=0
3
3
  title #TITLE#
4
4
  root (hd0)
5
- kernel /boot/vmlinuz-#KERNEL_VERSION# ro root=LABEL=/ rd_NO_PLYMOUTH
6
- initrd /boot/#KERNEL_IMAGE_NAME#-#KERNEL_VERSION#.img
5
+ kernel /boot/vmlinuz-#KERNEL_VERSION# ro root=LABEL=79d3d2d4 rd_NO_PLYMOUTH
6
+ initrd /boot/#KERNEL_IMAGE_NAME#-#KERNEL_VERSION#.img
@@ -17,7 +17,7 @@
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
19
  require 'boxgrinder-build/plugins/base-plugin'
20
- require 'boxgrinder-build/helpers/appliance-customize-helper'
20
+ require 'boxgrinder-build/helpers/linux-helper'
21
21
 
22
22
  module BoxGrinder
23
23
  class VirtualBoxPlugin < BasePlugin
@@ -29,11 +29,21 @@ module BoxGrinder
29
29
  @log.info "Converting image to VirtualBox format..."
30
30
 
31
31
  build_virtualbox
32
- customize
32
+
33
+ if is_os_old? or !@appliance_config.post['virtualbox'].nil?
34
+ @image_helper.customize([@deliverables.disk]) do |guestfs, guestfs_helper|
35
+ recreate_kernel(guestfs) if is_os_old?
36
+ customize(guestfs_helper) unless @appliance_config.post['virtualbox'].nil?
37
+ end
38
+ end
33
39
 
34
40
  @log.info "Image converted to VirtualBox format."
35
41
  end
36
42
 
43
+ def is_os_old?
44
+ (@appliance_config.os.name == 'centos' or @appliance_config.os.name == 'rhel') and @appliance_config.os.version == '5'
45
+ end
46
+
37
47
  def build_virtualbox
38
48
  @log.debug "Building VirtualBox image."
39
49
 
@@ -44,19 +54,20 @@ module BoxGrinder
44
54
  @log.debug "VirtualBox image was built."
45
55
  end
46
56
 
47
- def customize
48
- unless @appliance_config.post['virtualbox'].nil?
49
- @image_helper.customize(@deliverables.disk) do |guestfs, guestfs_helper|
50
- @appliance_config.post['virtualbox'].each do |cmd|
51
- guestfs_helper.sh(cmd, :arch => @appliance_config.hardware.arch)
52
- end
53
- @log.debug "Post commands from appliance definition file executed."
54
- end
55
- else
56
- @log.debug "No commands specified, skipping."
57
+ def recreate_kernel(guestfs)
58
+ @log.info "Recreating kernel to include require modules..."
59
+ LinuxHelper.new(:log => @log).recreate_kernel_image(guestfs, ['ahci'])
60
+ @log.info "Kernel recreated."
61
+ end
62
+
63
+ def customize(guestfs_helper)
64
+ @log.debug "Executing post commands from appliance definition..."
65
+ @appliance_config.post['virtualbox'].each do |cmd|
66
+ guestfs_helper.sh(cmd, :arch => @appliance_config.hardware.arch)
57
67
  end
68
+ @log.debug "Post commands from appliance definition file executed."
58
69
  end
59
70
  end
60
71
  end
61
72
 
62
- plugin :class => BoxGrinder::VirtualBoxPlugin, :type => :platform, :name => :virtualbox, :full_name => "VirtualBox"
73
+ plugin :class => BoxGrinder::VirtualBoxPlugin, :type => :platform, :name => :virtualbox, :full_name => "VirtualBox"
@@ -5,9 +5,9 @@ config.version = "8"
5
5
  virtualHW.version = "4"
6
6
  guestOS = "#GUESTOS#"
7
7
  displayName = "#NAME#"
8
- annotation = "#SUMMARY# | Version: #VERSION# | Built using BoxGrinder"
8
+ annotation = "#NAME# | Version: #VERSION# | Built using BoxGrinder"
9
9
  guestinfo.vmware.product.long = "#NAME#"
10
- guestinfo.vmware.product.url = "http://www.jboss.org/boxgrinder"
10
+ guestinfo.vmware.product.url = "http://boxgrinder.org"
11
11
  guestinfo.vmware.product.class = "virtual machine"
12
12
  numvcpus = "#VCPU#"
13
13
  memsize = "#MEM_SIZE#"
@@ -17,7 +17,6 @@
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
19
  require 'boxgrinder-build/plugins/base-plugin'
20
- require 'boxgrinder-build/helpers/appliance-customize-helper'
21
20
 
22
21
  module BoxGrinder
23
22
  class VMwarePlugin < BasePlugin
@@ -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.0
8
+ Version: 0.9.1
9
9
  Release: 1%{?dist}
10
10
  Group: Development/Languages
11
11
  License: LGPLv3+
@@ -19,6 +19,9 @@ Requires: ruby-libguestfs
19
19
  Requires: parted
20
20
  Requires: e2fsprogs
21
21
 
22
+ # Fix for rubygem-aws package
23
+ Requires: rubygem(activesupport)
24
+
22
25
  # For EL5
23
26
  BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
24
27
  BuildArch: noarch
@@ -30,6 +33,9 @@ BuildRequires: rubygem(boxgrinder-core) < 0.4.0
30
33
  BuildRequires: rubygem(echoe)
31
34
  BuildRequires: ruby-libguestfs
32
35
 
36
+ # Fix for rubygem-aws package
37
+ BuildRequires: rubygem(activesupport)
38
+
33
39
  # EBS and S3
34
40
  Requires: rubygem(amazon-ec2)
35
41
  # Fixes blankslate error
@@ -60,6 +66,11 @@ Requires: rsync
60
66
  Requires: wget
61
67
  Requires: util-linux
62
68
 
69
+ # ElasticHosts
70
+ Requires: rubygem(rest-client)
71
+
72
+ BuildRequires: rubygem(rest-client)
73
+
63
74
  Provides: rubygem(%{gemname}) = %{version}
64
75
 
65
76
  Obsoletes: rubygem(boxgrinder-build-ebs-delivery-plugin) < 0.0.4-2
@@ -137,6 +148,17 @@ popd
137
148
  %{gemdir}/doc/%{gemname}-%{version}
138
149
 
139
150
  %changelog
151
+ * Thu Mar 17 2011 <mgoldman@redhat.com> - 0.9.1-1
152
+ - Upstream release: 0.9.1
153
+ - [BGBUILD-188] Use libuestfs instead mounting partitions manually for EC2 appliances
154
+ - [BGBUILD-97] some filesystems dont get unmounted on BG interruption
155
+ - [BGBUILD-155] Images built on Centos5.x (el5) for VirtualBox kernel panic (/dev/root missing)
156
+ - [BGBUILD-190] Allow to specify kernel variant (PAE or not) for Fedora OS
157
+ - [BGBUILD-196] GuestFS fails mounting partitions where more then 3 partitions are present
158
+ - [BGBUILD-200] /sbin/e2label: Filesystem has unsupported feature(s) while trying to open /dev/sda1
159
+ - [BGBUILD-194] Add support for ElasticHosts cloud
160
+ - [BGBUILD-202] Unable to get valid context for ec2-user after login on AMI
161
+
140
162
  * Tue Mar 01 2011 <msavy@redhat.com> - 0.9.0-1
141
163
  - Upstream release: 0.9.0
142
164
  - [BGBUILD-103] README to indicate supported operating systems / requirements
@@ -145,7 +145,8 @@ module BoxGrinder
145
145
  appliance_config = ApplianceConfig.new
146
146
 
147
147
  appliance_helper = mock(ApplianceDefinitionHelper)
148
- appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks").and_raise("Unknown format")
148
+ appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
149
+ appliance_helper.should_receive(:appliance_configs).and_return([])
149
150
 
150
151
  clazz = mock('PluginClass')
151
152
 
@@ -179,7 +180,8 @@ module BoxGrinder
179
180
  prepare_appliance({}, "#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
180
181
 
181
182
  appliance_helper = mock(ApplianceDefinitionHelper)
182
- appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks").and_raise("Unknown format")
183
+ appliance_helper.should_receive(:read_definitions).with("#{File.dirname(__FILE__)}/rspec/src/appliances/jeos-f13.ks")
184
+ appliance_helper.should_receive(:appliance_configs).and_return([])
183
185
 
184
186
  plugin_manager = mock(PluginManager)
185
187
  plugin_manager.should_receive(:plugins).and_return({:os => {}})
@@ -191,83 +193,7 @@ module BoxGrinder
191
193
 
192
194
  lambda {
193
195
  @appliance.read_definition
194
- }.should raise_error("Couldn't read appliance definition file: jeos-f13.ks")
195
- end
196
- end
197
-
198
- describe ".validate_definition" do
199
- it "should validate definition and pass" do
200
- prepare_appliance
201
- @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
202
-
203
- appliance_config_validator = mock(ApplianceConfigValidator)
204
- appliance_config_validator.should_receive(:validate)
205
-
206
- ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
207
-
208
- plugin_manager = mock(PluginManager)
209
- plugin_manager.stub!(:plugins).and_return({:os => {:fedora => {:type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "14", "rawhide"]}}})
210
-
211
- PluginManager.stub!(:instance).and_return(plugin_manager)
212
-
213
- @appliance.validate_definition
214
- end
215
-
216
- it "should validate definition and fail because no operating system plugins are installed" do
217
- prepare_appliance
218
- @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
219
-
220
- appliance_config_validator = mock(ApplianceConfigValidator)
221
- appliance_config_validator.should_receive(:validate)
222
-
223
- ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
224
-
225
- plugin_manager = mock(PluginManager)
226
- plugin_manager.stub!(:plugins).and_return({:os => {}})
227
-
228
- PluginManager.stub!(:instance).and_return(plugin_manager)
229
-
230
- lambda {
231
- @appliance.validate_definition
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
- end
234
-
235
- it "should validate definition and fail because no supported operating system plugins is installed" do
236
- prepare_appliance
237
- @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
238
-
239
- appliance_config_validator = mock(ApplianceConfigValidator)
240
- appliance_config_validator.should_receive(:validate)
241
-
242
- ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
243
-
244
- plugin_manager = mock(PluginManager)
245
- plugin_manager.stub!(:plugins).and_return({:os => {:rhel => {}}})
246
-
247
- PluginManager.stub!(:instance).and_return(plugin_manager)
248
-
249
- lambda {
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://boxgrinder.org/tutorials/boxgrinder-build-plugins/#Operating_system_plugins. Supported OSes are: rhel")
252
- end
253
-
254
- it "should validate definition and fail because no supported operating system version plugins is installed" do
255
- prepare_appliance
256
- @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
257
-
258
- appliance_config_validator = mock(ApplianceConfigValidator)
259
- appliance_config_validator.should_receive(:validate)
260
-
261
- ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
262
-
263
- plugin_manager = mock(PluginManager)
264
- plugin_manager.stub!(:plugins).and_return({:os => {:fedora => {:type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["xyz"]}}})
265
-
266
- PluginManager.stub!(:instance).and_return(plugin_manager)
267
-
268
- lambda {
269
- @appliance.validate_definition
270
- }.should raise_error(RuntimeError, "Not supported operating system version selected: 11. Supported versions are: xyz")
196
+ }.should raise_error(ValidationError, "Couldn't read appliance definition file: jeos-f13.ks.")
271
197
  end
272
198
  end
273
199
 
@@ -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/helpers/augeas-helper'
20
21
 
21
22
  module BoxGrinder