boxgrinder-core 0.0.11 → 0.0.20
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/README +1 -0
- data/Rakefile +9 -0
- data/boxgrinder-core.gemspec +30 -0
- data/lib/boxgrinder-core/defaults.rb +2 -2
- data/lib/boxgrinder-core/helpers/exec-helper.rb +22 -9
- data/lib/boxgrinder-core/helpers/log-helper.rb +13 -5
- data/lib/boxgrinder-core/models/appliance-config.rb +17 -95
- data/lib/boxgrinder-core/validators/appliance-config-validator.rb +2 -2
- data/lib/openhash/openhash.rb +92 -0
- data/spec/Rakefile +9 -0
- data/spec/helpers/appliance-config-helper-spec.rb +6 -0
- data/spec/helpers/appliance-helper-spec.rb +6 -0
- data/spec/helpers/exec-helper-spec.rb +6 -0
- data/spec/helpers/log-helper-spec.rb +56 -0
- data/spec/helpers/queue-helper-spec.rb +6 -0
- data/spec/rspec/rspec-config-helper.rb +59 -0
- data/spec/rspec/src/appliances/ephemeral-repo.appl +24 -0
- data/spec/rspec/src/appliances/full.appl +24 -0
- data/spec/rspec/src/appliances/repo.appl +22 -0
- data/spec/validators/appliance-config-validator-spec.rb +6 -0
- metadata +58 -21
data/CHANGELOG
ADDED
data/Manifest
ADDED
File without changes
|
data/README
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
This gem contains core classes used across BoxGrinder projects.
|
data/Rakefile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'echoe'
|
2
|
+
|
3
|
+
Echoe.new("boxgrinder-core") do |p|
|
4
|
+
p.project = "BoxGrinder Core"
|
5
|
+
p.author = "Marek Goldmann"
|
6
|
+
p.summary = "Core files for BoxGrinder."
|
7
|
+
p.url = "http://www.jboss.org/stormgrind/projects/boxgrinder.html"
|
8
|
+
p.email = "info@boxgrinder.org"
|
9
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{boxgrinder-core}
|
5
|
+
s.version = "0.0.20"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Marek Goldmann"]
|
9
|
+
s.date = %q{2010-07-21}
|
10
|
+
s.description = %q{Core files for BoxGrinder.}
|
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/helpers/queue-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", "lib/openhash/openhash.rb"]
|
13
|
+
s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "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/helpers/queue-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", "lib/openhash/openhash.rb", "spec/Rakefile", "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/helpers/queue-helper-spec.rb", "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", "boxgrinder-core.gemspec"]
|
14
|
+
s.homepage = %q{http://www.jboss.org/stormgrind/projects/boxgrinder.html}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Boxgrinder-core", "--main", "README"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{BoxGrinder Core}
|
18
|
+
s.rubygems_version = %q{1.3.6}
|
19
|
+
s.summary = %q{Core files for BoxGrinder.}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
@@ -50,8 +50,8 @@ module BoxGrinder
|
|
50
50
|
:release => 'SNAPSHOT',
|
51
51
|
:dir_build => 'build',
|
52
52
|
#:topdir => "#{self.} build/topdir",
|
53
|
-
:dir_src_cache => 'sources-cache',
|
54
|
-
:dir_rpms_cache => 'rpms-cache',
|
53
|
+
:dir_src_cache => '/var/cache/boxgrinder/sources-cache',
|
54
|
+
:dir_rpms_cache => '/var/cache/boxgrinder/rpms-cache',
|
55
55
|
:dir_specs => 'specs',
|
56
56
|
:dir_appliances => 'appliances',
|
57
57
|
:dir_src => 'src',
|
@@ -19,6 +19,7 @@
|
|
19
19
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
20
20
|
|
21
21
|
require 'logger'
|
22
|
+
require 'open3'
|
22
23
|
|
23
24
|
module BoxGrinder
|
24
25
|
class ExecHelper
|
@@ -29,18 +30,30 @@ module BoxGrinder
|
|
29
30
|
def execute( command )
|
30
31
|
@log.debug "Executing command: '#{command}'"
|
31
32
|
|
32
|
-
|
33
|
+
output = ""
|
33
34
|
|
34
|
-
|
35
|
+
Open3.popen3( command ) do |stdin, stdout, stderr|
|
36
|
+
threads = []
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
threads << Thread.new(stdout) do |input_str|
|
39
|
+
input_str.each do |l|
|
40
|
+
output << l
|
41
|
+
@log.debug l.chomp.strip
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
threads << Thread.new(stderr) do |input_str|
|
46
|
+
input_str.each do |l|
|
47
|
+
output << l
|
48
|
+
@log.debug l.chomp.strip
|
49
|
+
end
|
50
|
+
end
|
51
|
+
threads.each{|t|t.join}
|
43
52
|
end
|
53
|
+
|
54
|
+
raise "An error occurred executing command: '#{command}'" if $?.to_i != 0
|
55
|
+
|
56
|
+
output
|
44
57
|
end
|
45
58
|
end
|
46
59
|
end
|
@@ -20,6 +20,7 @@
|
|
20
20
|
|
21
21
|
require 'logger'
|
22
22
|
require 'boxgrinder-core/defaults'
|
23
|
+
require 'fileutils'
|
23
24
|
|
24
25
|
Logger.const_set(:TRACE, 0)
|
25
26
|
Logger.const_set(:DEBUG, 1)
|
@@ -66,25 +67,32 @@ module BoxGrinder
|
|
66
67
|
formatter = Logger::Formatter.new
|
67
68
|
|
68
69
|
if type.include?(:file)
|
69
|
-
|
70
|
-
FileUtils.mkdir_p(File.dirname(location))
|
71
|
-
end
|
70
|
+
FileUtils.mkdir_p(File.dirname(location))
|
72
71
|
|
73
72
|
@file_log = Logger.new(location, 10, 1024000)
|
74
|
-
@file_log.level = Logger::TRACE
|
73
|
+
@file_log.level = threshold == Logger::TRACE ? Logger::TRACE : Logger::DEBUG
|
75
74
|
@file_log.formatter = formatter
|
76
75
|
end
|
77
76
|
|
78
77
|
if type.include?(:stdout)
|
79
|
-
@stdout_log = Logger.new(STDOUT)
|
78
|
+
@stdout_log = Logger.new(STDOUT.dup)
|
80
79
|
@stdout_log.level = threshold || Logger::INFO
|
81
80
|
@stdout_log.formatter = formatter
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
84
|
+
def write( msg )
|
85
|
+
@stdout_log.trace( msg.chomp.strip ) unless @stdout_log.nil?
|
86
|
+
@file_log.trace( msg.chomp.strip ) unless @file_log.nil?
|
87
|
+
end
|
88
|
+
|
85
89
|
def method_missing(method_name, *args)
|
86
90
|
@stdout_log.send(method_name, *args) unless @stdout_log.nil?
|
87
91
|
@file_log.send(method_name, *args) unless @file_log.nil?
|
88
92
|
end
|
89
93
|
end
|
94
|
+
|
95
|
+
attr_accessor :file_log
|
96
|
+
attr_accessor :stdout_log
|
97
|
+
|
90
98
|
end
|
@@ -19,24 +19,22 @@
|
|
19
19
|
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
20
20
|
|
21
21
|
require 'boxgrinder-core/defaults'
|
22
|
-
require '
|
22
|
+
require 'openhash/openhash'
|
23
23
|
require 'rbconfig'
|
24
24
|
|
25
25
|
module BoxGrinder
|
26
26
|
class ApplianceConfig
|
27
|
-
def initialize
|
28
|
-
|
27
|
+
def initialize
|
28
|
+
@name = nil
|
29
|
+
@summary = nil
|
29
30
|
|
30
|
-
@
|
31
|
-
@summary = nil #@definition['summary']
|
31
|
+
@os = OpenHash.new
|
32
32
|
|
33
|
-
@os
|
33
|
+
@os.name = nil
|
34
|
+
@os.version = nil
|
35
|
+
@os.password = nil
|
34
36
|
|
35
|
-
@
|
36
|
-
@os.version = nil #APPLIANCE_DEFAULTS[:os][:version]
|
37
|
-
@os.password = nil #APPLIANCE_DEFAULTS[:os][:password]
|
38
|
-
|
39
|
-
@hardware = OpenStruct.new
|
37
|
+
@hardware = OpenHash.new
|
40
38
|
|
41
39
|
@hardware.cpus = APPLIANCE_DEFAULTS[:hardware][:cpus]
|
42
40
|
@hardware.memory = APPLIANCE_DEFAULTS[:hardware][:memory]
|
@@ -44,7 +42,7 @@ module BoxGrinder
|
|
44
42
|
|
45
43
|
@post = {}
|
46
44
|
|
47
|
-
@packages =
|
45
|
+
@packages = OpenHash.new
|
48
46
|
@packages.includes = []
|
49
47
|
@packages.excludes = []
|
50
48
|
|
@@ -55,14 +53,8 @@ module BoxGrinder
|
|
55
53
|
@release = 0
|
56
54
|
end
|
57
55
|
|
58
|
-
#attr_reader :definition
|
59
|
-
#attr_reader :name
|
60
|
-
#attr_reader :summary
|
61
|
-
#attr_reader :appliances
|
62
56
|
attr_reader :os
|
63
57
|
attr_reader :hardware
|
64
|
-
#attr_reader :repos
|
65
|
-
#attr_reader :packages
|
66
58
|
attr_reader :path
|
67
59
|
attr_reader :file
|
68
60
|
attr_reader :post
|
@@ -87,61 +79,13 @@ module BoxGrinder
|
|
87
79
|
end
|
88
80
|
|
89
81
|
def initialize_paths
|
90
|
-
@path =
|
91
|
-
|
92
|
-
@path.
|
93
|
-
@path.
|
94
|
-
@path.
|
95
|
-
@path.
|
96
|
-
|
97
|
-
@path.file = OpenStruct.new
|
98
|
-
@path.file.raw = OpenStruct.new
|
99
|
-
@path.file.ec2 = OpenStruct.new
|
100
|
-
@path.file.vmware = OpenStruct.new
|
101
|
-
@path.file.vmware.personal = OpenStruct.new
|
102
|
-
@path.file.vmware.enterprise = OpenStruct.new
|
103
|
-
|
104
|
-
@path.dir.packages = "build/#{appliance_path}/packages"
|
105
|
-
|
106
|
-
@path.dir.build = "build/#{appliance_path}"
|
107
|
-
|
108
|
-
@path.dir.raw.build = "build/#{appliance_path}/raw"
|
109
|
-
@path.dir.raw.build_full = "build/#{appliance_path}/raw/#{@name}"
|
110
|
-
|
111
|
-
@path.dir.ec2.build = "build/#{appliance_path}/ec2"
|
112
|
-
@path.dir.ec2.bundle = "#{@path.dir.ec2.build}/bundle"
|
113
|
-
|
114
|
-
@path.dir.vmware.build = "build/#{appliance_path}/vmware"
|
115
|
-
@path.dir.vmware.personal = "#{@path.dir.vmware.build}/personal"
|
116
|
-
@path.dir.vmware.enterprise = "#{@path.dir.vmware.build}/enterprise"
|
117
|
-
|
118
|
-
@path.file.raw.kickstart = "#{@path.dir.raw.build}/#{@name}.ks"
|
119
|
-
@path.file.raw.config = "#{@path.dir.raw.build}/#{@name}.cfg"
|
120
|
-
@path.file.raw.yum = "#{@path.dir.raw.build}/#{@name}.yum.conf"
|
121
|
-
@path.file.raw.disk = "#{@path.dir.raw.build_full}/#{@name}-sda.raw"
|
122
|
-
@path.file.raw.xml = "#{@path.dir.raw.build_full}/#{@name}.xml"
|
123
|
-
|
124
|
-
@path.file.ec2.disk = "#{@path.dir.ec2.build}/#{@name}.ec2"
|
125
|
-
@path.file.ec2.manifest = "#{@path.dir.ec2.bundle}/#{@name}-sda.raw.manifest.xml"
|
126
|
-
|
127
|
-
@path.file.vmware.disk = "#{@path.dir.vmware.build}/#{@name}.raw"
|
128
|
-
@path.file.vmware.personal.vmx = "#{@path.dir.vmware.personal}/#{@name}.vmx"
|
129
|
-
@path.file.vmware.personal.vmdk = "#{@path.dir.vmware.personal}/#{@name}.vmdk"
|
130
|
-
@path.file.vmware.personal.disk = "#{@path.dir.vmware.personal}/#{@name}.raw"
|
131
|
-
@path.file.vmware.enterprise.vmx = "#{@path.dir.vmware.enterprise}/#{@name}.vmx"
|
132
|
-
@path.file.vmware.enterprise.vmdk = "#{@path.dir.vmware.enterprise}/#{@name}.vmdk"
|
133
|
-
@path.file.vmware.enterprise.disk = "#{@path.dir.vmware.enterprise}/#{@name}.raw"
|
134
|
-
|
135
|
-
@path.file.package = {
|
136
|
-
:raw => {
|
137
|
-
:tgz => "#{@path.dir.packages}/#{@name}-#{@version}.#{@release}-#{@hardware.arch}-raw.tgz",
|
138
|
-
:zip => "#{@path.dir.packages}/#{@name}-#{@version}.#{@release}-#{@hardware.arch}-raw.zip"
|
139
|
-
},
|
140
|
-
:vmware => {
|
141
|
-
:tgz => "#{@path.dir.packages}/#{@name}-#{@version}.#{@release}-#{@hardware.arch}-VMware.tgz",
|
142
|
-
:zip => "#{@path.dir.packages}/#{@name}-#{@version}.#{@release}-#{@hardware.arch}-VMware.zip"
|
143
|
-
}
|
144
|
-
}
|
82
|
+
@path = OpenHash.new
|
83
|
+
|
84
|
+
@path.os = "#{@os.name}/#{@os.version}"
|
85
|
+
@path.main = "#{@hardware.arch}/#{@path.os}"
|
86
|
+
@path.appliance = "appliances/#{@path.main}/#{@name}"
|
87
|
+
@path.build = "build/#{@path.appliance}"
|
88
|
+
|
145
89
|
self
|
146
90
|
end
|
147
91
|
|
@@ -150,23 +94,6 @@ module BoxGrinder
|
|
150
94
|
"#{@name}-#{@summary}-#{@version}-#{@release}-#{@os.name}-#{@os.version}-#{@os.password}-#{@hardware.cpus}-#{@hardware.memory}-#{@hardware.partitions}-#{@appliances}".hash
|
151
95
|
end
|
152
96
|
|
153
|
-
# TODO remove this, leave only :name
|
154
|
-
def simple_name
|
155
|
-
@name
|
156
|
-
end
|
157
|
-
|
158
|
-
def os_path
|
159
|
-
"#{@os.name}/#{@os.version}"
|
160
|
-
end
|
161
|
-
|
162
|
-
def main_path
|
163
|
-
"#{@hardware.arch}/#{os_path}"
|
164
|
-
end
|
165
|
-
|
166
|
-
def appliance_path
|
167
|
-
"appliances/#{main_path}/#{@name}"
|
168
|
-
end
|
169
|
-
|
170
97
|
def eql?(other)
|
171
98
|
hash.eql?(other.hash)
|
172
99
|
end
|
@@ -178,10 +105,5 @@ module BoxGrinder
|
|
178
105
|
def clone
|
179
106
|
Marshal::load(Marshal.dump(self))
|
180
107
|
end
|
181
|
-
|
182
|
-
def os_family
|
183
|
-
return :linux if [ 'fedora' ].include?( @os.name )
|
184
|
-
return :unknown
|
185
|
-
end
|
186
108
|
end
|
187
109
|
end
|
@@ -49,8 +49,8 @@ module BoxGrinder
|
|
49
49
|
unless @options[:os_plugins].nil?
|
50
50
|
os_plugin = @options[:os_plugins][@appliance_config.os.name.to_sym]
|
51
51
|
|
52
|
-
raise ApplianceValidationError, "Not supported operating system selected: #{@appliance_config.os.name}. Supported OSes are: #{
|
53
|
-
raise ApplianceValidationError, "Not supported operating system version selected: #{@appliance_config.os.version}. Supported versions are: #{os_plugin
|
52
|
+
raise ApplianceValidationError, "Not supported operating system selected: #{@appliance_config.os.name}. Supported OSes are: #{@options[:os_plugins].keys.join(", ")}" if os_plugin.nil?
|
53
|
+
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 )
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2005 Thomas Sawyer
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
class OpenHash < Hash
|
24
|
+
|
25
|
+
# New OpenHash.
|
26
|
+
def initialize(data={})
|
27
|
+
super()
|
28
|
+
merge!(data)
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
def <<(x)
|
33
|
+
case x
|
34
|
+
when Hash
|
35
|
+
update(x)
|
36
|
+
when Array
|
37
|
+
x.each_slice(2) do |(k, v)|
|
38
|
+
self[k] = v
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
def respond_to?(name)
|
45
|
+
key?(name.to_sym) || super(name)
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
def to_h
|
50
|
+
dup
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
def to_hash
|
55
|
+
dup
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
def inspect
|
60
|
+
super
|
61
|
+
end
|
62
|
+
|
63
|
+
# Omit specific Hash methods from slot protection.
|
64
|
+
def omit!(*methods)
|
65
|
+
methods.reject!{ |x| x.to_s =~ /^__/ }
|
66
|
+
(
|
67
|
+
class << self;
|
68
|
+
self;
|
69
|
+
end).class_eval{ private *methods }
|
70
|
+
end
|
71
|
+
|
72
|
+
# Route get and set calls.
|
73
|
+
def method_missing(s, *a, &b)
|
74
|
+
type = s.to_s[-1, 1]
|
75
|
+
name = s.to_s.sub(/[!?=]$/, '')
|
76
|
+
key = name.to_sym
|
77
|
+
case type
|
78
|
+
when '='
|
79
|
+
self[key] = a[0]
|
80
|
+
#when '!'
|
81
|
+
# self[s] = OpenHash.new
|
82
|
+
when '?'
|
83
|
+
key?(key)
|
84
|
+
else
|
85
|
+
if key?(key)
|
86
|
+
self[key]
|
87
|
+
else
|
88
|
+
super(s, *a, &b)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/spec/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'boxgrinder-core/helpers/log-helper'
|
2
|
+
|
3
|
+
module BoxGrinder
|
4
|
+
describe LogHelper do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@helper = LogHelper.new
|
8
|
+
@helper.instance_variable_set(:@stdout_log, Logger.new('/dev/null') )
|
9
|
+
@helper.instance_variable_set(:@file_log, Logger.new('/dev/null') )
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should initialize properly without arguments with good log levels" do
|
13
|
+
FileUtils.should_receive(:mkdir_p).once.with("log")
|
14
|
+
|
15
|
+
@helper = LogHelper.new
|
16
|
+
|
17
|
+
stdout_log = @helper.instance_variable_get(:@stdout_log)
|
18
|
+
file_log = @helper.instance_variable_get(:@file_log)
|
19
|
+
|
20
|
+
stdout_log.level.should == Logger::INFO
|
21
|
+
file_log.level.should == Logger::DEBUG
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should allow to log in every known log level" do
|
25
|
+
@helper.fatal( "fatal" )
|
26
|
+
@helper.debug( "debug" )
|
27
|
+
@helper.error( "error" )
|
28
|
+
@helper.warn( "warn" )
|
29
|
+
@helper.info( "info" )
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should change log level" do
|
33
|
+
FileUtils.should_receive(:mkdir_p).once.with("log")
|
34
|
+
|
35
|
+
@helper = LogHelper.new( :threshold => "debug" )
|
36
|
+
|
37
|
+
stdout_log = @helper.instance_variable_get(:@stdout_log)
|
38
|
+
file_log = @helper.instance_variable_get(:@file_log)
|
39
|
+
|
40
|
+
stdout_log.level.should == Logger::DEBUG
|
41
|
+
file_log.level.should == Logger::DEBUG
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should change log level" do
|
45
|
+
FileUtils.should_receive(:mkdir_p).once.with("log")
|
46
|
+
|
47
|
+
@helper = LogHelper.new( :thrshold => "doesntexists" )
|
48
|
+
|
49
|
+
stdout_log = @helper.instance_variable_get(:@stdout_log)
|
50
|
+
file_log = @helper.instance_variable_get(:@file_log)
|
51
|
+
|
52
|
+
stdout_log.level.should == Logger::INFO
|
53
|
+
file_log.level.should == Logger::DEBUG
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'boxgrinder-core/models/config'
|
2
|
+
require 'boxgrinder-core/models/appliance-config'
|
3
|
+
require 'boxgrinder-core/helpers/appliance-config-helper'
|
4
|
+
require 'boxgrinder-core/helpers/appliance-helper'
|
5
|
+
require 'logger'
|
6
|
+
|
7
|
+
Logger.const_set(:TRACE, 0)
|
8
|
+
Logger.const_set(:DEBUG, 1)
|
9
|
+
Logger.const_set(:INFO, 2)
|
10
|
+
Logger.const_set(:WARN, 3)
|
11
|
+
Logger.const_set(:ERROR, 4)
|
12
|
+
Logger.const_set(:FATAL, 5)
|
13
|
+
Logger.const_set(:UNKNOWN, 6)
|
14
|
+
|
15
|
+
Logger::SEV_LABEL.insert(0, 'TRACE')
|
16
|
+
|
17
|
+
class Logger
|
18
|
+
def trace?
|
19
|
+
@level <= TRACE
|
20
|
+
end
|
21
|
+
|
22
|
+
def trace(progname = nil, &block)
|
23
|
+
add(TRACE, nil, progname, &block)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module RSpecConfigHelper
|
28
|
+
RSPEC_BASE_LOCATION = "#{File.dirname(__FILE__)}"
|
29
|
+
|
30
|
+
def generate_config( params = OpenStruct.new )
|
31
|
+
config = BoxGrinder::Config.new
|
32
|
+
|
33
|
+
# files
|
34
|
+
config.files.base_vmdk = params.base_vmdk || "../../../src/base.vmdk"
|
35
|
+
config.files.base_vmx = params.base_vmx || "../../../src/base.vmx"
|
36
|
+
|
37
|
+
config
|
38
|
+
end
|
39
|
+
|
40
|
+
def generate_appliance_config( appliance_definition_file = "#{RSPEC_BASE_LOCATION}/src/appliances/full.appl" )
|
41
|
+
appliance_configs, appliance_config = BoxGrinder::ApplianceHelper.new(:log => Logger.new('/dev/null')).read_definitions( appliance_definition_file )
|
42
|
+
appliance_config_helper = BoxGrinder::ApplianceConfigHelper.new( appliance_configs )
|
43
|
+
|
44
|
+
appliance_config_helper.merge(appliance_config.clone.init_arch).initialize_paths
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate_appliance_config_gnome( os_version = "11" )
|
48
|
+
appliance_config = BoxGrinder::ApplianceConfig.new("valid-appliance-gnome", (-1.size) == 8 ? "x86_64" : "i386", "fedora", os_version)
|
49
|
+
|
50
|
+
appliance_config.disk_size = 2
|
51
|
+
appliance_config.summary = "this is a summary"
|
52
|
+
appliance_config.network_name = "NAT"
|
53
|
+
appliance_config.vcpu = "1"
|
54
|
+
appliance_config.mem_size = "1024"
|
55
|
+
appliance_config.appliances = [ appliance_config.name ]
|
56
|
+
|
57
|
+
appliance_config
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: repo
|
2
|
+
summary: A dummy repo appliance
|
3
|
+
os:
|
4
|
+
name: fedora
|
5
|
+
version: 12
|
6
|
+
hardware:
|
7
|
+
memory: 256
|
8
|
+
partitions:
|
9
|
+
"/":
|
10
|
+
size: 1
|
11
|
+
packages:
|
12
|
+
includes:
|
13
|
+
- gcc-c++
|
14
|
+
- wget
|
15
|
+
repos:
|
16
|
+
- name: "cirras"
|
17
|
+
baseurl: "http://repo.boxgrinder.org/packages/#OS_NAME#/#OS_VERSION#/RPMS/#ARCH#"
|
18
|
+
ephemeral: true
|
19
|
+
- name: "abc"
|
20
|
+
baseurl: "http://abc"
|
21
|
+
mirrorlist: "http://repo.boxgrinder.org/packages/#OS_NAME#/#OS_VERSION#/RPMS/#ARCH#"
|
22
|
+
ephemeral: true
|
23
|
+
- name: "boxgrinder-f12-testing-#ARCH#"
|
24
|
+
mirrorlist: "https://mirrors.fedoraproject.org/metalink?repo=updates-testing-f#OS_VERSION#&arch=#ARCH#"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: full
|
2
|
+
summary: A full appliance definition
|
3
|
+
os:
|
4
|
+
name: fedora
|
5
|
+
version: 11
|
6
|
+
hardware:
|
7
|
+
memory: 256
|
8
|
+
partitions:
|
9
|
+
"/":
|
10
|
+
size: 2
|
11
|
+
"/home":
|
12
|
+
size: 3
|
13
|
+
packages:
|
14
|
+
includes:
|
15
|
+
- gcc-c++
|
16
|
+
- wget
|
17
|
+
repos:
|
18
|
+
- name: "cirras"
|
19
|
+
baseurl: "http://repo.boxgrinder.org/packages/#OS_NAME#/#OS_VERSION#/RPMS/#ARCH#"
|
20
|
+
- name: "abc"
|
21
|
+
baseurl: "http://abc"
|
22
|
+
mirrorlist: "http://repo.boxgrinder.org/packages/#OS_NAME#/#OS_VERSION#/RPMS/#ARCH#"
|
23
|
+
- name: "boxgrinder-f11-testing-#ARCH#"
|
24
|
+
mirrorlist: "https://mirrors.fedoraproject.org/metalink?repo=updates-testing-f#OS_VERSION#&arch=#ARCH#"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: repo
|
2
|
+
summary: A dummy repo appliance
|
3
|
+
os:
|
4
|
+
name: fedora
|
5
|
+
version: 12
|
6
|
+
hardware:
|
7
|
+
memory: 256
|
8
|
+
partitions:
|
9
|
+
"/":
|
10
|
+
size: 1
|
11
|
+
packages:
|
12
|
+
includes:
|
13
|
+
- gcc-c++
|
14
|
+
- wget
|
15
|
+
repos:
|
16
|
+
- name: "cirras"
|
17
|
+
baseurl: "http://repo.boxgrinder.org/packages/#OS_NAME#/#OS_VERSION#/RPMS/#ARCH#"
|
18
|
+
- name: "abc"
|
19
|
+
baseurl: "http://abc"
|
20
|
+
mirrorlist: "http://repo.boxgrinder.org/packages/#OS_NAME#/#OS_VERSION#/RPMS/#ARCH#"
|
21
|
+
- name: "boxgrinder-f12-testing-#ARCH#"
|
22
|
+
mirrorlist: "https://mirrors.fedoraproject.org/metalink?repo=updates-testing-f#OS_VERSION#&arch=#ARCH#"
|
metadata
CHANGED
@@ -5,49 +5,85 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 20
|
9
|
+
version: 0.0.20
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
|
-
-
|
12
|
+
- Marek Goldmann
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-07-21 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
|
-
description:
|
21
|
+
description: Core files for BoxGrinder.
|
22
22
|
email: info@boxgrinder.org
|
23
23
|
executables: []
|
24
24
|
|
25
25
|
extensions: []
|
26
26
|
|
27
|
-
extra_rdoc_files:
|
28
|
-
|
29
|
-
|
27
|
+
extra_rdoc_files:
|
28
|
+
- CHANGELOG
|
29
|
+
- LICENSE
|
30
|
+
- README
|
30
31
|
- lib/boxgrinder-core.rb
|
32
|
+
- lib/boxgrinder-core/defaults.rb
|
33
|
+
- lib/boxgrinder-core/helpers/appliance-config-helper.rb
|
34
|
+
- lib/boxgrinder-core/helpers/appliance-helper.rb
|
35
|
+
- lib/boxgrinder-core/helpers/exec-helper.rb
|
36
|
+
- lib/boxgrinder-core/helpers/log-helper.rb
|
37
|
+
- lib/boxgrinder-core/helpers/queue-helper.rb
|
31
38
|
- lib/boxgrinder-core/models/appliance-config.rb
|
32
39
|
- lib/boxgrinder-core/models/config.rb
|
33
40
|
- lib/boxgrinder-core/models/task.rb
|
34
|
-
- lib/boxgrinder-core/defaults.rb
|
35
|
-
- lib/boxgrinder-core/validators/errors.rb
|
36
41
|
- lib/boxgrinder-core/validators/appliance-config-validator.rb
|
37
|
-
- lib/boxgrinder-core/
|
38
|
-
- lib/
|
42
|
+
- lib/boxgrinder-core/validators/errors.rb
|
43
|
+
- lib/openhash/openhash.rb
|
44
|
+
files:
|
45
|
+
- CHANGELOG
|
46
|
+
- LICENSE
|
47
|
+
- Manifest
|
48
|
+
- README
|
49
|
+
- Rakefile
|
50
|
+
- lib/boxgrinder-core.rb
|
51
|
+
- lib/boxgrinder-core/defaults.rb
|
52
|
+
- lib/boxgrinder-core/helpers/appliance-config-helper.rb
|
39
53
|
- lib/boxgrinder-core/helpers/appliance-helper.rb
|
54
|
+
- lib/boxgrinder-core/helpers/exec-helper.rb
|
40
55
|
- lib/boxgrinder-core/helpers/log-helper.rb
|
41
|
-
- lib/boxgrinder-core/helpers/
|
42
|
-
-
|
43
|
-
-
|
56
|
+
- lib/boxgrinder-core/helpers/queue-helper.rb
|
57
|
+
- lib/boxgrinder-core/models/appliance-config.rb
|
58
|
+
- lib/boxgrinder-core/models/config.rb
|
59
|
+
- lib/boxgrinder-core/models/task.rb
|
60
|
+
- lib/boxgrinder-core/validators/appliance-config-validator.rb
|
61
|
+
- lib/boxgrinder-core/validators/errors.rb
|
62
|
+
- lib/openhash/openhash.rb
|
63
|
+
- spec/Rakefile
|
64
|
+
- spec/helpers/appliance-config-helper-spec.rb
|
65
|
+
- spec/helpers/appliance-helper-spec.rb
|
66
|
+
- spec/helpers/exec-helper-spec.rb
|
67
|
+
- spec/helpers/log-helper-spec.rb
|
68
|
+
- spec/helpers/queue-helper-spec.rb
|
69
|
+
- spec/rspec/rspec-config-helper.rb
|
70
|
+
- spec/rspec/src/appliances/ephemeral-repo.appl
|
71
|
+
- spec/rspec/src/appliances/full.appl
|
72
|
+
- spec/rspec/src/appliances/repo.appl
|
73
|
+
- spec/validators/appliance-config-validator-spec.rb
|
74
|
+
- boxgrinder-core.gemspec
|
44
75
|
has_rdoc: true
|
45
76
|
homepage: http://www.jboss.org/stormgrind/projects/boxgrinder.html
|
46
77
|
licenses: []
|
47
78
|
|
48
79
|
post_install_message:
|
49
|
-
rdoc_options:
|
50
|
-
|
80
|
+
rdoc_options:
|
81
|
+
- --line-numbers
|
82
|
+
- --inline-source
|
83
|
+
- --title
|
84
|
+
- Boxgrinder-core
|
85
|
+
- --main
|
86
|
+
- README
|
51
87
|
require_paths:
|
52
88
|
- lib
|
53
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -62,14 +98,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
98
|
- - ">="
|
63
99
|
- !ruby/object:Gem::Version
|
64
100
|
segments:
|
65
|
-
-
|
66
|
-
|
101
|
+
- 1
|
102
|
+
- 2
|
103
|
+
version: "1.2"
|
67
104
|
requirements: []
|
68
105
|
|
69
|
-
rubyforge_project:
|
106
|
+
rubyforge_project: BoxGrinder Core
|
70
107
|
rubygems_version: 1.3.6
|
71
108
|
signing_key:
|
72
109
|
specification_version: 3
|
73
|
-
summary:
|
110
|
+
summary: Core files for BoxGrinder.
|
74
111
|
test_files: []
|
75
112
|
|