boxgrinder-build 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +13 -0
- data/Manifest +3 -3
- data/Rakefile +1 -1
- data/bin/boxgrinder +121 -0
- data/boxgrinder-build.gemspec +12 -12
- data/lib/boxgrinder-build.rb +19 -0
- data/lib/boxgrinder-build/appliance.rb +30 -35
- data/lib/boxgrinder-build/helpers/appliance-customize-helper.rb +2 -2
- data/lib/boxgrinder-build/helpers/augeas-helper.rb +2 -2
- data/lib/boxgrinder-build/helpers/guestfs-helper.rb +16 -7
- data/lib/boxgrinder-build/helpers/image-helper.rb +48 -20
- data/lib/boxgrinder-build/helpers/linux-helper.rb +2 -2
- data/lib/boxgrinder-build/helpers/package-helper.rb +9 -12
- data/lib/boxgrinder-build/helpers/plugin-helper.rb +11 -19
- data/lib/boxgrinder-build/helpers/thor-helper.rb +82 -0
- data/lib/boxgrinder-build/managers/plugin-manager.rb +10 -25
- data/lib/boxgrinder-build/plugins/base-plugin.rb +50 -33
- data/rubygem-boxgrinder-build.spec +20 -5
- data/spec/appliance-spec.rb +60 -46
- data/spec/helpers/guestfs-helper-spec.rb +123 -37
- data/spec/helpers/image-helper-spec.rb +126 -56
- data/spec/helpers/package-helper-spec.rb +35 -0
- data/spec/helpers/plugin-helper-spec.rb +64 -20
- data/spec/managers/plugin-manager-spec.rb +33 -2
- data/spec/plugins/base-plugin-spec.rb +83 -27
- metadata +21 -20
- data/bin/boxgrinder-build +0 -91
- data/spec/rspec/src/appliances/jeos-f13.appl +0 -27
- data/spec/rspec/src/appliances/jeos-f13.ks +0 -23
data/CHANGELOG
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
v0.8.0
|
2
|
+
|
3
|
+
* [BGBUILD-138] enablerepo path is not escaped when calling repoquery
|
4
|
+
* [BGBUILD-133] Support a consolidated configuration file
|
5
|
+
* [BGBUILD-128] Allow to specify plugin configuration using CLI
|
6
|
+
* [BGBUILD-134] Replace rubygem-commander with rubygem-thor
|
7
|
+
* [BGBUILD-131] Check if OS is supported before executing the plugin
|
8
|
+
* [BGBUILD-68] Global .boxgrinder/config or rc style file for config
|
9
|
+
* [BGBUILD-79] Allow to use BoxGrinder Build as a library
|
10
|
+
* [BGBUILD-127] Use appliance definition object instead of a file when using BG as a library
|
11
|
+
* [BGBUILD-72] Add support for growing (not pre-allocated) disks for KVM/Xen
|
12
|
+
* [BGBUILD-147] Allow to list installed plugins and version information
|
13
|
+
|
1
14
|
v0.7.1
|
2
15
|
|
3
16
|
* [BGBUILD-124] Guestfs fails while mounting multiple partitions with '_' prefix
|
data/Manifest
CHANGED
@@ -3,8 +3,9 @@ LICENSE
|
|
3
3
|
Manifest
|
4
4
|
README
|
5
5
|
Rakefile
|
6
|
-
bin/boxgrinder
|
6
|
+
bin/boxgrinder
|
7
7
|
boxgrinder-build.gemspec
|
8
|
+
lib/boxgrinder-build.rb
|
8
9
|
lib/boxgrinder-build/appliance.rb
|
9
10
|
lib/boxgrinder-build/helpers/appliance-customize-helper.rb
|
10
11
|
lib/boxgrinder-build/helpers/augeas-helper.rb
|
@@ -13,6 +14,7 @@ lib/boxgrinder-build/helpers/image-helper.rb
|
|
13
14
|
lib/boxgrinder-build/helpers/linux-helper.rb
|
14
15
|
lib/boxgrinder-build/helpers/package-helper.rb
|
15
16
|
lib/boxgrinder-build/helpers/plugin-helper.rb
|
17
|
+
lib/boxgrinder-build/helpers/thor-helper.rb
|
16
18
|
lib/boxgrinder-build/managers/plugin-manager.rb
|
17
19
|
lib/boxgrinder-build/plugins/base-plugin.rb
|
18
20
|
rubygem-boxgrinder-build.spec
|
@@ -27,5 +29,3 @@ spec/helpers/package-helper-spec.rb
|
|
27
29
|
spec/helpers/plugin-helper-spec.rb
|
28
30
|
spec/managers/plugin-manager-spec.rb
|
29
31
|
spec/plugins/base-plugin-spec.rb
|
30
|
-
spec/rspec/src/appliances/jeos-f13.appl
|
31
|
-
spec/rspec/src/appliances/jeos-f13.ks
|
data/Rakefile
CHANGED
@@ -26,7 +26,7 @@ Echoe.new("boxgrinder-build") do |p|
|
|
26
26
|
p.summary = "A tool for creating appliances from simple plain text files for various virtual environments."
|
27
27
|
p.url = "http://www.jboss.org/boxgrinder"
|
28
28
|
p.email = "info@boxgrinder.org"
|
29
|
-
p.runtime_dependencies = ["
|
29
|
+
p.runtime_dependencies = ["thor >=0.13", "boxgrinder-core ~>0.2.0"]
|
30
30
|
end
|
31
31
|
|
32
32
|
desc "Run all tests"
|
data/bin/boxgrinder
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright 2010 Red Hat, Inc.
|
4
|
+
#
|
5
|
+
# This is free software; you can redistribute it and/or modify it
|
6
|
+
# under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation; either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This software is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this software; if not, write to the Free
|
17
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
18
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
19
|
+
|
20
|
+
require 'rubygems'
|
21
|
+
require 'boxgrinder-core/helpers/log-helper'
|
22
|
+
require 'boxgrinder-build/appliance'
|
23
|
+
require 'boxgrinder-build/helpers/thor-helper'
|
24
|
+
|
25
|
+
#$stderr.reopen($stdout)
|
26
|
+
|
27
|
+
if Process.uid != 0
|
28
|
+
puts "This program must be executed with root privileges. Try 'sudo boxgrinder-build'"
|
29
|
+
abort
|
30
|
+
end
|
31
|
+
|
32
|
+
module BoxGrinder
|
33
|
+
class App < ThorHelper
|
34
|
+
desc "build [appliance definition file] [options]", "Create an image from selected appliance definition for selected platform and deliver it using selected method"
|
35
|
+
method_option :platform, :type => :string, :default => :none, :aliases => '-p', :desc => "The name of platform you want to convert to."
|
36
|
+
method_option :delivery, :type => :string, :default => :none, :aliases => '-d', :desc => "The delivery method for selected appliance."
|
37
|
+
method_option :os_config, :type => :hash, :default => {}, :desc => "Operating system plugin options."
|
38
|
+
method_option :platform_config, :type => :hash, :default => {}, :desc => "Platform plugin options."
|
39
|
+
method_option :delivery_config, :type => :hash, :default => {}, :desc => "Delivery plugin options."
|
40
|
+
method_option :additional_plugins, :type => :array, :default => [], :banner => 'plugin1 plugin2', :aliases => '-l', :desc => "Space separated list of additional plugins. Default: empty."
|
41
|
+
method_option :force, :type => :boolean, :default => false, :aliases => '-f', :desc => "Force image creation - removes all previous builds for selected appliance. Default: false."
|
42
|
+
method_option :debug, :type => :boolean, :default => false, :desc => "Prints debug information while building. Default: false."
|
43
|
+
method_option :trace, :type => :boolean, :default => false, :desc => "Prints trace information while building. Default: false."
|
44
|
+
|
45
|
+
def build(appliance_definition_file)
|
46
|
+
log_level = :debug if options.debug?
|
47
|
+
log_level = :trace if options.trace?
|
48
|
+
|
49
|
+
config = Config.new(options.merge(:platform => options.platform.to_sym, :delivery => options.delivery.to_sym))
|
50
|
+
config.merge!(:log_level => log_level) unless log_level.nil?
|
51
|
+
|
52
|
+
log = LogHelper.new(:level => config.log_level)
|
53
|
+
|
54
|
+
unless File.exists?(appliance_definition_file)
|
55
|
+
log.fatal "Appliance definition file '#{appliance_definition_file}' could not be found."
|
56
|
+
abort
|
57
|
+
end
|
58
|
+
|
59
|
+
begin
|
60
|
+
Appliance.new(appliance_definition_file, config, :log => log).create
|
61
|
+
rescue Exception => e
|
62
|
+
log.fatal e
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
desc 'info', "Prints out the program details"
|
67
|
+
method_option :plugins, :type => :boolean, :default => false, :aliases => '-p', :desc => "List also available plugins. Default: false."
|
68
|
+
|
69
|
+
def info
|
70
|
+
PluginHelper.new(Config.new).load_plugins if options.plugins
|
71
|
+
|
72
|
+
shell.say
|
73
|
+
shell.say "BoxGrinder Build #{File.read("#{File.dirname(__FILE__)}/../CHANGELOG").match(/^v(.*)/)[1]}"
|
74
|
+
|
75
|
+
if options.plugins
|
76
|
+
|
77
|
+
shell.say
|
78
|
+
shell.say "Plugin summary:"
|
79
|
+
|
80
|
+
[:os, :platform, :delivery].each do |type|
|
81
|
+
shell.say
|
82
|
+
|
83
|
+
if PluginManager.instance.plugins[type].empty?
|
84
|
+
shell.say "No #{type} plugins available"
|
85
|
+
else
|
86
|
+
shell.say "Available #{type} plugins:"
|
87
|
+
PluginManager.instance.plugins[type].each do |name, plugin_info|
|
88
|
+
shell.say " - #{name} plugin for #{plugin_info[:full_name]}."
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
shell.say
|
95
|
+
end
|
96
|
+
|
97
|
+
class << self
|
98
|
+
def build_help(shell)
|
99
|
+
examples = {
|
100
|
+
"$ boxgrinder build jeos.appl" => "# Build KVM image for jeos.appl",
|
101
|
+
"$ boxgrinder build jeos.appl -f" => "# Build KVM image for jeos.appl with removing previous build for this image",
|
102
|
+
"$ boxgrinder build jeos.appl --os-config format:qcow2" => "# Build KVM image for jeos.appl with a qcow2 disk",
|
103
|
+
"$ boxgrinder build jeos.appl -p vmware --platform-config type:personal thin_disk:true" => "# Build VMware image for VMware Server, Player, Fusion using thin (growing) disk",
|
104
|
+
"$ boxgrinder build jeos.appl -p ec2 -d ami" => "# Build and register AMI for jeos.appl",
|
105
|
+
"$ boxgrinder build jeos.appl -p vmware -d local" => "# Build VMware image for jeos.appl and deliver it to local directory"
|
106
|
+
}.sort { |a, b| a[0] <=> b[0] }
|
107
|
+
|
108
|
+
shell.say "Examples:"
|
109
|
+
shell.print_table(examples, :ident => 2, :truncate => true)
|
110
|
+
shell.say
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
begin
|
117
|
+
BoxGrinder::App.start
|
118
|
+
rescue Thor::Error => e
|
119
|
+
puts e.message
|
120
|
+
end
|
121
|
+
|
data/boxgrinder-build.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{boxgrinder-build}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.8.0"
|
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{2011-
|
10
|
-
s.default_executable = %q{boxgrinder
|
9
|
+
s.date = %q{2011-02-09}
|
10
|
+
s.default_executable = %q{boxgrinder}
|
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}
|
13
|
-
s.executables = ["boxgrinder
|
14
|
-
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/boxgrinder-build", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/image-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb"]
|
15
|
-
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/boxgrinder-build", "boxgrinder-build.
|
13
|
+
s.executables = ["boxgrinder"]
|
14
|
+
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "bin/boxgrinder", "lib/boxgrinder-build.rb", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/image-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/helpers/thor-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb"]
|
15
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "bin/boxgrinder", "boxgrinder-build.gemspec", "lib/boxgrinder-build.rb", "lib/boxgrinder-build/appliance.rb", "lib/boxgrinder-build/helpers/appliance-customize-helper.rb", "lib/boxgrinder-build/helpers/augeas-helper.rb", "lib/boxgrinder-build/helpers/guestfs-helper.rb", "lib/boxgrinder-build/helpers/image-helper.rb", "lib/boxgrinder-build/helpers/linux-helper.rb", "lib/boxgrinder-build/helpers/package-helper.rb", "lib/boxgrinder-build/helpers/plugin-helper.rb", "lib/boxgrinder-build/helpers/thor-helper.rb", "lib/boxgrinder-build/managers/plugin-manager.rb", "lib/boxgrinder-build/plugins/base-plugin.rb", "rubygem-boxgrinder-build.spec", "spec/Rakefile", "spec/appliance-spec.rb", "spec/helpers/appliance-customize-helper-spec.rb", "spec/helpers/augeas-helper-spec.rb", "spec/helpers/guestfs-helper-spec.rb", "spec/helpers/image-helper-spec.rb", "spec/helpers/linux-helper-spec.rb", "spec/helpers/package-helper-spec.rb", "spec/helpers/plugin-helper-spec.rb", "spec/managers/plugin-manager-spec.rb", "spec/plugins/base-plugin-spec.rb"]
|
16
16
|
s.homepage = %q{http://www.jboss.org/boxgrinder}
|
17
17
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-build", "--main", "README"]
|
18
18
|
s.require_paths = ["lib"]
|
@@ -25,14 +25,14 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.specification_version = 3
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
|
-
s.add_runtime_dependency(%q<
|
29
|
-
s.add_runtime_dependency(%q<boxgrinder-core>, ["~> 0.
|
28
|
+
s.add_runtime_dependency(%q<thor>, [">= 0.13"])
|
29
|
+
s.add_runtime_dependency(%q<boxgrinder-core>, ["~> 0.2.0"])
|
30
30
|
else
|
31
|
-
s.add_dependency(%q<
|
32
|
-
s.add_dependency(%q<boxgrinder-core>, ["~> 0.
|
31
|
+
s.add_dependency(%q<thor>, [">= 0.13"])
|
32
|
+
s.add_dependency(%q<boxgrinder-core>, ["~> 0.2.0"])
|
33
33
|
end
|
34
34
|
else
|
35
|
-
s.add_dependency(%q<
|
36
|
-
s.add_dependency(%q<boxgrinder-core>, ["~> 0.
|
35
|
+
s.add_dependency(%q<thor>, [">= 0.13"])
|
36
|
+
s.add_dependency(%q<boxgrinder-core>, ["~> 0.2.0"])
|
37
37
|
end
|
38
38
|
end
|
@@ -0,0 +1,19 @@
|
|
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/appliance'
|
@@ -17,6 +17,8 @@
|
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
19
|
require 'rubygems'
|
20
|
+
require 'hashery/opencascade'
|
21
|
+
require 'boxgrinder-core/helpers/log-helper'
|
20
22
|
require 'boxgrinder-core/models/appliance-config'
|
21
23
|
require 'boxgrinder-core/models/config'
|
22
24
|
require 'boxgrinder-core/helpers/appliance-helper'
|
@@ -27,47 +29,41 @@ require 'boxgrinder-core/validators/appliance-config-validator'
|
|
27
29
|
|
28
30
|
module BoxGrinder
|
29
31
|
class Appliance
|
30
|
-
|
31
|
-
|
32
|
-
@config
|
33
|
-
@
|
34
|
-
@log = options[:log] || Logger.new(STDOUT)
|
35
|
-
@options = options[:options]
|
36
|
-
|
37
|
-
@config.name = @options.name
|
38
|
-
@config.version.version = @options.version
|
39
|
-
@config.version.release = nil
|
32
|
+
def initialize(appliance_definition, config = Config.new, options = {})
|
33
|
+
@appliance_definition = appliance_definition
|
34
|
+
@config = config
|
35
|
+
@log = options[:log] || LogHelper.new(:level => @config.log_level)
|
40
36
|
end
|
41
37
|
|
42
38
|
def read_definition
|
43
39
|
begin
|
44
40
|
# first try to read as appliance definition file
|
45
|
-
appliance_configs, appliance_config = ApplianceHelper.new(:log => @log).read_definitions(@
|
41
|
+
appliance_configs, appliance_config = ApplianceHelper.new(:log => @log).read_definitions(@appliance_definition)
|
46
42
|
rescue
|
47
43
|
# then try to read OS plugin specific format
|
48
44
|
PluginManager.instance.plugins[:os].each_value do |info|
|
49
45
|
plugin = info[:class].new
|
50
|
-
appliance_config = plugin.read_file(@
|
46
|
+
appliance_config = plugin.read_file(@appliance_definition) if plugin.respond_to?(:read_file)
|
51
47
|
break unless appliance_config.nil?
|
52
48
|
end
|
53
49
|
appliance_configs = [appliance_config]
|
54
50
|
end
|
55
51
|
|
56
|
-
raise "Couldn't read appliance definition file: #{File.basename(@
|
52
|
+
raise "Couldn't read appliance definition file: #{File.basename(@appliance_definition)}" if appliance_config.nil?
|
57
53
|
|
58
54
|
appliance_config_helper = ApplianceConfigHelper.new(appliance_configs)
|
59
|
-
@appliance_config
|
55
|
+
@appliance_config = appliance_config_helper.merge(appliance_config.clone.init_arch).initialize_paths
|
60
56
|
end
|
61
57
|
|
62
58
|
def validate_definition
|
63
59
|
ApplianceConfigValidator.new(@appliance_config).validate
|
64
60
|
|
65
|
-
|
61
|
+
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?
|
66
62
|
|
67
63
|
os_plugin = PluginManager.instance.plugins[:os][@appliance_config.os.name.to_sym]
|
68
64
|
|
69
|
-
|
70
|
-
|
65
|
+
raise "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?
|
66
|
+
raise "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)
|
71
67
|
end
|
72
68
|
|
73
69
|
def remove_old_builds
|
@@ -83,19 +79,18 @@ module BoxGrinder
|
|
83
79
|
end
|
84
80
|
|
85
81
|
def create
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
82
|
+
@log.debug "Launching new BoxGrinder build..."
|
83
|
+
@log.trace "Used configuration: #{@config.to_yaml}"
|
84
|
+
|
85
|
+
PluginHelper.new(@config, :log => @log).load_plugins
|
86
|
+
read_definition
|
87
|
+
validate_definition
|
88
|
+
remove_old_builds if @config.force
|
89
|
+
execute_plugin_chain
|
95
90
|
end
|
96
91
|
|
97
92
|
def execute_os_plugin
|
98
|
-
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?
|
93
|
+
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?
|
99
94
|
|
100
95
|
os_plugin, os_plugin_info = PluginManager.instance.initialize_plugin(:os, @appliance_config.os.name.to_sym)
|
101
96
|
os_plugin.init(@config, @appliance_config, :log => @log, :plugin_info => os_plugin_info)
|
@@ -106,21 +101,21 @@ module BoxGrinder
|
|
106
101
|
end
|
107
102
|
|
108
103
|
@log.debug "Executing operating system plugin for #{@appliance_config.os.name}..."
|
109
|
-
os_plugin.run(@
|
104
|
+
os_plugin.run(@appliance_definition)
|
110
105
|
@log.debug "Operating system plugin executed."
|
111
106
|
|
112
107
|
{:deliverables => os_plugin.deliverables, :plugin_info => os_plugin_info}
|
113
108
|
end
|
114
109
|
|
115
110
|
def execute_platform_plugin(previous_plugin_output)
|
116
|
-
if @
|
111
|
+
if @config.platform == :none or @config.platform.to_s.empty? == nil
|
117
112
|
@log.debug "No platform selected, skipping platform conversion."
|
118
113
|
return previous_plugin_output
|
119
114
|
end
|
120
115
|
|
121
|
-
raise "No platform plugins installed. Install one or more platform plugin. See http://community.jboss.org/docs/DOC-15081 and http://community.jboss.org/docs/DOC-15214 for more info" if PluginManager.instance.plugins[:platform].empty?
|
116
|
+
raise "No platform plugins installed. Install one or more platform plugin. See http://community.jboss.org/docs/DOC-15081 and http://community.jboss.org/docs/DOC-15214 for more info." if PluginManager.instance.plugins[:platform].empty?
|
122
117
|
|
123
|
-
platform_plugin, platform_plugin_info = PluginManager.instance.initialize_plugin(:platform, @
|
118
|
+
platform_plugin, platform_plugin_info = PluginManager.instance.initialize_plugin(:platform, @config.platform)
|
124
119
|
platform_plugin.init(@config, @appliance_config, :log => @log, :plugin_info => platform_plugin_info, :previous_plugin_info => previous_plugin_output[:plugin_info], :previous_deliverables => previous_plugin_output[:deliverables])
|
125
120
|
|
126
121
|
if platform_plugin.deliverables_exists?
|
@@ -128,7 +123,7 @@ module BoxGrinder
|
|
128
123
|
return {:deliverables => platform_plugin.deliverables, :plugin_info => platform_plugin_info}
|
129
124
|
end
|
130
125
|
|
131
|
-
@log.debug "Executing platform plugin for #{@
|
126
|
+
@log.debug "Executing platform plugin for #{@config.platform}..."
|
132
127
|
platform_plugin.run
|
133
128
|
@log.debug "Platform plugin executed."
|
134
129
|
|
@@ -136,16 +131,16 @@ module BoxGrinder
|
|
136
131
|
end
|
137
132
|
|
138
133
|
def execute_delivery_plugin(previous_plugin_output)
|
139
|
-
if @
|
134
|
+
if @config.delivery == :none or @config.delivery.to_s.empty? == nil
|
140
135
|
@log.debug "No delivery method selected, skipping delivering."
|
141
136
|
return
|
142
137
|
end
|
143
138
|
|
144
139
|
raise "No delivery plugins installed. Install one or more delivery plugin. See http://community.jboss.org/docs/DOC-15081 and http://community.jboss.org/docs/DOC-15214 for more info" if PluginManager.instance.plugins[:delivery].empty?
|
145
140
|
|
146
|
-
delivery_plugin, delivery_plugin_info = PluginManager.instance.initialize_plugin(:delivery, @
|
141
|
+
delivery_plugin, delivery_plugin_info = PluginManager.instance.initialize_plugin(:delivery, @config.delivery)
|
147
142
|
delivery_plugin.init(@config, @appliance_config, :log => @log, :plugin_info => delivery_plugin_info, :previous_plugin_info => previous_plugin_output[:plugin_info], :previous_deliverables => previous_plugin_output[:deliverables])
|
148
|
-
delivery_plugin.run(@
|
143
|
+
delivery_plugin.run(@config.delivery)
|
149
144
|
end
|
150
145
|
end
|
151
146
|
end
|
@@ -19,7 +19,7 @@
|
|
19
19
|
require 'rubygems'
|
20
20
|
require 'boxgrinder-build/helpers/guestfs-helper'
|
21
21
|
require 'boxgrinder-core/helpers/exec-helper'
|
22
|
-
require '
|
22
|
+
require 'boxgrinder-core/helpers/log-helper'
|
23
23
|
|
24
24
|
module BoxGrinder
|
25
25
|
class ApplianceCustomizeHelper
|
@@ -29,7 +29,7 @@ module BoxGrinder
|
|
29
29
|
@appliance_config = appliance_config
|
30
30
|
@disk = disk
|
31
31
|
|
32
|
-
@log = options[:log] ||
|
32
|
+
@log = options[:log] || LogHelper.new
|
33
33
|
@exec_helper = options[:exec_helper] || ExecHelper.new( { :log => @log } )
|
34
34
|
end
|
35
35
|
|
@@ -16,14 +16,14 @@
|
|
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 '
|
19
|
+
require 'boxgrinder-core/helpers/log-helper'
|
20
20
|
|
21
21
|
module BoxGrinder
|
22
22
|
class AugeasHelper
|
23
23
|
def initialize(guestfs, guestfs_helper, options = {})
|
24
24
|
@guestfs = guestfs
|
25
25
|
@guestfs_helper = guestfs_helper
|
26
|
-
@log = options[:log] ||
|
26
|
+
@log = options[:log] || LogHelper.new
|
27
27
|
|
28
28
|
@files = {}
|
29
29
|
end
|
@@ -17,9 +17,10 @@
|
|
17
17
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
18
18
|
|
19
19
|
require 'boxgrinder-build/helpers/augeas-helper'
|
20
|
+
require 'boxgrinder-core/helpers/log-helper'
|
20
21
|
require 'guestfs'
|
21
|
-
require 'logger'
|
22
22
|
require 'open-uri'
|
23
|
+
require 'timeout'
|
23
24
|
require 'rbconfig'
|
24
25
|
|
25
26
|
module BoxGrinder
|
@@ -82,7 +83,7 @@ module BoxGrinder
|
|
82
83
|
class GuestFSHelper
|
83
84
|
def initialize(raw_disk, options = {})
|
84
85
|
@raw_disk = raw_disk
|
85
|
-
@log = options[:log] ||
|
86
|
+
@log = options[:log] || LogHelper.new
|
86
87
|
|
87
88
|
@partitions = {}
|
88
89
|
end
|
@@ -93,7 +94,8 @@ module BoxGrinder
|
|
93
94
|
@log.trace "Checking if HW virtualization is available..."
|
94
95
|
|
95
96
|
begin
|
96
|
-
open('http://169.254.169.254/1.0/meta-data/local-ipv4')
|
97
|
+
Timeout::timeout(2) { open('http://169.254.169.254/1.0/meta-data/local-ipv4') }
|
98
|
+
|
97
99
|
ec2 = true
|
98
100
|
rescue Exception
|
99
101
|
ec2 = false
|
@@ -109,7 +111,7 @@ module BoxGrinder
|
|
109
111
|
false
|
110
112
|
end
|
111
113
|
|
112
|
-
def customize
|
114
|
+
def customize(options = {})
|
113
115
|
read_pipe, write_pipe = IO.pipe
|
114
116
|
|
115
117
|
fork do
|
@@ -122,7 +124,7 @@ module BoxGrinder
|
|
122
124
|
end
|
123
125
|
end
|
124
126
|
|
125
|
-
helper = execute(write_pipe)
|
127
|
+
helper = execute(write_pipe, options)
|
126
128
|
|
127
129
|
yield @guestfs, helper
|
128
130
|
|
@@ -133,7 +135,9 @@ module BoxGrinder
|
|
133
135
|
Process.wait
|
134
136
|
end
|
135
137
|
|
136
|
-
def execute(pipe = nil)
|
138
|
+
def execute(pipe = nil, options = {})
|
139
|
+
options = {:ide_disk => false}.merge(options)
|
140
|
+
|
137
141
|
@log.debug "Preparing guestfs..."
|
138
142
|
|
139
143
|
@guestfs = pipe.nil? ? Guestfs::create : Guestfs::create.redirect(pipe)
|
@@ -149,6 +153,7 @@ module BoxGrinder
|
|
149
153
|
@guestfs.set_selinux(1)
|
150
154
|
|
151
155
|
unless hw_virtualization_available?
|
156
|
+
# This wrapper is required especially for EC2 where running qemu-kvm crashes libguestfs
|
152
157
|
qemu_wrapper = (RbConfig::CONFIG['host_cpu'].eql?('x86_64') ? "/usr/bin/qemu-system-x86_64" : "/usr/bin/qemu")
|
153
158
|
|
154
159
|
if File.exists?(qemu_wrapper)
|
@@ -159,7 +164,11 @@ module BoxGrinder
|
|
159
164
|
end
|
160
165
|
|
161
166
|
@log.trace "Adding drive '#{@raw_disk}'..."
|
162
|
-
|
167
|
+
if options[:ide_disk]
|
168
|
+
@guestfs.add_drive_with_if(@raw_disk, 'ide')
|
169
|
+
else
|
170
|
+
@guestfs.add_drive(@raw_disk)
|
171
|
+
end
|
163
172
|
@log.trace "Drive added."
|
164
173
|
|
165
174
|
if @guestfs.respond_to?('set_network')
|