boxgrinder-build 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v0.6.5
2
+
3
+ * Release bump required for plugins
4
+
1
5
  v0.6.4
2
6
 
3
7
  * [BGBUILD-98] Use hashery gem
data/Rakefile CHANGED
@@ -19,7 +19,6 @@
19
19
  require 'rubygems'
20
20
  require 'spec/rake/spectask'
21
21
  require 'echoe'
22
- require 'rbconfig'
23
22
 
24
23
  Echoe.new("boxgrinder-build") do |p|
25
24
  p.project = "BoxGrinder Build"
@@ -27,7 +26,7 @@ Echoe.new("boxgrinder-build") do |p|
27
26
  p.summary = "A tool for creating appliances from simple plain text files for various virtual environments."
28
27
  p.url = "http://www.jboss.org/boxgrinder"
29
28
  p.email = "info@boxgrinder.org"
30
- p.runtime_dependencies = ["commander ~>4.0.3", "boxgrinder-core ~>0.1.3"]
29
+ p.runtime_dependencies = ["commander ~>4.0.3", "boxgrinder-core ~>0.1.4"]
31
30
  end
32
31
 
33
32
  desc "Run all tests"
@@ -48,24 +47,3 @@ Spec::Rake::SpecTask.new('spec:coverage') do |t|
48
47
  t.rcov_opts = ['--exclude', 'spec,teamcity/*,/usr/lib/ruby/,.gem/ruby,/boxgrinder-core/,/gems/']
49
48
  t.verbose = true
50
49
  end
51
-
52
- desc "Create RPM"
53
- task :rpm, :target, :version, :arch, :needs => ['clean', 'gem'] do |t, args|
54
- target = args[:target] || 'fedora'
55
- version = args[:version] || 'rawhide'
56
- arch = args[:arch] || RbConfig::CONFIG['host_cpu']
57
-
58
- Dir["**/rubygem-*.spec"].each do |spec|
59
- `mock -v -r #{target}-#{version}-#{arch} --buildsrpm --sources pkg/*.gem --spec #{spec} --resultdir pkg/`
60
- exit 1 unless $? == 0
61
- `mock -v -r #{target}-#{version}-#{arch} --rebuild pkg/*.rpm --resultdir pkg/`
62
- exit 1 unless $? == 0
63
- end
64
- end
65
-
66
- desc "Install RPM"
67
- task 'rpm:install' => [:rpm] do
68
- system "sudo yum -y remove rubygem-boxgrinder-build"
69
- system "sudo yum -y localinstall --nogpgcheck pkg/*.rpm"
70
- exit 1 unless $? == 0
71
- end
data/bin/boxgrinder-build CHANGED
@@ -46,7 +46,7 @@ module Commander
46
46
  end
47
47
 
48
48
  program :name, 'BoxGrinder Build'
49
- program :version, '0.6.4'
49
+ program :version, '0.6.5'
50
50
  program :description, "A tool for building VM images from simple definition files."
51
51
  program :help, 'Homepage', 'http://www.jboss.org/boxgrinder/build.html'
52
52
  program :help, 'Documentation', 'http://community.jboss.org/docs/DOC-14358'
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{boxgrinder-build}
5
- s.version = "0.6.4"
5
+ s.version = "0.6.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Marek Goldmann"]
9
- s.date = %q{2010-11-23}
9
+ s.date = %q{2010-12-03}
10
10
  s.default_executable = %q{boxgrinder-build}
11
11
  s.description = %q{A tool for creating appliances from simple plain text files for various virtual environments.}
12
12
  s.email = %q{info@boxgrinder.org}
@@ -26,13 +26,13 @@ Gem::Specification.new do |s|
26
26
 
27
27
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
28
  s.add_runtime_dependency(%q<commander>, ["~> 4.0.3"])
29
- s.add_runtime_dependency(%q<boxgrinder-core>, ["~> 0.1.3"])
29
+ s.add_runtime_dependency(%q<boxgrinder-core>, ["~> 0.1.4"])
30
30
  else
31
31
  s.add_dependency(%q<commander>, ["~> 4.0.3"])
32
- s.add_dependency(%q<boxgrinder-core>, ["~> 0.1.3"])
32
+ s.add_dependency(%q<boxgrinder-core>, ["~> 0.1.4"])
33
33
  end
34
34
  else
35
35
  s.add_dependency(%q<commander>, ["~> 4.0.3"])
36
- s.add_dependency(%q<boxgrinder-core>, ["~> 0.1.3"])
36
+ s.add_dependency(%q<boxgrinder-core>, ["~> 0.1.4"])
37
37
  end
38
38
  end
@@ -16,6 +16,7 @@
16
16
  # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
17
  # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
18
18
 
19
+ require 'rubygems'
19
20
  require 'boxgrinder-core/models/appliance-config'
20
21
  require 'boxgrinder-core/models/config'
21
22
  require 'boxgrinder-core/helpers/appliance-helper'
@@ -28,23 +29,32 @@ module BoxGrinder
28
29
  class Appliance
29
30
 
30
31
  def initialize(appliance_definition_file, options = {})
31
- @config = Config.new
32
- @appliance_definition_file = appliance_definition_file
33
- @log = options[:log] || Logger.new(STDOUT)
34
- @options = options[:options]
32
+ @config = Config.new
33
+ @appliance_definition_file = appliance_definition_file
34
+ @log = options[:log] || Logger.new(STDOUT)
35
+ @options = options[:options]
35
36
 
36
- @config.name = @options.name
37
+ @config.name = @options.name
37
38
  @config.version.version = @options.version
38
39
  @config.version.release = nil
39
40
  end
40
41
 
41
- def read_and_validate_definition
42
+ def read_definition
42
43
  appliance_configs, appliance_config = ApplianceHelper.new(:log => @log).read_definitions(@appliance_definition_file)
43
- appliance_config_helper = ApplianceConfigHelper.new(appliance_configs)
44
+ appliance_config_helper = ApplianceConfigHelper.new(appliance_configs)
44
45
 
45
46
  @appliance_config = appliance_config_helper.merge(appliance_config.clone.init_arch).initialize_paths
47
+ end
46
48
 
49
+ def validate_definition
47
50
  ApplianceConfigValidator.new(@appliance_config).validate
51
+
52
+ raise "No operating system plugins installed. Install one or more operating system plugin. See http://community.jboss.org/docs/DOC-15081 and http://community.jboss.org/docs/DOC-15214 for more info" if PluginManager.instance.plugins[:os].empty?
53
+
54
+ os_plugin = PluginManager.instance.plugins[:os][@appliance_config.os.name.to_sym]
55
+
56
+ raise ApplianceValidationError, "Not supported operating system selected: #{@appliance_config.os.name}. Make sure you have installed right operating system plugin, see http://community.jboss.org/docs/DOC-15214. Supported OSes are: #{PluginManager.instance.plugins[:os].keys.join(", ")}" if os_plugin.nil?
57
+ raise ApplianceValidationError, "Not supported operating system version selected: #{@appliance_config.os.version}. Supported versions are: #{os_plugin[:versions].join(", ")}" unless @appliance_config.os.version.nil? or os_plugin[:versions].include?(@appliance_config.os.version)
48
58
  end
49
59
 
50
60
  def remove_old_builds
@@ -56,8 +66,8 @@ module BoxGrinder
56
66
  def execute_plugin_chain
57
67
  @log.info "Building '#{@appliance_config.name}' appliance for #{@appliance_config.hardware.arch} architecture."
58
68
 
59
- base_plugin_output = execute_os_plugin
60
- platform_plugin_output = execute_platform_plugin(base_plugin_output)
69
+ base_plugin_output = execute_os_plugin
70
+ platform_plugin_output = execute_platform_plugin(base_plugin_output)
61
71
 
62
72
  execute_delivery_plugin(platform_plugin_output)
63
73
  end
@@ -65,7 +75,8 @@ module BoxGrinder
65
75
  def create
66
76
  begin
67
77
  PluginHelper.new(:options => @options, :log => @log).load_plugins
68
- read_and_validate_definition
78
+ read_definition
79
+ validate_definition
69
80
  remove_old_builds if @options.force
70
81
  execute_plugin_chain
71
82
  rescue
@@ -16,9 +16,9 @@
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 'boxgrinder-core/validators/errors'
19
+ require 'rubygems'
20
20
  require 'boxgrinder-build/helpers/guestfs-helper'
21
- require 'tempfile'
21
+ require 'boxgrinder-core/helpers/exec-helper'
22
22
  require 'logger'
23
23
 
24
24
  module BoxGrinder
@@ -5,8 +5,8 @@
5
5
 
6
6
  Summary: A tool for creating appliances from simple plain text files
7
7
  Name: rubygem-%{gemname}
8
- Version: 0.6.4
9
- Release: 3%{?dist}
8
+ Version: 0.6.5
9
+ Release: 1%{?dist}
10
10
  Group: Development/Languages
11
11
  License: LGPLv3+
12
12
  URL: http://www.jboss.org/boxgrinder
@@ -85,6 +85,9 @@ popd
85
85
  %{gemdir}/doc/%{gemname}-%{version}
86
86
 
87
87
  %changelog
88
+ * Thu Dec 02 2010 <mgoldman@redhat.com> - 0.6.5-1
89
+ - Updated to new upstream release: 0.6.5
90
+
88
91
  * Mon Nov 22 2010 <mgoldman@redhat.com> - 0.6.4-3
89
92
  - Changelog rewritten
90
93
  - Added Require: parted and e2fsprogs
@@ -18,15 +18,14 @@
18
18
 
19
19
  require 'rubygems'
20
20
  require 'boxgrinder-build/appliance'
21
- #require 'rspec/rspec-config-helper'
22
21
  require 'ostruct'
23
22
  require 'logger'
24
23
 
25
24
  module BoxGrinder
26
25
  describe Appliance do
27
26
  def prepare_appliance(options = OpenStruct.new)
28
- options.name = 'boxgrinder'
29
- options.version = '1.0'
27
+ options.name = 'boxgrinder'
28
+ options.version = '1.0'
30
29
 
31
30
  @options = options
32
31
  @log = Logger.new('/dev/null')
@@ -50,16 +49,16 @@ module BoxGrinder
50
49
 
51
50
  @appliance_config.stub!(:hardware).and_return(
52
51
  OpenCascade.new({
53
- :partitions =>
54
- {
55
- '/' => {'size' => 2},
56
- '/home' => {'size' => 3},
57
- },
58
- :arch => 'i686',
59
- :base_arch => 'i386',
60
- :cpus => 1,
61
- :memory => 256,
62
- })
52
+ :partitions =>
53
+ {
54
+ '/' => {'size' => 2},
55
+ '/home' => {'size' => 3},
56
+ },
57
+ :arch => 'i686',
58
+ :base_arch => 'i386',
59
+ :cpus => 1,
60
+ :memory => 256,
61
+ })
63
62
  )
64
63
 
65
64
  @appliance_config
@@ -77,7 +76,8 @@ module BoxGrinder
77
76
 
78
77
  PluginHelper.should_receive(:new).with(:options => @options, :log => @log).and_return(plugin_helper)
79
78
 
80
- @appliance.should_receive(:read_and_validate_definition)
79
+ @appliance.should_receive(:read_definition)
80
+ @appliance.should_receive(:validate_definition)
81
81
  @appliance.should_not_receive(:remove_old_builds)
82
82
  @appliance.should_receive(:execute_plugin_chain)
83
83
 
@@ -92,14 +92,15 @@ module BoxGrinder
92
92
 
93
93
  PluginHelper.should_receive(:new).with(:options => @options, :log => @log).and_return(plugin_helper)
94
94
 
95
- @appliance.should_receive(:read_and_validate_definition)
95
+ @appliance.should_receive(:read_definition)
96
+ @appliance.should_receive(:validate_definition)
96
97
  @appliance.should_receive(:remove_old_builds)
97
98
  @appliance.should_receive(:execute_plugin_chain)
98
99
 
99
100
  @appliance.create
100
101
  end
101
102
 
102
- it "should read and validate definition" do
103
+ it "should read definition" do
103
104
  prepare_appliance
104
105
 
105
106
  appliance_config = ApplianceConfig.new
@@ -119,12 +120,98 @@ module BoxGrinder
119
120
 
120
121
  ApplianceConfigHelper.should_receive(:new).with({}).and_return(appliance_config_helper)
121
122
 
122
- appliance_config_validator = mock(ApplianceConfigValidator)
123
- appliance_config_validator.should_receive(:validate)
123
+ @appliance.read_definition
124
+ end
125
+
126
+ describe ".validate_definition" do
127
+ it "should validate definition and pass" do
128
+ prepare_appliance
129
+ @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
130
+
131
+ appliance_config_validator = mock(ApplianceConfigValidator)
132
+ appliance_config_validator.should_receive(:validate)
133
+
134
+ ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
135
+
136
+ puts @appliance_config
137
+
138
+ plugin_manager = mock(PluginManager)
139
+ plugin_manager.stub!(:plugins).and_return({:os => {:fedora => {:type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "14", "rawhide"]}}})
140
+
141
+ PluginManager.stub!(:instance).and_return(plugin_manager)
142
+
143
+ @appliance.validate_definition
144
+ end
145
+
146
+ it "should validate definition and fail because no operating system plugins are installed" do
147
+ prepare_appliance
148
+ @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
149
+
150
+ appliance_config_validator = mock(ApplianceConfigValidator)
151
+ appliance_config_validator.should_receive(:validate)
152
+
153
+ ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
154
+
155
+ plugin_manager = mock(PluginManager)
156
+ plugin_manager.stub!(:plugins).and_return({:os => {}})
157
+
158
+ PluginManager.stub!(:instance).and_return(plugin_manager)
159
+
160
+ begin
161
+ @appliance.validate_definition
162
+ raise "Shouldn't raise"
163
+ rescue => e
164
+ e.message.should == "No operating system plugins installed. Install one or more operating system plugin. See http://community.jboss.org/docs/DOC-15081 and http://community.jboss.org/docs/DOC-15214 for more info"
165
+ end
166
+ end
167
+
168
+ it "should validate definition and fail because no supported operating system plugins is installed" do
169
+ prepare_appliance
170
+ @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
171
+
172
+ appliance_config_validator = mock(ApplianceConfigValidator)
173
+ appliance_config_validator.should_receive(:validate)
174
+
175
+ ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
176
+
177
+ puts @appliance_config
178
+
179
+ plugin_manager = mock(PluginManager)
180
+ plugin_manager.stub!(:plugins).and_return({:os => {:rhel => {}}})
181
+
182
+ PluginManager.stub!(:instance).and_return(plugin_manager)
183
+
184
+ begin
185
+ @appliance.validate_definition
186
+ raise "Shouldn't raise"
187
+ rescue => e
188
+ e.message.should == "Not supported operating system selected: fedora. Make sure you have installed right operating system plugin, see http://community.jboss.org/docs/DOC-15214. Supported OSes are: rhel"
189
+ end
190
+ end
191
+
192
+ it "should validate definition and fail because no supported operating system version plugins is installed" do
193
+ prepare_appliance
194
+ @appliance.instance_variable_set(:@appliance_config, prepare_appliance_config)
195
+
196
+ appliance_config_validator = mock(ApplianceConfigValidator)
197
+ appliance_config_validator.should_receive(:validate)
198
+
199
+ ApplianceConfigValidator.should_receive(:new).with(@appliance_config).and_return(appliance_config_validator)
200
+
201
+ puts @appliance_config
202
+
203
+ plugin_manager = mock(PluginManager)
204
+ plugin_manager.stub!(:plugins).and_return({:os => {:fedora => {:type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["xyz"]}}})
124
205
 
125
- ApplianceConfigValidator.should_receive(:new).with(appliance_config).and_return(appliance_config_validator)
206
+ PluginManager.stub!(:instance).and_return(plugin_manager)
126
207
 
127
- @appliance.read_and_validate_definition
208
+ begin
209
+ @appliance.validate_definition
210
+ raise "Shouldn't raise"
211
+ rescue => e
212
+ e.message.should == "Not supported operating system version selected: 11. Supported versions are: xyz"
213
+ end
214
+ end
128
215
  end
129
216
 
130
217
  it "should remove old builds" do
@@ -147,7 +234,7 @@ module BoxGrinder
147
234
  os_plugin.should_receive(:deliverables).and_return({:disk => 'abc'})
148
235
 
149
236
  @plugin_manager.should_receive(:plugins).and_return({:os => "something"})
150
- @plugin_manager.should_receive(:initialize_plugin).once.with(:os, :fedora).and_return([os_plugin, {:class => Appliance, :type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "rawhide"]}])
237
+ @plugin_manager.should_receive(:initialize_plugin).once.with(:os, :fedora).and_return([os_plugin, {:class => Appliance, :type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "rawhide"]}])
151
238
 
152
239
  @appliance.execute_plugin_chain
153
240
  end
@@ -164,7 +251,7 @@ module BoxGrinder
164
251
  os_plugin.should_receive(:deliverables).and_return({:disk => 'abc'})
165
252
 
166
253
  @plugin_manager.should_receive(:plugins).and_return({:os => "something"})
167
- @plugin_manager.should_receive(:initialize_plugin).once.with(:os, :fedora).and_return([os_plugin, {:class => Appliance, :type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "rawhide"]}])
254
+ @plugin_manager.should_receive(:initialize_plugin).once.with(:os, :fedora).and_return([os_plugin, {:class => Appliance, :type => :os, :name => :fedora, :full_name => "Fedora", :versions => ["11", "12", "13", "rawhide"]}])
168
255
 
169
256
  @appliance.execute_plugin_chain
170
257
  end
@@ -182,7 +269,7 @@ module BoxGrinder
182
269
  platform_plugin.should_receive(:deliverables).and_return({:disk => 'abc'})
183
270
 
184
271
  @plugin_manager.should_receive(:plugins).and_return({:platform => "something"})
185
- @plugin_manager.should_receive(:initialize_plugin).once.with(:platform, :vmware).and_return([platform_plugin, {:class => Appliance, :type => :platform, :name => :vmware, :full_name => "VMware"}])
272
+ @plugin_manager.should_receive(:initialize_plugin).once.with(:platform, :vmware).and_return([platform_plugin, {:class => Appliance, :type => :platform, :name => :vmware, :full_name => "VMware"}])
186
273
 
187
274
  @appliance.execute_plugin_chain
188
275
  end
@@ -200,7 +287,7 @@ module BoxGrinder
200
287
  platform_plugin.should_receive(:deliverables).and_return({:disk => 'abc'})
201
288
 
202
289
  @plugin_manager.should_receive(:plugins).and_return({:platform => "something"})
203
- @plugin_manager.should_receive(:initialize_plugin).once.with(:platform, :vmware).and_return([platform_plugin, {:class => Appliance, :type => :platform, :name => :vmware, :full_name => "VMware"}])
290
+ @plugin_manager.should_receive(:initialize_plugin).once.with(:platform, :vmware).and_return([platform_plugin, {:class => Appliance, :type => :platform, :name => :vmware, :full_name => "VMware"}])
204
291
 
205
292
  @appliance.execute_plugin_chain
206
293
  end
@@ -217,7 +304,7 @@ module BoxGrinder
217
304
  delivery_plugin.should_receive(:run).with(:ami)
218
305
 
219
306
  @plugin_manager.should_receive(:plugins).and_return({:delivery => "something"})
220
- @plugin_manager.should_receive(:initialize_plugin).with(:delivery, :ami).and_return([delivery_plugin, {:class => Appliance, :type => :delivery, :name => :s3, :full_name => "Amazon Simple Storage Service (Amazon S3)", :types => [:s3, :cloudfront, :ami]}])
307
+ @plugin_manager.should_receive(:initialize_plugin).with(:delivery, :ami).and_return([delivery_plugin, {:class => Appliance, :type => :delivery, :name => :s3, :full_name => "Amazon Simple Storage Service (Amazon S3)", :types => [:s3, :cloudfront, :ami]}])
221
308
 
222
309
  @appliance.execute_plugin_chain
223
310
  end
@@ -234,7 +321,7 @@ module BoxGrinder
234
321
  delivery_plugin.should_receive(:run).with(:same)
235
322
 
236
323
  @plugin_manager.should_receive(:plugins).and_return({:delivery => "something"})
237
- @plugin_manager.should_receive(:initialize_plugin).with(:delivery, :same).and_return([delivery_plugin, {:class => Appliance, :type => :delivery, :name => :same, :full_name => "A plugin"}])
324
+ @plugin_manager.should_receive(:initialize_plugin).with(:delivery, :same).and_return([delivery_plugin, {:class => Appliance, :type => :delivery, :name => :same, :full_name => "A plugin"}])
238
325
 
239
326
  @appliance.execute_plugin_chain
240
327
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxgrinder-build
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 4
10
- version: 0.6.4
9
+ - 5
10
+ version: 0.6.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marek Goldmann
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-23 00:00:00 +01:00
18
+ date: 2010-12-03 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -42,12 +42,12 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 29
45
+ hash: 19
46
46
  segments:
47
47
  - 0
48
48
  - 1
49
- - 3
50
- version: 0.1.3
49
+ - 4
50
+ version: 0.1.4
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  description: A tool for creating appliances from simple plain text files for various virtual environments.