boxgrinder-build 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/LICENSE +165 -0
  2. data/README +4 -0
  3. data/appliances/jeos.appl +22 -0
  4. data/appliances/meta.appl +41 -0
  5. data/bin/boxgrinder +23 -0
  6. data/docs/examples/appliances/appliances-appliance/appliances-appliance.appl +6 -0
  7. data/docs/examples/appliances/appliances-appliance/appliances-appliance.pp +16 -0
  8. data/docs/examples/appliances/minimal-appliance/minimal-appliance.appl +2 -0
  9. data/docs/examples/appliances/minimal-appliance/minimal-appliance.pp +16 -0
  10. data/docs/examples/appliances/mix-appliance/mix-appliance.appl +9 -0
  11. data/docs/examples/appliances/mix-appliance/mix-appliance.pp +16 -0
  12. data/docs/examples/appliances/packages-appliance/packages-appliance.appl +6 -0
  13. data/docs/examples/appliances/packages-appliance/packages-appliance.pp +16 -0
  14. data/docs/node-info/pom.xml +31 -0
  15. data/docs/node-info/src/main/webapp/META-INF/MANIFEST.MF +3 -0
  16. data/docs/node-info/src/main/webapp/WEB-INF/web.xml +7 -0
  17. data/docs/node-info/src/main/webapp/index.jsp +70 -0
  18. data/extras/sign-rpms +12 -0
  19. data/lib/boxgrinder-build/appliance-kickstart.rb +159 -0
  20. data/lib/boxgrinder-build/appliance.rb +52 -0
  21. data/lib/boxgrinder-build/boxgrinder.rb +92 -0
  22. data/lib/boxgrinder-build/erb/appliance.ks.erb +44 -0
  23. data/lib/boxgrinder-build/helpers/appliance-customize-helper.rb +92 -0
  24. data/lib/boxgrinder-build/helpers/aws-helper.rb +75 -0
  25. data/lib/boxgrinder-build/helpers/guestfs-helper.rb +86 -0
  26. data/lib/boxgrinder-build/helpers/rake-helper.rb +71 -0
  27. data/lib/boxgrinder-build/helpers/release-helper.rb +135 -0
  28. data/lib/boxgrinder-build/helpers/ssh-helper.rb +140 -0
  29. data/lib/boxgrinder-build/images/ec2-image.rb +301 -0
  30. data/lib/boxgrinder-build/images/raw-image.rb +137 -0
  31. data/lib/boxgrinder-build/images/vmware-image.rb +214 -0
  32. data/lib/boxgrinder-build/models/ssh-config.rb +44 -0
  33. data/lib/boxgrinder-build/validators/appliance-config-parameter-validator.rb +37 -0
  34. data/lib/boxgrinder-build/validators/appliance-definition-validator.rb +89 -0
  35. data/lib/boxgrinder-build/validators/appliance-dependency-validator.rb +163 -0
  36. data/lib/boxgrinder-build/validators/appliance-validator.rb +84 -0
  37. data/lib/boxgrinder-build/validators/aws-validator.rb +58 -0
  38. data/lib/boxgrinder-build/validators/config-validator.rb +67 -0
  39. data/lib/boxgrinder-build/validators/ssh-validator.rb +35 -0
  40. data/lib/boxgrinder-build/validators/validator.rb +91 -0
  41. data/lib/boxgrinder-build.rb +48 -0
  42. data/lib/progressbar/progressbar.rb +236 -0
  43. data/src/README.vmware +38 -0
  44. data/src/base.repo +4 -0
  45. data/src/base.vmdk +19 -0
  46. data/src/base.vmx +45 -0
  47. data/src/ec2/fstab_32bit +8 -0
  48. data/src/ec2/fstab_64bit +8 -0
  49. data/src/ec2/ifcfg-eth0 +7 -0
  50. data/src/ec2/rc_local +32 -0
  51. data/src/f12/yum.conf +24 -0
  52. data/src/motd.init +21 -0
  53. data/src/oddthesis/RPM-GPG-KEY-oddthesis +30 -0
  54. data/src/oddthesis/oddthesis.repo +23 -0
  55. metadata +197 -0
@@ -0,0 +1,58 @@
1
+ # JBoss, Home of Professional Open Source
2
+ # Copyright 2009, Red Hat Middleware LLC, and individual contributors
3
+ # by the @authors tag. See the copyright.txt in the distribution for a
4
+ # full listing of individual contributors.
5
+ #
6
+ # This is free software; you can redistribute it and/or modify it
7
+ # under the terms of the GNU Lesser General Public License as
8
+ # published by the Free Software Foundation; either version 2.1 of
9
+ # the License, or (at your option) any later version.
10
+ #
11
+ # This software is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this software; if not, write to the Free
18
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20
+
21
+ require 'boxgrinder-core/validators/errors'
22
+
23
+ module BoxGrinder
24
+ class AWSValidator
25
+
26
+ def initialize( config )
27
+ @config = config
28
+ end
29
+
30
+ def validate_aws_config( config )
31
+ secure_permissions = "600"
32
+
33
+ raise ValidationError, "Please specify aws section in configuration file (#{@config.config_file}). #{DEFAULT_HELP_TEXT[:general]}" if config.nil?
34
+
35
+ raise ValidationError, "Please specify path to cert in aws section in configuration file (#{@config.config_file}). #{DEFAULT_HELP_TEXT[:general]}" if config['cert_file'].nil?
36
+ raise ValidationError, "Certificate file '#{config['cert_file']}' specified in configuration file (#{@config.config_file}) doesn't exists. Please check your path. #{DEFAULT_HELP_TEXT[:general]}" unless File.exists?( config['cert_file'] )
37
+ cert_permission = sprintf( "%o", File.stat( config['cert_file'] ).mode )[ 3, 5 ]
38
+ raise ValidationError, "Certificate file '#{config['cert_file']}' specified in aws section in configuration file (#{@config.config_file}) has wrong permissions (#{cert_permission}), please correct it, run: 'chmod #{secure_permissions} #{config['cert_file']}'." unless cert_permission.eql?( secure_permissions )
39
+
40
+ raise ValidationError, "Please specify path to private key in aws section in configuration file (#{@config.config_file}). #{DEFAULT_HELP_TEXT[:general]}" if config['key_file'].nil?
41
+ raise ValidationError, "Private key file '#{config['key_file']}' specified in aws section in configuration file (#{@config.config_file}) doesn't exists. Please check your path." unless File.exists?( config['key_file'] )
42
+ key_permission = sprintf( "%o", File.stat( config['key_file'] ).mode )[ 3, 5 ]
43
+ raise ValidationError, "Private key file '#{config['key_file']}' specified in aws section in configuration file (#{@config.config_file}) has wrong permissions (#{key_permission}), please correct it, run: 'chmod #{secure_permissions} #{config['key_file']}'." unless key_permission.eql?( secure_permissions )
44
+
45
+ raise ValidationError, "Please specify account number in aws section in configuration file (#{@config.config_file}). #{DEFAULT_HELP_TEXT[:general]}" if config['account_number'].nil?
46
+ raise ValidationError, "Please specify access key in aws section in configuration file (#{@config.config_file}). #{DEFAULT_HELP_TEXT[:general]}" if config['access_key'].nil?
47
+ raise ValidationError, "Please specify secret access key in aws section in configuration file (#{@config.config_file}). #{DEFAULT_HELP_TEXT[:general]}" if config['secret_access_key'].nil?
48
+ end
49
+
50
+ # TODO we're using this?
51
+ def validate_aws_release_config( config )
52
+ return if config.nil?
53
+
54
+ raise ValidationError, "No 's3' subsection in 'release' section in configuration file (#{@config.config_file})." if config['s3'].nil?
55
+ raise ValidationError, "Please specify bucket name in 's3' subsection in configuration file (#{@config.config_file})." if config['s3']['bucket_name'].nil? or config['s3']['bucket_name'].length == 0
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,67 @@
1
+ # JBoss, Home of Professional Open Source
2
+ # Copyright 2009, Red Hat Middleware LLC, and individual contributors
3
+ # by the @authors tag. See the copyright.txt in the distribution for a
4
+ # full listing of individual contributors.
5
+ #
6
+ # This is free software; you can redistribute it and/or modify it
7
+ # under the terms of the GNU Lesser General Public License as
8
+ # published by the Free Software Foundation; either version 2.1 of
9
+ # the License, or (at your option) any later version.
10
+ #
11
+ # This software is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this software; if not, write to the Free
18
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20
+
21
+ require 'boxgrinder-core/validators/errors'
22
+
23
+ module BoxGrinder
24
+ class ConfigValidator
25
+ def initialize( config, options = {} )
26
+ @config = config
27
+ @log = options[:log] || Logger.new(STDOUT)
28
+ end
29
+
30
+ def validate
31
+ validate_common
32
+ validate_vmware_files
33
+ validate_appliance_dir
34
+ end
35
+
36
+ def validate_common
37
+ secure_permissions = "600"
38
+
39
+ if File.exists?( @config.config_file )
40
+ conf_file_permissions = sprintf( "%o", File.stat( @config.config_file ).mode )[ 3, 5 ]
41
+ raise ValidationError, "Configuration file (#{@config.config_file}) has wrong permissions (#{conf_file_permissions}), please correct it, run: 'chmod #{secure_permissions} #{@config.config_file}'." unless conf_file_permissions.eql?( secure_permissions )
42
+ end
43
+ end
44
+
45
+ def validate_appliance_dir
46
+ raise ValidationError, "Appliances directory '#{@config.dir.appliances}' doesn't exists, please create it: 'mkdir -p #{@config.dir.appliances}'." if !File.exists?(File.dirname( @config.dir.appliances )) && !File.directory?(File.dirname( @config.dir.appliances ))
47
+ end
48
+
49
+ def validate_vmware_files
50
+ if File.exists?( "#{@config.dir.src}/base.vmdk" )
51
+ @config.files.base_vmdk = "#{@config.dir.src}/base.vmdk"
52
+ else
53
+ @config.files.base_vmdk = "#{@config.dir.base}/src/base.vmdk"
54
+ end
55
+
56
+ raise ValidationError, "base.vmdk file doesn't exists, please check you configuration)" unless File.exists?( @config.files.base_vmdk )
57
+
58
+ if File.exists?( "#{@config.dir.src}/base.vmx" )
59
+ @config.files.base_vmx = "#{@config.dir.src}/base.vmx"
60
+ else
61
+ @config.files.base_vmx = "#{@config.dir.base}/src/base.vmx"
62
+ end
63
+
64
+ raise ValidationError, "base.vmx file doesn't exists, please check you configuration)" unless File.exists?( @config.files.base_vmx )
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,35 @@
1
+ # JBoss, Home of Professional Open Source
2
+ # Copyright 2009, Red Hat Middleware LLC, and individual contributors
3
+ # by the @authors tag. See the copyright.txt in the distribution for a
4
+ # full listing of individual contributors.
5
+ #
6
+ # This is free software; you can redistribute it and/or modify it
7
+ # under the terms of the GNU Lesser General Public License as
8
+ # published by the Free Software Foundation; either version 2.1 of
9
+ # the License, or (at your option) any later version.
10
+ #
11
+ # This software is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this software; if not, write to the Free
18
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20
+
21
+ module BoxGrinder
22
+ class SSHValidator
23
+ def initialize( config )
24
+ @config = config
25
+ end
26
+
27
+ def validate
28
+ raise ValidationError, "Specified configuration file (#{@config.config_file}) doesn't exists. #{DEFAULT_HELP_TEXT[:general]}" unless File.exists?( @config.config_file )
29
+ raise ValidationError, "No 'ssh' section in config file in configuration file '#{@config.config_file}'. #{DEFAULT_HELP_TEXT[:general]}" if @config.data['ssh'].nil?
30
+ raise ValidationError, "Host not specified in configuration file '#{@config.config_file}'. #{DEFAULT_HELP_TEXT[:general]}" if @config.data['ssh']['host'].nil?
31
+ raise ValidationError, "Username not specified in configuration file '#{@config.config_file}'. #{DEFAULT_HELP_TEXT[:general]}" if @config.data['ssh']['username'].nil?
32
+ raise ValidationError, "Remote release packages path (remote_release_path) not specified in ssh section in configuration file '#{@config.config_file}'. #{DEFAULT_HELP_TEXT[:general]}" if @config.data['ssh']['remote_rpm_path'].nil?
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,91 @@
1
+ # JBoss, Home of Professional Open Source
2
+ # Copyright 2009, Red Hat Middleware LLC, and individual contributors
3
+ # by the @authors tag. See the copyright.txt in the distribution for a
4
+ # full listing of individual contributors.
5
+ #
6
+ # This is free software; you can redistribute it and/or modify it
7
+ # under the terms of the GNU Lesser General Public License as
8
+ # published by the Free Software Foundation; either version 2.1 of
9
+ # the License, or (at your option) any later version.
10
+ #
11
+ # This software is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this software; if not, write to the Free
18
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20
+
21
+ require 'boxgrinder-core/validators/errors'
22
+ require 'boxgrinder-build/validators/appliance-validator'
23
+ require 'boxgrinder-build/validators/config-validator'
24
+ require 'rake/tasklib'
25
+
26
+ module BoxGrinder
27
+ class Validator < Rake::TaskLib
28
+
29
+ def initialize( config, options = {} )
30
+ @config = config
31
+ @log = options[:log] || Logger.new(STDOUT)
32
+
33
+ define_tasks
34
+ end
35
+
36
+ def define_tasks
37
+
38
+ desc "Validate appliance files definitions"
39
+ task "validate:definitions" do
40
+ validate_definitions
41
+ end
42
+
43
+ desc "Validate configuration"
44
+ task "validate:config" do
45
+ validate_configuration
46
+ end
47
+
48
+ desc "Validate everything"
49
+ task "validate:all" => [ "validate:definitions", "validate:config" ]
50
+ end
51
+
52
+ def validate_definitions
53
+ @log.debug "Validating appliance definitions..."
54
+
55
+ begin
56
+ raise ValidationError, "Appliance directory '#{@config.dir.appliances}' doesn't exists, please check your Rakefile" if @config.dir.appliances.nil? or !File.exists?(File.dirname( @config.dir.appliances )) or !File.directory?(File.dirname( @config.dir.appliances ))
57
+
58
+ appliances = Dir[ "#{@config.dir.appliances}/*/*.appl" ]
59
+
60
+ appliances.each do |appliance_def|
61
+ ApplianceValidator.new( @config.dir.appliances, appliance_def ).validate
62
+ end
63
+
64
+ if appliances.size == 0
65
+ @log.debug "No appliance definitions found in '#{@config.dir.appliances}' directory"
66
+ else
67
+ @log.debug "All #{appliances.size} appliances definitions are valid"
68
+ end
69
+ rescue ApplianceValidationError => appliance_validation_error
70
+ raise "Error while validating appliance definition: #{appliance_validation_error}"
71
+ rescue ValidationError => validation_error
72
+ raise "Error while validating appliance definitions: #{validation_error}"
73
+ rescue => exception
74
+ raise "Something went wrong: #{exception}"
75
+ end
76
+ end
77
+
78
+ def validate_configuration
79
+ @log.debug "Validating configuration..."
80
+ begin
81
+ ConfigValidator.new( @config, :log => @log).validate
82
+ rescue ValidationError => validation_error
83
+ raise "Error while validating configuration: #{validation_error}"
84
+ rescue => exception
85
+ raise "Something went wrong: #{exception}"
86
+ end
87
+
88
+ @log.debug "Configuration is valid"
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # JBoss, Home of Professional Open Source
4
+ # Copyright 2009, Red Hat Middleware LLC, and individual contributors
5
+ # by the @authors tag. See the copyright.txt in the distribution for a
6
+ # full listing of individual contributors.
7
+ #
8
+ # This is free software; you can redistribute it and/or modify it
9
+ # under the terms of the GNU Lesser General Public License as
10
+ # published by the Free Software Foundation; either version 2.1 of
11
+ # the License, or (at your option) any later version.
12
+ #
13
+ # This software is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # Lesser General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public
19
+ # License along with this software; if not, write to the Free
20
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
22
+
23
+ require 'rubygems'
24
+
25
+ gem 'boxgrinder-core', '>= 0.0.1'
26
+ gem 'aws-s3', '>= 0.6.2'
27
+ gem 'amazon-ec2', '>= 0.9.6'
28
+ gem 'net-sftp', '>= 2.0.4'
29
+ gem 'net-ssh', '>= 2.0.20'
30
+ gem 'rake', '>= 0.8.7'
31
+
32
+ require 'boxgrinder-build/helpers/rake-helper'
33
+
34
+ begin
35
+ require 'rake'
36
+ rescue LoadError
37
+ require 'rubygems'
38
+ require 'rake'
39
+ end
40
+
41
+ task :default do
42
+ puts "Run '#{Rake.application.name} -T' to get list of all available commands."
43
+ end
44
+
45
+ BoxGrinder::RakeHelper.new
46
+
47
+ Rake.application.init('boxgrinder')
48
+ Rake.application.top_level
@@ -0,0 +1,236 @@
1
+ #
2
+ # Ruby/ProgressBar - a text progress bar library
3
+ #
4
+ # Copyright (C) 2001-2005 Satoru Takabayashi <satoru@namazu.org>
5
+ # All rights reserved.
6
+ # This is free software with ABSOLUTELY NO WARRANTY.
7
+ #
8
+ # You can redistribute it and/or modify it under the terms
9
+ # of Ruby's license.
10
+ #
11
+
12
+ class ProgressBar
13
+ VERSION = "0.9"
14
+
15
+ def initialize (title, total, out = STDERR)
16
+ @title = title
17
+ @total = total
18
+ @out = out
19
+ @terminal_width = 80
20
+ @bar_mark = "o"
21
+ @current = 0
22
+ @previous = 0
23
+ @finished_p = false
24
+ @start_time = Time.now
25
+ @previous_time = @start_time
26
+ @title_width = 14
27
+ @format = "%-#{@title_width}s %3d%% %s %s"
28
+ @format_arguments = [:title, :percentage, :bar, :stat]
29
+ clear
30
+ show
31
+ end
32
+ attr_reader :title
33
+ attr_reader :current
34
+ attr_reader :total
35
+ attr_accessor :start_time
36
+
37
+ private
38
+ def fmt_bar
39
+ bar_width = do_percentage * @terminal_width / 100
40
+ sprintf("|%s%s|",
41
+ @bar_mark * bar_width,
42
+ " " * (@terminal_width - bar_width))
43
+ end
44
+
45
+ def fmt_percentage
46
+ do_percentage
47
+ end
48
+
49
+ def fmt_stat
50
+ if @finished_p then elapsed else eta end
51
+ end
52
+
53
+ def fmt_stat_for_file_transfer
54
+ if @finished_p then
55
+ sprintf("%s %s %s", bytes, transfer_rate, elapsed)
56
+ else
57
+ sprintf("%s %s %s", bytes, transfer_rate, eta)
58
+ end
59
+ end
60
+
61
+ def fmt_title
62
+ @title[0,(@title_width - 1)] + ":"
63
+ end
64
+
65
+ def convert_bytes (bytes)
66
+ if bytes < 1024
67
+ sprintf("%6dB", bytes)
68
+ elsif bytes < 1024 * 1000 # 1000kb
69
+ sprintf("%5.1fKB", bytes.to_f / 1024)
70
+ elsif bytes < 1024 * 1024 * 1000 # 1000mb
71
+ sprintf("%5.1fMB", bytes.to_f / 1024 / 1024)
72
+ else
73
+ sprintf("%5.1fGB", bytes.to_f / 1024 / 1024 / 1024)
74
+ end
75
+ end
76
+
77
+ def transfer_rate
78
+ bytes_per_second = @current.to_f / (Time.now - @start_time)
79
+ sprintf("%s/s", convert_bytes(bytes_per_second))
80
+ end
81
+
82
+ def bytes
83
+ convert_bytes(@current)
84
+ end
85
+
86
+ def format_time (t)
87
+ t = t.to_i
88
+ sec = t % 60
89
+ min = (t / 60) % 60
90
+ hour = t / 3600
91
+ sprintf("%02d:%02d:%02d", hour, min, sec);
92
+ end
93
+
94
+ # ETA stands for Estimated Time of Arrival.
95
+ def eta
96
+ if @current == 0
97
+ "ETA: --:--:--"
98
+ else
99
+ elapsed = Time.now - @start_time
100
+ eta = elapsed * @total / @current - elapsed;
101
+ sprintf("ETA: %s", format_time(eta))
102
+ end
103
+ end
104
+
105
+ def elapsed
106
+ elapsed = Time.now - @start_time
107
+ sprintf("Time: %s", format_time(elapsed))
108
+ end
109
+
110
+ def eol
111
+ if @finished_p then "\n" else "\r" end
112
+ end
113
+
114
+ def do_percentage
115
+ if @total.zero?
116
+ 100
117
+ else
118
+ @current * 100 / @total
119
+ end
120
+ end
121
+
122
+ def get_width
123
+ # FIXME: I don't know how portable it is.
124
+ default_width = 80
125
+ begin
126
+ tiocgwinsz = 0x5413
127
+ data = [0, 0, 0, 0].pack("SSSS")
128
+ if @out.ioctl(tiocgwinsz, data) >= 0 then
129
+ rows, cols, xpixels, ypixels = data.unpack("SSSS")
130
+ if cols >= 0 then cols else default_width end
131
+ else
132
+ default_width
133
+ end
134
+ rescue Exception
135
+ default_width
136
+ end
137
+ end
138
+
139
+ def show
140
+ arguments = @format_arguments.map {|method|
141
+ method = sprintf("fmt_%s", method)
142
+ send(method)
143
+ }
144
+ line = sprintf(@format, *arguments)
145
+
146
+ width = get_width
147
+ if line.length == width - 1
148
+ @out.print(line + eol)
149
+ @out.flush
150
+ elsif line.length >= width
151
+ @terminal_width = [@terminal_width - (line.length - width + 1), 0].max
152
+ if @terminal_width == 0 then @out.print(line + eol) else show end
153
+ else # line.length < width - 1
154
+ @terminal_width += width - line.length + 1
155
+ show
156
+ end
157
+ @previous_time = Time.now
158
+ end
159
+
160
+ def show_if_needed
161
+ if @total.zero?
162
+ cur_percentage = 100
163
+ prev_percentage = 0
164
+ else
165
+ cur_percentage = (@current * 100 / @total).to_i
166
+ prev_percentage = (@previous * 100 / @total).to_i
167
+ end
168
+
169
+ # Use "!=" instead of ">" to support negative changes
170
+ if cur_percentage != prev_percentage ||
171
+ Time.now - @previous_time >= 1 || @finished_p
172
+ show
173
+ end
174
+ end
175
+
176
+ public
177
+ def clear
178
+ @out.print "\r"
179
+ @out.print(" " * (get_width - 1))
180
+ @out.print "\r"
181
+ end
182
+
183
+ def finish
184
+ @current = @total
185
+ @finished_p = true
186
+ show
187
+ end
188
+
189
+ def finished?
190
+ @finished_p
191
+ end
192
+
193
+ def file_transfer_mode
194
+ @format_arguments = [:title, :percentage, :bar, :stat_for_file_transfer]
195
+ end
196
+
197
+ def format= (format)
198
+ @format = format
199
+ end
200
+
201
+ def format_arguments= (arguments)
202
+ @format_arguments = arguments
203
+ end
204
+
205
+ def halt
206
+ @finished_p = true
207
+ show
208
+ end
209
+
210
+ def inc (step = 1)
211
+ @current += step
212
+ @current = @total if @current > @total
213
+ show_if_needed
214
+ @previous = @current
215
+ end
216
+
217
+ def set (count)
218
+ if count < 0 || count > @total
219
+ raise "invalid count: #{count} (total: #{@total})"
220
+ end
221
+ @current = count
222
+ show_if_needed
223
+ @previous = @current
224
+ end
225
+
226
+ def inspect
227
+ "#<ProgressBar:#{@current}/#{@total}>"
228
+ end
229
+ end
230
+
231
+ class ReversedProgressBar < ProgressBar
232
+ def do_percentage
233
+ 100 - super
234
+ end
235
+ end
236
+
data/src/README.vmware ADDED
@@ -0,0 +1,38 @@
1
+ #NAME# version #VERSION#
2
+
3
+ This package contains #APPLIANCE_NAME# image for VMware.
4
+
5
+ VMware Personal (VMware Fusion, VMware Server, VMware Player)
6
+ =============================================================
7
+
8
+ Required files:
9
+ ---------------
10
+
11
+ #APPLIANCE_NAME#-sda.raw
12
+ personal/#APPLIANCE_NAME#.vmx
13
+ personal/#APPLIANCE_NAME#.vmdk
14
+
15
+ Required steps:
16
+ ---------------
17
+
18
+ 1. Extract #APPLIANCE_NAME#-sda.raw file and all files from personal/ directory into one directory.
19
+ 2. Add #APPLIANCE_NAME#.vmx to inventory.
20
+ 3. Run appliance.
21
+
22
+ VMware Enterprise (VMware ESX/ESXi/, VMware vSphere)
23
+ ====================================================
24
+
25
+ Required files:
26
+ ---------------
27
+
28
+ #APPLIANCE_NAME#-sda.raw
29
+ enterprise/#APPLIANCE_NAME#.vmx
30
+ enterprise/#APPLIANCE_NAME#.vmdk
31
+
32
+ Required steps:
33
+ ---------------
34
+
35
+ 1. Extract #APPLIANCE_NAME#-sda.raw file and all files from enterprise/ directory into one directory.
36
+ 2. Upload all files to ESX server using vSpehere/VI client.
37
+ 3. Add #APPLIANCE_NAME#.vmx to inventory.
38
+ 4. Run appliance.
data/src/base.repo ADDED
@@ -0,0 +1,4 @@
1
+ [#NAME#]
2
+ name=#NAME#
3
+ enabled=1
4
+ gpgcheck=0
data/src/base.vmdk ADDED
@@ -0,0 +1,19 @@
1
+ # Disk DescriptorFile
2
+ version=1
3
+ CID=fffffffe
4
+ parentCID=ffffffff
5
+ createType="#TYPE#"
6
+
7
+ # Extent description
8
+ RW #TOTAL_SECTORS# #EXTENT_TYPE# "#NAME#-sda.raw" #NUMBER#
9
+
10
+ # The Disk Data Base
11
+ #DDB
12
+
13
+ ddb.toolsVersion = "0"
14
+ ddb.adapterType = "lsilogic"
15
+ ddb.geometry.sectors = "#SECTORS#"
16
+ ddb.geometry.heads = "#HEADS#"
17
+ ddb.geometry.cylinders = "#CYLINDERS#"
18
+ ddb.encoding = "UTF-8"
19
+ ddb.virtualHWVersion = "#HW_VERSION#"
data/src/base.vmx ADDED
@@ -0,0 +1,45 @@
1
+
2
+ #!/usr/bin/vmware
3
+
4
+ config.version = "8"
5
+ virtualHW.version = "4"
6
+ guestOS = "#GUESTOS#"
7
+ displayName = "#NAME#"
8
+ annotation = "#SUMMARY# | Version: #VERSION# | Built by: #BUILDER#"
9
+ guestinfo.vmware.product.long = "#NAME#"
10
+ guestinfo.vmware.product.url = "http://www.jboss.org/stormgrind/projects/boxgrinder.html"
11
+ guestinfo.vmware.product.class = "virtual machine"
12
+ numvcpus = "#VCPU#"
13
+ memsize = "#MEM_SIZE#"
14
+ MemAllowAutoScaleDown = "FALSE"
15
+ MemTrimRate = "-1"
16
+ uuid.action = "create"
17
+ tools.remindInstall = "TRUE"
18
+ hints.hideAll = "TRUE"
19
+ tools.syncTime = "TRUE"
20
+ serial0.present = "FALSE"
21
+ serial1.present = "FALSE"
22
+ parallel0.present = "FALSE"
23
+ logging = "TRUE"
24
+ log.fileName = "#NAME#.log"
25
+ log.append = "TRUE"
26
+ log.keepOld = "3"
27
+ isolation.tools.hgfs.disable = "FALSE"
28
+ isolation.tools.dnd.disable = "FALSE"
29
+ isolation.tools.copy.enable = "TRUE"
30
+ isolation.tools.paste.enabled = "TRUE"
31
+ floppy0.present = "FALSE"
32
+
33
+ scsi0:0.present = "TRUE"
34
+ scsi0:0.fileName = "#NAME#.vmdk"
35
+ scsi0:0.mode = "persistent"
36
+ scsi0:0.startConnected = "TRUE"
37
+ scsi0:0.writeThrough = "TRUE"
38
+ scsi0.present = "TRUE"
39
+ scsi0.virtualDev = "lsilogic"
40
+
41
+ ethernet0.present = "TRUE"
42
+ ethernet0.connectionType = "nat"
43
+ ethernet0.addressType = "generated"
44
+ ethernet0.generatedAddressOffset = "0"
45
+ ethernet0.autoDetect = "TRUE"
@@ -0,0 +1,8 @@
1
+ /dev/sda1 / ext3 defaults 1 1
2
+ /dev/sda2 /mnt ext3 defaults 1 2
3
+ /dev/sda3 swap swap defaults 0 0
4
+ none /dev/pts devpts gid=5,mode=620 0 0
5
+ none /dev/shm tmpfs defaults 0 0
6
+ none /proc proc defaults 0 0
7
+ none /sys sysfs defaults 0 0
8
+
@@ -0,0 +1,8 @@
1
+ /dev/sda1 / ext3 defaults 1 1
2
+ /dev/sdb /mnt ext3 defaults 0 0
3
+ /dev/sdc /data ext3 defaults 0 0
4
+ none /dev/pts devpts gid=5,mode=620 0 0
5
+ none /dev/shm tmpfs defaults 0 0
6
+ none /proc proc defaults 0 0
7
+ none /sys sysfs defaults 0 0
8
+
@@ -0,0 +1,7 @@
1
+ DEVICE=eth0
2
+ BOOTPROTO=dhcp
3
+ ONBOOT=yes
4
+ TYPE=Ethernet
5
+ USERCTL=yes
6
+ PEERDNS=yes
7
+ IPV6INIT=no