boxgrinder-core 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Rakefile +0 -22
- data/boxgrinder-core.gemspec +4 -4
- data/lib/boxgrinder-core/helpers/appliance-helper.rb +33 -33
- data/lib/boxgrinder-core/validators/appliance-config-validator.rb +9 -15
- data/rubygem-boxgrinder-core.spec +5 -2
- metadata +4 -7
- data/lib/boxgrinder-core/helpers/queue-helper.rb +0 -52
- data/spec/helpers/queue-helper-spec.rb +0 -24
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -19,7 +19,6 @@
|
|
19
19
|
require 'rubygems'
|
20
20
|
require 'spec/rake/spectask'
|
21
21
|
require 'echoe'
|
22
|
-
require 'rbconfig'
|
23
22
|
|
24
23
|
Echoe.new("boxgrinder-core") do |p|
|
25
24
|
p.project = "BoxGrinder"
|
@@ -46,24 +45,3 @@ Spec::Rake::SpecTask.new('spec:coverage') do |t|
|
|
46
45
|
t.rcov_opts = ['--exclude', 'spec,teamcity/*,/usr/lib/ruby/,.gem/ruby,/boxgrinder-build/,/gems/']
|
47
46
|
t.verbose = true
|
48
47
|
end
|
49
|
-
|
50
|
-
desc "Create RPM"
|
51
|
-
task :rpm, :target, :version, :arch, :needs => ['clean', 'gem'] do |t, args|
|
52
|
-
target = args[:target] || 'fedora'
|
53
|
-
version = args[:version] || 'rawhide'
|
54
|
-
arch = args[:arch] || RbConfig::CONFIG['host_cpu']
|
55
|
-
|
56
|
-
Dir["**/rubygem-*.spec"].each do |spec|
|
57
|
-
`mock -v -r #{target}-#{version}-#{arch} --buildsrpm --sources pkg/*.gem --spec #{spec} --resultdir pkg/`
|
58
|
-
exit 1 unless $? == 0
|
59
|
-
`mock -v -r #{target}-#{version}-#{arch} --rebuild pkg/*.rpm --resultdir pkg/`
|
60
|
-
exit 1 unless $? == 0
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
desc "Install RPM"
|
65
|
-
task 'rpm:install' => [:rpm] do
|
66
|
-
system "sudo yum -y remove rubygem-boxgrinder-core"
|
67
|
-
system "sudo yum -y localinstall --nogpgcheck pkg/*.rpm"
|
68
|
-
exit 1 unless $? == 0
|
69
|
-
end
|
data/boxgrinder-core.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{boxgrinder-core}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Marek Goldmann"]
|
9
|
-
s.date = %q{2010-
|
9
|
+
s.date = %q{2010-12-03}
|
10
10
|
s.description = %q{Core library for BoxGrinder}
|
11
11
|
s.email = %q{info@boxgrinder.org}
|
12
|
-
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/
|
13
|
-
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "boxgrinder-core.gemspec", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb"]
|
13
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "boxgrinder-core.gemspec", "lib/boxgrinder-core.rb", "lib/boxgrinder-core/defaults.rb", "lib/boxgrinder-core/helpers/appliance-config-helper.rb", "lib/boxgrinder-core/helpers/appliance-helper.rb", "lib/boxgrinder-core/helpers/exec-helper.rb", "lib/boxgrinder-core/helpers/log-helper.rb", "lib/boxgrinder-core/models/appliance-config.rb", "lib/boxgrinder-core/models/config.rb", "lib/boxgrinder-core/models/task.rb", "lib/boxgrinder-core/validators/appliance-config-validator.rb", "lib/boxgrinder-core/validators/errors.rb", "rubygem-boxgrinder-core.spec", "spec/helpers/appliance-config-helper-spec.rb", "spec/helpers/appliance-helper-spec.rb", "spec/helpers/exec-helper-spec.rb", "spec/helpers/log-helper-spec.rb", "spec/rspec/ls/one", "spec/rspec/ls/two", "spec/rspec/rspec-config-helper.rb", "spec/rspec/src/appliances/ephemeral-repo.appl", "spec/rspec/src/appliances/full.appl", "spec/rspec/src/appliances/repo.appl", "spec/validators/appliance-config-validator-spec.rb"]
|
14
14
|
s.homepage = %q{http://www.jboss.org/boxgrinder}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-core", "--main", "README"]
|
16
16
|
s.require_paths = ["lib"]
|
@@ -32,23 +32,23 @@ module BoxGrinder
|
|
32
32
|
configs = []
|
33
33
|
|
34
34
|
appliance_config =
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
else
|
49
|
-
raise 'Unsupported file format for appliance definition file'
|
50
|
-
end
|
35
|
+
case definition_file_extension
|
36
|
+
when '.appl', '.yml', '.yaml'
|
37
|
+
read_yaml(definition_file)
|
38
|
+
when '.xml'
|
39
|
+
read_xml(definition_file)
|
40
|
+
else
|
41
|
+
unless content_type.nil?
|
42
|
+
case content_type
|
43
|
+
when 'application/x-yaml', 'text/yaml'
|
44
|
+
read_yaml(definition_file)
|
45
|
+
when 'application/xml', 'text/xml', 'application/x-xml'
|
46
|
+
read_xml(definition_file)
|
47
|
+
end
|
51
48
|
end
|
49
|
+
end
|
50
|
+
|
51
|
+
raise 'Unsupported file format for appliance definition file' if appliance_config.nil?
|
52
52
|
|
53
53
|
configs << appliance_config
|
54
54
|
|
@@ -56,7 +56,7 @@ module BoxGrinder
|
|
56
56
|
configs << read_definitions("#{File.dirname(definition_file)}/#{appliance_name}#{definition_file_extension}").first
|
57
57
|
end unless appliance_config.appliances.nil? or !appliance_config.appliances.is_a?(Array)
|
58
58
|
|
59
|
-
[
|
59
|
+
[configs.flatten, appliance_config]
|
60
60
|
end
|
61
61
|
|
62
62
|
def read_yaml(file)
|
@@ -71,16 +71,16 @@ module BoxGrinder
|
|
71
71
|
|
72
72
|
appliance_config = ApplianceConfig.new
|
73
73
|
|
74
|
-
appliance_config.name
|
75
|
-
appliance_config.summary
|
74
|
+
appliance_config.name = definition['name'] unless definition['name'].nil?
|
75
|
+
appliance_config.summary = definition['summary'] unless definition['summary'].nil?
|
76
76
|
|
77
77
|
definition['variables'].each { |key, value| appliance_config.variables[key] = value } unless definition['variables'].nil?
|
78
78
|
|
79
|
-
appliance_config.appliances
|
80
|
-
appliance_config.repos
|
79
|
+
appliance_config.appliances = definition['appliances'] unless definition['appliances'].nil?
|
80
|
+
appliance_config.repos = definition['repos'] unless definition['repos'].nil?
|
81
81
|
|
82
|
-
appliance_config.version
|
83
|
-
appliance_config.release
|
82
|
+
appliance_config.version = definition['version'].to_s unless definition['version'].nil?
|
83
|
+
appliance_config.release = definition['release'].to_s unless definition['release'].nil?
|
84
84
|
|
85
85
|
unless definition['default_repos'].nil?
|
86
86
|
appliance_config.default_repos = definition['default_repos']
|
@@ -88,22 +88,22 @@ module BoxGrinder
|
|
88
88
|
end
|
89
89
|
|
90
90
|
unless definition['packages'].nil?
|
91
|
-
appliance_config.packages.includes
|
92
|
-
appliance_config.packages.excludes
|
91
|
+
appliance_config.packages.includes = definition['packages']['includes'] unless definition['packages']['includes'].nil?
|
92
|
+
appliance_config.packages.excludes = definition['packages']['excludes'] unless definition['packages']['excludes'].nil?
|
93
93
|
end
|
94
94
|
|
95
95
|
unless definition['os'].nil?
|
96
|
-
appliance_config.os.name
|
97
|
-
appliance_config.os.version
|
98
|
-
appliance_config.os.password
|
96
|
+
appliance_config.os.name = definition['os']['name'].to_s unless definition['os']['name'].nil?
|
97
|
+
appliance_config.os.version = definition['os']['version'].to_s unless definition['os']['version'].nil?
|
98
|
+
appliance_config.os.password = definition['os']['password'].to_s unless definition['os']['password'].nil?
|
99
99
|
end
|
100
100
|
|
101
101
|
unless definition['hardware'].nil?
|
102
|
-
appliance_config.hardware.arch
|
103
|
-
appliance_config.hardware.cpus
|
104
|
-
appliance_config.hardware.memory
|
105
|
-
appliance_config.hardware.network
|
106
|
-
appliance_config.hardware.partitions
|
102
|
+
appliance_config.hardware.arch = definition['hardware']['arch'] unless definition['hardware']['arch'].nil?
|
103
|
+
appliance_config.hardware.cpus = definition['hardware']['cpus'] unless definition['hardware']['cpus'].nil?
|
104
|
+
appliance_config.hardware.memory = definition['hardware']['memory'] unless definition['hardware']['memory'].nil?
|
105
|
+
appliance_config.hardware.network = definition['hardware']['network'] unless definition['hardware']['network'].nil?
|
106
|
+
appliance_config.hardware.partitions = definition['hardware']['partitions'] unless definition['hardware']['partitions'].nil?
|
107
107
|
end
|
108
108
|
|
109
109
|
definition['post'].each { |key, value| appliance_config.post[key] = value } unless definition['post'].nil?
|
@@ -21,14 +21,14 @@ require 'boxgrinder-core/defaults'
|
|
21
21
|
|
22
22
|
module BoxGrinder
|
23
23
|
class ApplianceConfigValidator
|
24
|
-
def initialize(
|
24
|
+
def initialize(appliance_config, options = {})
|
25
25
|
@appliance_config = appliance_config
|
26
|
-
@options
|
26
|
+
@options = options
|
27
27
|
end
|
28
28
|
|
29
29
|
def validate
|
30
|
-
check_for_missing_field(
|
31
|
-
check_for_missing_field(
|
30
|
+
check_for_missing_field('name')
|
31
|
+
check_for_missing_field('summary')
|
32
32
|
|
33
33
|
validate_os
|
34
34
|
validate_hardware
|
@@ -37,20 +37,10 @@ module BoxGrinder
|
|
37
37
|
|
38
38
|
protected
|
39
39
|
|
40
|
-
def check_for_missing_field(
|
40
|
+
def check_for_missing_field(name)
|
41
41
|
raise ApplianceValidationError, "Missing field: appliance definition file should have field '#{name}'" if eval("@appliance_config.#{name}").nil?
|
42
42
|
end
|
43
43
|
|
44
|
-
def validate_os
|
45
|
-
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?
|
46
|
-
|
47
|
-
os_plugin = PluginManager.instance.plugins[:os][@appliance_config.os.name.to_sym]
|
48
|
-
|
49
|
-
raise ApplianceValidationError, "No operating system selected" if @appliance_config.os.name.nil?
|
50
|
-
raise ApplianceValidationError, "Not supported operating system selected: #{@appliance_config.os.name}. Make sure you have installed right operating system plugin, see http://community.jboss.org/docs/DOC-15214. Supported OSes are: #{PluginManager.instance.plugins[:os].keys.join(", ")}" if os_plugin.nil?
|
51
|
-
raise ApplianceValidationError, "Not supported operating system version selected: #{@appliance_config.os.version}. Supported versions are: #{os_plugin[:versions].join(", ")}" unless @appliance_config.os.version.nil? or os_plugin[:versions].include?( @appliance_config.os.version )
|
52
|
-
end
|
53
|
-
|
54
44
|
def validate_hardware
|
55
45
|
raise ApplianceValidationError, "Not valid CPU amount: Too many or too less CPU's: '#{@appliance_config.hardware.cpus}'. Please choose from 1-4. Please correct your appliance definition file, thanks." unless @appliance_config.hardware.cpus >= 1 and @appliance_config.hardware.cpus <= 4
|
56
46
|
raise ApplianceValidationError, "Not valid memory amount: '#{@appliance_config.hardware.memory}' is wrong value. Please correct your appliance definition file" if @appliance_config.hardware.memory =~ /\d/
|
@@ -59,6 +49,10 @@ module BoxGrinder
|
|
59
49
|
raise ApplianceValidationError, "No partitions found. Please correct your appliance definition file" if @appliance_config.hardware.partitions.size == 0
|
60
50
|
end
|
61
51
|
|
52
|
+
def validate_os
|
53
|
+
raise ApplianceValidationError, "No operating system selected" if @appliance_config.os.name.nil?
|
54
|
+
end
|
55
|
+
|
62
56
|
def validate_repos
|
63
57
|
return if @appliance_config.repos.size == 0
|
64
58
|
|
@@ -5,8 +5,8 @@
|
|
5
5
|
|
6
6
|
Summary: Core library for BoxGrinder
|
7
7
|
Name: rubygem-%{gemname}
|
8
|
-
Version: 0.1.
|
9
|
-
Release:
|
8
|
+
Version: 0.1.4
|
9
|
+
Release: 1%{?dist}
|
10
10
|
Group: Development/Languages
|
11
11
|
License: LGPLv3+
|
12
12
|
URL: http://www.jboss.org/boxgrinder
|
@@ -73,6 +73,9 @@ popd
|
|
73
73
|
%{gemdir}/doc/%{gemname}-%{version}
|
74
74
|
|
75
75
|
%changelog
|
76
|
+
* Thu Dec 02 2010 <mgoldman@redhat.com> - 0.1.4-1
|
77
|
+
- Updated to new upstream release: 0.1.4
|
78
|
+
|
76
79
|
* Wed Nov 17 2010 <mgoldman@redhat.com> - 0.1.3-3
|
77
80
|
- Added: BuildRequires: rubygem(echoe)
|
78
81
|
- Changed the way Gem is installed and tests are exeuted
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxgrinder-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marek Goldmann
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-03 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -66,7 +66,6 @@ extra_rdoc_files:
|
|
66
66
|
- lib/boxgrinder-core/helpers/appliance-helper.rb
|
67
67
|
- lib/boxgrinder-core/helpers/exec-helper.rb
|
68
68
|
- lib/boxgrinder-core/helpers/log-helper.rb
|
69
|
-
- lib/boxgrinder-core/helpers/queue-helper.rb
|
70
69
|
- lib/boxgrinder-core/models/appliance-config.rb
|
71
70
|
- lib/boxgrinder-core/models/config.rb
|
72
71
|
- lib/boxgrinder-core/models/task.rb
|
@@ -85,7 +84,6 @@ files:
|
|
85
84
|
- lib/boxgrinder-core/helpers/appliance-helper.rb
|
86
85
|
- lib/boxgrinder-core/helpers/exec-helper.rb
|
87
86
|
- lib/boxgrinder-core/helpers/log-helper.rb
|
88
|
-
- lib/boxgrinder-core/helpers/queue-helper.rb
|
89
87
|
- lib/boxgrinder-core/models/appliance-config.rb
|
90
88
|
- lib/boxgrinder-core/models/config.rb
|
91
89
|
- lib/boxgrinder-core/models/task.rb
|
@@ -96,7 +94,6 @@ files:
|
|
96
94
|
- spec/helpers/appliance-helper-spec.rb
|
97
95
|
- spec/helpers/exec-helper-spec.rb
|
98
96
|
- spec/helpers/log-helper-spec.rb
|
99
|
-
- spec/helpers/queue-helper-spec.rb
|
100
97
|
- spec/rspec/ls/one
|
101
98
|
- spec/rspec/ls/two
|
102
99
|
- spec/rspec/rspec-config-helper.rb
|
@@ -1,52 +0,0 @@
|
|
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 'logger'
|
20
|
-
|
21
|
-
module BoxGrinder
|
22
|
-
class QueueHelper
|
23
|
-
def initialize(options = {})
|
24
|
-
@log = options[:log] || Logger.new(STDOUT)
|
25
|
-
end
|
26
|
-
|
27
|
-
def client(opts = {})
|
28
|
-
begin
|
29
|
-
require 'rubygems'
|
30
|
-
require 'torquebox-messaging-client'
|
31
|
-
rescue
|
32
|
-
@log.error "Couldn't load TorqueBox messaging client."
|
33
|
-
return nil
|
34
|
-
end
|
35
|
-
|
36
|
-
host = opts[:host] || 'localhost'
|
37
|
-
port = opts[:port] || 1099
|
38
|
-
|
39
|
-
naming_provider_url = "jnp://#{host}:#{port}/"
|
40
|
-
|
41
|
-
@log.trace "Creating messaging client..."
|
42
|
-
|
43
|
-
ret_val = TorqueBox::Messaging::Client.connect(:naming_provider_url => naming_provider_url ) do |client|
|
44
|
-
yield client
|
45
|
-
end
|
46
|
-
|
47
|
-
@log.trace "Messaging client closed."
|
48
|
-
|
49
|
-
ret_val
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,24 +0,0 @@
|
|
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-core/helpers/queue-helper'
|
20
|
-
|
21
|
-
module BoxGrinder
|
22
|
-
describe QueueHelper do
|
23
|
-
end
|
24
|
-
end
|