boxgrinder-build 0.4.1 → 0.5.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 +7 -0
- data/Manifest +0 -0
- data/Rakefile +11 -0
- data/bin/boxgrinder-build +33 -27
- data/boxgrinder-build.gemspec +38 -0
- data/lib/boxgrinder-build/appliance.rb +32 -41
- data/lib/boxgrinder-build/helpers/appliance-customize-helper.rb +3 -48
- data/lib/boxgrinder-build/helpers/guestfs-helper.rb +98 -12
- data/lib/boxgrinder-build/helpers/linux-helper.rb +69 -0
- data/lib/boxgrinder-build/helpers/package-helper.rb +20 -11
- data/lib/boxgrinder-build/helpers/plugin-helper.rb +32 -32
- data/lib/boxgrinder-build/managers/plugin-manager.rb +98 -0
- data/lib/boxgrinder-build/plugins/base-plugin.rb +70 -17
- data/spec/Rakefile +13 -0
- data/spec/appliance-spec.rb +195 -0
- data/spec/helpers/appliance-customize-helper-spec.rb +30 -0
- data/spec/helpers/guestfs-helper-spec.rb +129 -0
- data/spec/helpers/linux-helper-spec.rb +50 -0
- data/spec/helpers/package-helper-spec.rb +6 -0
- data/spec/helpers/plugin-helper-spec.rb +63 -0
- data/spec/managers/plugin-manager-spec.rb +27 -0
- data/spec/plugins/base-plugin-spec.rb +89 -0
- data/spec/rspec/src/appliances/jeos-f13.appl +27 -0
- metadata +60 -157
- data/docs/examples/appliances/appliances.appl +0 -5
- data/docs/examples/appliances/minimal.appl +0 -9
- data/docs/examples/appliances/mix.appl +0 -8
- data/docs/examples/appliances/packages.appl +0 -13
- data/docs/node-info/pom.xml +0 -31
- data/docs/node-info/src/main/webapp/META-INF/MANIFEST.MF +0 -3
- data/docs/node-info/src/main/webapp/WEB-INF/web.xml +0 -7
- data/docs/node-info/src/main/webapp/index.jsp +0 -70
- data/lib/boxgrinder-build/helpers/rake-helper.rb +0 -71
- data/lib/boxgrinder-build/managers/base-plugin-manager.rb +0 -62
- data/lib/boxgrinder-build/managers/delivery-plugin-manager.rb +0 -39
- data/lib/boxgrinder-build/managers/operating-system-plugin-manager.rb +0 -6
- data/lib/boxgrinder-build/managers/platform-plugin-manager.rb +0 -26
- data/lib/boxgrinder-build/plugins/delivery/base/base-delivery-plugin.rb +0 -43
- data/lib/boxgrinder-build/plugins/delivery/local/local-plugin.rb +0 -57
- data/lib/boxgrinder-build/plugins/delivery/s3/aws-helper.rb +0 -64
- data/lib/boxgrinder-build/plugins/delivery/s3/s3-plugin.rb +0 -190
- data/lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb +0 -159
- data/lib/boxgrinder-build/plugins/os/base/kickstart.rb +0 -148
- data/lib/boxgrinder-build/plugins/os/base/rhel-based-os-plugin.rb +0 -51
- data/lib/boxgrinder-build/plugins/os/base/rpm-based-os-plugin.rb +0 -134
- data/lib/boxgrinder-build/plugins/os/base/src/appliance.ks.erb +0 -41
- data/lib/boxgrinder-build/plugins/os/base/src/base.repo +0 -4
- data/lib/boxgrinder-build/plugins/os/base/src/motd.init +0 -21
- data/lib/boxgrinder-build/plugins/os/base/validators/rpm-dependency-validator.rb +0 -162
- data/lib/boxgrinder-build/plugins/os/base-operating-system-plugin.rb +0 -37
- data/lib/boxgrinder-build/plugins/os/centos/centos-plugin.rb +0 -52
- data/lib/boxgrinder-build/plugins/os/fedora/fedora-plugin.rb +0 -74
- data/lib/boxgrinder-build/plugins/os/rhel/rhel-plugin.rb +0 -40
- data/lib/boxgrinder-build/plugins/platform/base-platform-plugin.rb +0 -37
- data/lib/boxgrinder-build/plugins/platform/ec2/ec2-plugin.rb +0 -332
- data/lib/boxgrinder-build/plugins/platform/ec2/src/f12/yum.conf +0 -24
- data/lib/boxgrinder-build/plugins/platform/ec2/src/f12-i386-boxgrinder.repo +0 -11
- data/lib/boxgrinder-build/plugins/platform/ec2/src/f12-x86_64-boxgrinder.repo +0 -11
- data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_32bit +0 -8
- data/lib/boxgrinder-build/plugins/platform/ec2/src/fstab_64bit +0 -8
- data/lib/boxgrinder-build/plugins/platform/ec2/src/ifcfg-eth0 +0 -7
- data/lib/boxgrinder-build/plugins/platform/ec2/src/rc_local +0 -29
- data/lib/boxgrinder-build/plugins/platform/vmware/src/README +0 -42
- data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmdk +0 -19
- data/lib/boxgrinder-build/plugins/platform/vmware/src/base.vmx +0 -45
- data/lib/boxgrinder-build/plugins/platform/vmware/vmware-plugin.rb +0 -181
- data/lib/boxgrinder-build/validators/appliance-config-parameter-validator.rb +0 -37
- data/lib/boxgrinder-build/validators/appliance-validator.rb +0 -84
- data/lib/boxgrinder-build/validators/config-validator.rb +0 -48
- data/lib/boxgrinder-build/validators/ssh-validator.rb +0 -35
- data/lib/boxgrinder-build/validators/validator.rb +0 -91
@@ -1,181 +0,0 @@
|
|
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-build/plugins/platform/base-platform-plugin'
|
22
|
-
require 'boxgrinder-build/helpers/appliance-customize-helper'
|
23
|
-
|
24
|
-
module BoxGrinder
|
25
|
-
class VMwarePlugin < BasePlatformPlugin
|
26
|
-
def info
|
27
|
-
{
|
28
|
-
:name => :vmware,
|
29
|
-
:full_name => "VMware"
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def after_init
|
34
|
-
@deliverables[:disk] = "#{@appliance_config.path.dir.build}/vmware/#{@appliance_config.name}.raw"
|
35
|
-
|
36
|
-
@deliverables[:metadata] = {
|
37
|
-
:vmx_enterprise => "#{@appliance_config.path.dir.build}/vmware/#{@appliance_config.name}-enterprise.vmx",
|
38
|
-
:vmdk_enterprise => "#{@appliance_config.path.dir.build}/vmware/#{@appliance_config.name}-enterprise.vmdk",
|
39
|
-
:vmx_personal => "#{@appliance_config.path.dir.build}/vmware/#{@appliance_config.name}-personal.vmx",
|
40
|
-
:vmdk_personal => "#{@appliance_config.path.dir.build}/vmware/#{@appliance_config.name}-personal.vmdk"
|
41
|
-
}
|
42
|
-
|
43
|
-
@deliverables[:other] = {
|
44
|
-
:readme => "#{@appliance_config.path.dir.build}/vmware/README"
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
def execute( base_image_path )
|
50
|
-
@log.info "Converting image to VMware format..."
|
51
|
-
@log.debug "Copying VMware image file, this may take several minutes..."
|
52
|
-
|
53
|
-
FileUtils.mkdir_p File.dirname( @deliverables[:disk] )
|
54
|
-
|
55
|
-
@exec_helper.execute "cp #{base_image_path} #{@deliverables[:disk]}" if ( !File.exists?( @deliverables[:disk] ) || File.new( base_image_path ).mtime > File.new( @deliverables[:disk] ).mtime )
|
56
|
-
|
57
|
-
@log.debug "VMware image copied."
|
58
|
-
|
59
|
-
unless @appliance_config.post['vmware'].nil?
|
60
|
-
customize( @deliverables[:disk] ) do |guestfs, guestfs_helper|
|
61
|
-
@appliance_config.post['vmware'].each do |cmd|
|
62
|
-
@log.debug "Executing #{cmd}"
|
63
|
-
guestfs.sh( cmd )
|
64
|
-
end
|
65
|
-
@log.debug "Post commands from appliance definition file executed."
|
66
|
-
end
|
67
|
-
else
|
68
|
-
@log.debug "No commands specified, skipping."
|
69
|
-
end
|
70
|
-
|
71
|
-
build_vmware_enterprise
|
72
|
-
build_vmware_personal
|
73
|
-
|
74
|
-
readme = File.open( "#{File.dirname(__FILE__)}/src/README" ).read
|
75
|
-
readme.gsub!( /#APPLIANCE_NAME#/, @appliance_config.name )
|
76
|
-
readme.gsub!( /#NAME#/, @config.name )
|
77
|
-
readme.gsub!( /#VERSION#/, @config.version_with_release )
|
78
|
-
|
79
|
-
File.open( @deliverables[:other][:readme], "w") {|f| f.write( readme ) }
|
80
|
-
|
81
|
-
@log.info "Image converted to VMware format."
|
82
|
-
end
|
83
|
-
|
84
|
-
# returns value of cylinders, heads and sector for selected disk size (in GB)
|
85
|
-
|
86
|
-
def generate_scsi_chs(disk_size)
|
87
|
-
disk_size = (disk_size * 1024).to_i
|
88
|
-
|
89
|
-
gb_sectors = 2097152
|
90
|
-
|
91
|
-
if disk_size <= 1024
|
92
|
-
h = 128
|
93
|
-
s = 32
|
94
|
-
else
|
95
|
-
h = 255
|
96
|
-
s = 63
|
97
|
-
end
|
98
|
-
|
99
|
-
c = disk_size / 1024 * gb_sectors / (h*s)
|
100
|
-
total_sectors = gb_sectors * disk_size / 1024
|
101
|
-
|
102
|
-
return [ c, h, s, total_sectors ]
|
103
|
-
end
|
104
|
-
|
105
|
-
def change_vmdk_values( type )
|
106
|
-
vmdk_data = File.open( "#{File.dirname( __FILE__ )}/src/base.vmdk" ).read
|
107
|
-
|
108
|
-
disk_size = 0.0
|
109
|
-
@appliance_config.hardware.partitions.values.each { |part| disk_size += part['size'].to_f }
|
110
|
-
|
111
|
-
c, h, s, total_sectors = generate_scsi_chs( disk_size )
|
112
|
-
|
113
|
-
is_enterprise = type.eql?("vmfs")
|
114
|
-
|
115
|
-
vmdk_data.gsub!( /#NAME#/, @appliance_config.name )
|
116
|
-
vmdk_data.gsub!( /#TYPE#/, type )
|
117
|
-
vmdk_data.gsub!( /#EXTENT_TYPE#/, is_enterprise ? "VMFS" : "FLAT" )
|
118
|
-
vmdk_data.gsub!( /#NUMBER#/, is_enterprise ? "" : "0" )
|
119
|
-
vmdk_data.gsub!( /#HW_VERSION#/, is_enterprise ? "4" : "3" )
|
120
|
-
vmdk_data.gsub!( /#CYLINDERS#/, c.to_s )
|
121
|
-
vmdk_data.gsub!( /#HEADS#/, h.to_s )
|
122
|
-
vmdk_data.gsub!( /#SECTORS#/, s.to_s )
|
123
|
-
vmdk_data.gsub!( /#TOTAL_SECTORS#/, total_sectors.to_s )
|
124
|
-
|
125
|
-
vmdk_data
|
126
|
-
end
|
127
|
-
|
128
|
-
def change_common_vmx_values
|
129
|
-
vmx_data = File.open( "#{File.dirname( __FILE__ )}/src/base.vmx" ).read
|
130
|
-
|
131
|
-
# replace version with current appliance version
|
132
|
-
vmx_data.gsub!( /#VERSION#/, "#{@appliance_config.version}.#{@appliance_config.release}" )
|
133
|
-
# replace builder with current builder name and version
|
134
|
-
vmx_data.gsub!( /#BUILDER#/, "#{@config.name} #{@config.version_with_release}" )
|
135
|
-
# change name
|
136
|
-
vmx_data.gsub!( /#NAME#/, @appliance_config.name.to_s )
|
137
|
-
# and summary
|
138
|
-
vmx_data.gsub!( /#SUMMARY#/, @appliance_config.summary.to_s )
|
139
|
-
# replace guestOS informations to: linux or otherlinux-64, this seems to be the savests values
|
140
|
-
vmx_data.gsub!( /#GUESTOS#/, "#{@appliance_config.hardware.arch == "x86_64" ? "otherlinux-64" : "linux"}" )
|
141
|
-
# memory size
|
142
|
-
vmx_data.gsub!( /#MEM_SIZE#/, @appliance_config.hardware.memory.to_s )
|
143
|
-
# memory size
|
144
|
-
vmx_data.gsub!( /#VCPU#/, @appliance_config.hardware.cpus.to_s )
|
145
|
-
# network name
|
146
|
-
# vmx_data.gsub!( /#NETWORK_NAME#/, @image_config.network_name )
|
147
|
-
|
148
|
-
vmx_data
|
149
|
-
end
|
150
|
-
|
151
|
-
def build_vmware_personal
|
152
|
-
@log.debug "Building VMware personal image."
|
153
|
-
|
154
|
-
# create .vmx file
|
155
|
-
File.open( @deliverables[:metadata][:vmx_personal], "w" ) {|f| f.write( change_common_vmx_values ) }
|
156
|
-
|
157
|
-
# create disk descriptor file
|
158
|
-
File.open( @deliverables[:metadata][:vmdk_personal], "w" ) {|f| f.write( change_vmdk_values( "monolithicFlat" ) ) }
|
159
|
-
|
160
|
-
@log.debug "VMware personal image was built."
|
161
|
-
end
|
162
|
-
|
163
|
-
def build_vmware_enterprise
|
164
|
-
@log.debug "Building VMware enterprise image."
|
165
|
-
|
166
|
-
# defaults for ESXi (maybe for others too)
|
167
|
-
@appliance_config.hardware.network = "VM Network" if @appliance_config.hardware.network.eql?( "NAT" )
|
168
|
-
|
169
|
-
# create .vmx file
|
170
|
-
vmx_data = change_common_vmx_values
|
171
|
-
vmx_data += "ethernet0.networkName = \"#{@appliance_config.hardware.network}\""
|
172
|
-
|
173
|
-
File.open( @deliverables[:metadata][:vmx_enterprise], "w" ) {|f| f.write( vmx_data ) }
|
174
|
-
|
175
|
-
# create disk descriptor file
|
176
|
-
File.open( @deliverables[:metadata][:vmdk_enterprise], "w" ) {|f| f.write( change_vmdk_values( "vmfs" ) ) }
|
177
|
-
|
178
|
-
@log.debug "VMware enterprise image was built."
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
@@ -1,37 +0,0 @@
|
|
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 ApplianceConfigParameterValidator
|
25
|
-
def validate
|
26
|
-
raise ValidationError, "'#{ENV['BG_HARDWARE_ARCH']}' is not a valid build architecture. Available architectures: #{SUPPORTED_ARCHES.join(", ")}." if (!ENV['BG_HARDWARE_ARCH'].nil? and !SUPPORTED_ARCHES.include?( ENV['BG_HARDWARE_ARCH']))
|
27
|
-
raise ValidationError, "'#{ENV['BG_OS_NAME']}' is not a valid OS name. Please enter valid name." if !ENV['BG_OS_NAME'].nil? && !SUPPORTED_OSES.keys.include?( ENV['BG_OS_NAME'] )
|
28
|
-
|
29
|
-
os_name = ENV['BG_OS_NAME'].nil? ? APPLIANCE_DEFAULTS[:os][:name] : ENV['BG_OS_NAME']
|
30
|
-
|
31
|
-
raise ValidationError, "'#{ENV['BG_OS_VERSION']}' is not a valid OS version for #{os_name}. Please enter valid version." if !ENV['BG_OS_VERSION'].nil? && !SUPPORTED_OSES[os_name].include?( ENV['BG_OS_VERSION'] )
|
32
|
-
raise ValidationError, "'#{ENV['BG_HARDWARE_DISK_SIZE']}' is not a valid disk size. Please enter valid size in GB." if !ENV['BG_HARDWARE_DISK_SIZE'].nil? && ENV['BG_HARDWARE_DISK_SIZE'].to_i == 0
|
33
|
-
raise ValidationError, "'#{ENV['BG_HARDWARE_MEM_SIZE']}' is not a valid memory size. Please enter valid size in MB." if !ENV['BG_HARDWARE_MEM_SIZE'].nil? && ENV['BG_HARDWARE_MEM_SIZE'].to_i == 0
|
34
|
-
raise ValidationError, "'#{ENV['BG_HARDWARE_CPUS']}' is not a valid virtual cpu amount. Please enter valid amount." if !ENV['BG_HARDWARE_CPUS'].nil? && ENV['BG_HARDWARE_CPUS'].to_i == 0
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,84 +0,0 @@
|
|
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 'yaml'
|
23
|
-
|
24
|
-
module BoxGrinder
|
25
|
-
class ApplianceValidator
|
26
|
-
def initialize( dir_appliances, appliance_def, options = {} )
|
27
|
-
@dir_appliances = dir_appliances
|
28
|
-
|
29
|
-
@log = options[:log] || Logger.new(STDOUT)
|
30
|
-
@exec_helper = options[:exec_helper] || ExecHelper.new( { :log => @log } )
|
31
|
-
|
32
|
-
#check if appliance_def is nil
|
33
|
-
raise ApplianceValidationError, "Appliance definition file must be specified" if appliance_def.nil? or appliance_def.length == 0
|
34
|
-
|
35
|
-
@appliance_name = File.basename( appliance_def, '.appl' )
|
36
|
-
|
37
|
-
# check if file exists
|
38
|
-
raise ApplianceValidationError, "Appliance definition file for '#{@appliance_name}' doesn't exists" unless File.exists?( appliance_def )
|
39
|
-
|
40
|
-
@appliance_def = appliance_def
|
41
|
-
end
|
42
|
-
|
43
|
-
def validate
|
44
|
-
@definition = YAML.load_file( @appliance_def )
|
45
|
-
# check for summary
|
46
|
-
raise ApplianceValidationError, "Appliance definition file for '#{@appliance_name}' should have summary" if @definition['summary'].nil? or @definition['summary'].length == 0
|
47
|
-
# check if selected desktop type is supported
|
48
|
-
raise ApplianceValidationError, "Selected desktop type ('#{@definition['desktop']}') isn't supported. Supported desktop types: #{SUPPORTED_DESKTOP_TYPES.join( "," )}" if !@definition['desktop'].nil? and !SUPPORTED_DESKTOP_TYPES.include?( @definition['desktop'] )
|
49
|
-
# check if all dependent appliances exists
|
50
|
-
#appliances, valid = get_appliances(@appliance_name)
|
51
|
-
#raise ApplianceValidationError, "Could not find all dependent appliances for multiappliance '#{@appliance_name}'" unless valid
|
52
|
-
# check appliance count
|
53
|
-
#raise ApplianceValidationError, "Invalid appliance count for appliance '#{@appliance_name}'" unless appliances.size >= 1
|
54
|
-
end
|
55
|
-
|
56
|
-
protected
|
57
|
-
|
58
|
-
def get_appliances( appliance_name )
|
59
|
-
appliances = Array.new
|
60
|
-
valid = true
|
61
|
-
|
62
|
-
appliance_def = "#{@dir_appliances}/#{appliance_name}/#{appliance_name}.appl"
|
63
|
-
|
64
|
-
unless File.exists?( appliance_def )
|
65
|
-
@log.info "Appliance configuration file for '#{appliance_name}' doesn't exists, please check your config files."
|
66
|
-
return false
|
67
|
-
end
|
68
|
-
|
69
|
-
appliances_read = YAML.load_file( appliance_def )['appliances']
|
70
|
-
|
71
|
-
appliances_read.each do |appl|
|
72
|
-
appls, v = get_appliances( appl )
|
73
|
-
|
74
|
-
appliances += appls if v
|
75
|
-
valid = false unless v
|
76
|
-
end unless appliances_read.nil? or appliances_read.empty?
|
77
|
-
|
78
|
-
appliances.push( appliance_name )
|
79
|
-
|
80
|
-
[ appliances, valid ]
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
@@ -1,48 +0,0 @@
|
|
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_appliance_dir
|
33
|
-
end
|
34
|
-
|
35
|
-
def validate_common
|
36
|
-
secure_permissions = "600"
|
37
|
-
|
38
|
-
if File.exists?( @config.config_file )
|
39
|
-
conf_file_permissions = sprintf( "%o", File.stat( @config.config_file ).mode )[ 3, 5 ]
|
40
|
-
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 )
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def validate_appliance_dir
|
45
|
-
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 ))
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,35 +0,0 @@
|
|
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
|
@@ -1,91 +0,0 @@
|
|
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
|