boxgrinder-build 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/CHANGELOG +14 -0
  2. data/README.md +136 -0
  3. data/Rakefile +11 -6
  4. data/bin/boxgrinder-build +199 -0
  5. data/boxgrinder-build.gemspec +26 -14
  6. data/lib/boxgrinder-build/appliance.rb +6 -6
  7. data/lib/boxgrinder-build/helpers/guestfs-helper.rb +5 -3
  8. data/lib/boxgrinder-build/helpers/image-helper.rb +6 -0
  9. data/lib/boxgrinder-build/helpers/plugin-helper.rb +15 -4
  10. data/lib/boxgrinder-build/plugins/base-plugin.rb +1 -0
  11. data/lib/boxgrinder-build/plugins/delivery/ebs/ebs-plugin.rb +280 -0
  12. data/lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb +66 -0
  13. data/lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb +242 -0
  14. data/lib/boxgrinder-build/plugins/delivery/s3/src/cert-ec2.pem +23 -0
  15. data/lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb +152 -0
  16. data/lib/boxgrinder-build/plugins/delivery/usb/usb-plugin.rb +43 -0
  17. data/lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb +46 -0
  18. data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +61 -0
  19. data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +67 -0
  20. data/lib/boxgrinder-build/plugins/os/rpm-based/kickstart.rb +118 -0
  21. data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-based-os-plugin.rb +202 -0
  22. data/lib/boxgrinder-build/plugins/os/rpm-based/rpm-dependency-validator.rb +153 -0
  23. data/lib/boxgrinder-build/plugins/os/rpm-based/src/appliance.ks.erb +37 -0
  24. data/lib/boxgrinder-build/plugins/os/rpm-based/src/base.repo +4 -0
  25. data/lib/boxgrinder-build/plugins/os/rpm-based/src/motd.init +21 -0
  26. data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +239 -0
  27. data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit +7 -0
  28. data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit +7 -0
  29. data/lib/boxgrinder-build/plugins/platform/ec2/src/ifcfg-eth0 +7 -0
  30. data/lib/boxgrinder-build/plugins/platform/ec2/src/menu.lst +6 -0
  31. data/lib/boxgrinder-build/plugins/platform/ec2/src/rc_local +19 -0
  32. data/lib/boxgrinder-build/plugins/platform/virtualbox/virtualbox-plugin.rb +62 -0
  33. data/lib/boxgrinder-build/plugins/platform/vmware/src/README-enterprise +18 -0
  34. data/lib/boxgrinder-build/plugins/platform/vmware/src/README-personal +16 -0
  35. data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk +20 -0
  36. data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx +45 -0
  37. data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +194 -0
  38. data/rubygem-boxgrinder-build.spec +73 -10
  39. data/spec/appliance-spec.rb +2 -2
  40. data/spec/helpers/guestfs-helper-spec.rb +4 -2
  41. data/spec/helpers/image-helper-spec.rb +4 -0
  42. data/spec/helpers/plugin-helper-spec.rb +0 -38
  43. data/spec/managers/plugin-manager-spec.rb +6 -6
  44. data/spec/plugins/delivery/ebs/ebs-plugin-spec.rb +230 -0
  45. data/spec/plugins/delivery/ebs/ebs.yaml +3 -0
  46. data/spec/plugins/delivery/local/local-plugin-spec.rb +133 -0
  47. data/spec/plugins/delivery/s3/s3-plugin-spec.rb +351 -0
  48. data/spec/plugins/delivery/sftp/sftp-plugin-spec.rb +26 -0
  49. data/spec/plugins/os/centos/centos-plugin-spec.rb +52 -0
  50. data/spec/plugins/os/fedora/fedora-plugin-spec.rb +73 -0
  51. data/spec/plugins/os/rhel/rhel-plugin-spec.rb +158 -0
  52. data/spec/plugins/os/rpm-based/kickstart-spec.rb +129 -0
  53. data/spec/plugins/os/rpm-based/rpm-based-os-plugin-spec.rb +162 -0
  54. data/spec/plugins/os/rpm-based/rpm-dependency-validator-spec.rb +50 -0
  55. data/spec/plugins/os/rpm-based/src/jeos-f13-plain.ks +20 -0
  56. data/spec/plugins/os/rpm-based/src/jeos-f13-without-version.ks +22 -0
  57. data/spec/plugins/os/rpm-based/src/jeos-f13.ks +23 -0
  58. data/spec/plugins/platform/ec2/ec2-plugin-spec.rb +339 -0
  59. data/spec/plugins/platform/virtualbox/virtualbox-plugin-spec.rb +118 -0
  60. data/spec/plugins/platform/vmware/vmware-plugin-spec.rb +299 -0
  61. metadata +149 -25
  62. data/README +0 -7
  63. data/bin/boxgrinder +0 -128
  64. data/lib/boxgrinder-build/helpers/thor-helper.rb +0 -85
data/bin/boxgrinder DELETED
@@ -1,128 +0,0 @@
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'"
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
- method_option :backtrace, :type => :boolean, :default => false, :aliases => '-b', :desc => "Prints full backtrace if errors occur whilst building. Default: true if -debug or -trace, else false."
45
-
46
- def build(appliance_definition_file)
47
- log_level = :debug if options.debug?
48
- log_level = :trace if options.trace?
49
- #TODO want to be able to compare log levels like Logger::LVL_X<=>Logger::LVL_Y (as with inbuilt logger CONST values)
50
- backtrace = options.backtrace || !log_level.nil?
51
-
52
- config = Config.new(options.merge(:platform => options.platform.to_sym, :delivery => options.delivery.to_sym))
53
- config.merge!(:log_level => log_level) unless log_level.nil?
54
-
55
- log = LogHelper.new(:level => config.log_level)
56
-
57
- unless File.exists?(appliance_definition_file)
58
- log.fatal "Appliance definition file '#{appliance_definition_file}' could not be found."
59
- abort
60
- end
61
-
62
- begin
63
- Appliance.new(appliance_definition_file, config, :log => log).create
64
- rescue Exception => e
65
- if backtrace
66
- log.fatal e
67
- else #demote backtrace to debug so that it is in file log only
68
- log.fatal e.message
69
- log.debug e.backtrace.join($/)
70
- end
71
- end
72
- end
73
-
74
- desc 'info', "Prints out the program details"
75
- method_option :plugins, :type => :boolean, :default => false, :aliases => '-p', :desc => "List also available plugins. Default: false."
76
-
77
- def info
78
- PluginHelper.new(Config.new).load_plugins if options.plugins
79
-
80
- shell.say
81
- shell.say "BoxGrinder Build #{File.read("#{File.dirname(__FILE__)}/../CHANGELOG").match(/^v(.*)/)[1]}"
82
-
83
- if options.plugins
84
-
85
- shell.say
86
- shell.say "Plugin summary:"
87
-
88
- [:os, :platform, :delivery].each do |type|
89
- shell.say
90
-
91
- if PluginManager.instance.plugins[type].empty?
92
- shell.say "No #{type} plugins available"
93
- else
94
- shell.say "Available #{type} plugins:"
95
- PluginManager.instance.plugins[type].each do |name, plugin_info|
96
- shell.say " - #{name} plugin for #{plugin_info[:full_name]}."
97
- end
98
- end
99
- end
100
- end
101
-
102
- shell.say
103
- end
104
-
105
- class << self
106
- def build_help(shell)
107
- examples = {
108
- "$ boxgrinder build jeos.appl" => "# Build KVM image for jeos.appl",
109
- "$ boxgrinder build jeos.appl -f" => "# Build KVM image for jeos.appl with removing previous build for this image",
110
- "$ boxgrinder build jeos.appl --os-config format:qcow2" => "# Build KVM image for jeos.appl with a qcow2 disk",
111
- "$ 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",
112
- "$ boxgrinder build jeos.appl -p ec2 -d ami" => "# Build and register AMI for jeos.appl",
113
- "$ boxgrinder build jeos.appl -p vmware -d local" => "# Build VMware image for jeos.appl and deliver it to local directory"
114
- }.sort { |a, b| a[0] <=> b[0] }
115
-
116
- shell.say "Examples:"
117
- shell.print_table(examples, :ident => 2, :truncate => true)
118
- shell.say
119
- end
120
- end
121
- end
122
- end
123
-
124
- begin
125
- BoxGrinder::App.start
126
- rescue Thor::Error => e
127
- puts e.message
128
- end
@@ -1,85 +0,0 @@
1
- # Copyright 2010 Red Hat, Inc.
2
- #
3
- # This is free software; you can redistribute it and/or modify it
4
- # under the terms of the GNU Lesser General Public License as
5
- # published by the Free Software Foundation; either version 3 of
6
- # the License, or (at your option) any later version.
7
- #
8
- # This software is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- # Lesser General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU Lesser General Public
14
- # License along with this software; if not, write to the Free
15
- # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16
- # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
17
-
18
- require 'thor'
19
-
20
- class Thor
21
- module CoreExt
22
- class HashWithIndifferentAccess < ::Hash
23
- def initialize(hash={})
24
- super()
25
- hash.each do |key, value|
26
- self[convert_key(key)] = value
27
- end
28
-
29
- to_boolean(self)
30
- end
31
-
32
- def to_boolean(h)
33
- h.each do |k, v|
34
- if v.is_a?(Hash)
35
- to_boolean(v)
36
- next
37
- end
38
-
39
- next unless v.is_a?(String)
40
-
41
- case v
42
- when /^true$/i then
43
- h[k] = true
44
- when /^false$/i then
45
- h[k] = false
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
52
-
53
- module BoxGrinder
54
- class ThorHelper < Thor
55
- class << self
56
- def help(shell)
57
- boxgrinder_header(shell)
58
- super(shell)
59
- end
60
-
61
- def task_help(shell, task_name)
62
- boxgrinder_header(shell)
63
-
64
- help_method = "#{task_name}_help".to_sym
65
- send(help_method, shell) if respond_to?(help_method) and method(help_method).arity == 1
66
- super(shell, task_name)
67
-
68
- shell.say
69
- end
70
-
71
- def boxgrinder_header(shell)
72
- shell.say
73
- shell.say "BoxGrinder Build:"
74
- shell.say " A tool for building VM images from simple definition files."
75
- shell.say
76
- shell.say "Homepage:"
77
- shell.say " http://boxgrinder.org/"
78
- shell.say
79
- shell.say "Documentation:"
80
- shell.say " http://boxgrinder.org/tutorials/"
81
- shell.say
82
- end
83
- end
84
- end
85
- end