boxgrinder-core 0.3.0 → 0.3.1
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 +10 -0
- data/Rakefile +13 -9
- data/boxgrinder-core.gemspec +11 -8
- data/lib/boxgrinder-core/appliance-parser.rb +84 -0
- data/{spec/validators/appliance-config-validator-spec.rb → lib/boxgrinder-core/appliance-validator.rb} +15 -2
- data/lib/boxgrinder-core/{validators/errors.rb → errors.rb} +16 -0
- data/lib/boxgrinder-core/helpers/appliance-config-helper.rb +10 -18
- data/lib/boxgrinder-core/helpers/appliance-definition-helper.rb +19 -59
- data/lib/boxgrinder-core/helpers/appliance-transformation-helper.rb +58 -0
- data/lib/boxgrinder-core/helpers/exec-helper.rb +48 -21
- data/lib/boxgrinder-core/models/appliance-config.rb +39 -23
- data/lib/boxgrinder-core/models/config.rb +4 -2
- data/lib/boxgrinder-core/schemas/appliance_schema_0.8.0.yaml +95 -0
- data/lib/boxgrinder-core/schemas/appliance_schema_0.9.0.yaml +92 -0
- data/rubygem-boxgrinder-core.spec +13 -1
- data/spec/appliance-parser-spec.rb +68 -0
- data/spec/appliance-validator-spec.rb +71 -0
- data/spec/helpers/appliance-config-helper-spec.rb +136 -1
- data/spec/helpers/appliance-definition-helper-spec.rb +51 -79
- data/spec/helpers/appliance-transformation-helper-spec.rb +51 -0
- data/spec/helpers/exec-helper-spec.rb +40 -12
- data/spec/helpers/log-helper-spec.rb +1 -0
- data/spec/models/config-spec.rb +2 -1
- data/spec/rspec/src/appliances/0.8.x.appl +38 -0
- data/spec/rspec/src/appliances/0.9.x-invalid.appl +40 -0
- data/spec/rspec/src/appliances/0.9.x.appl +36 -0
- metadata +48 -19
- data/lib/boxgrinder-core/validators/appliance-config-validator.rb +0 -65
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: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marek Goldmann
|
@@ -15,41 +15,57 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-27 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: hashery
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 27
|
30
30
|
segments:
|
31
31
|
- 1
|
32
|
+
- 3
|
32
33
|
- 0
|
33
|
-
|
34
|
-
version: 1.0.0
|
34
|
+
version: 1.3.0
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: kwalify
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 7
|
46
46
|
segments:
|
47
|
-
- 1
|
48
|
-
- 3
|
49
47
|
- 0
|
50
|
-
|
48
|
+
- 7
|
49
|
+
- 2
|
50
|
+
version: 0.7.2
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: open4
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 23
|
62
|
+
segments:
|
63
|
+
- 1
|
64
|
+
- 0
|
65
|
+
- 0
|
66
|
+
version: 1.0.0
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
53
69
|
description: Core library for BoxGrinder
|
54
70
|
email: info@boxgrinder.org
|
55
71
|
executables: []
|
@@ -61,15 +77,19 @@ extra_rdoc_files:
|
|
61
77
|
- LICENSE
|
62
78
|
- README
|
63
79
|
- lib/boxgrinder-core.rb
|
80
|
+
- lib/boxgrinder-core/appliance-parser.rb
|
81
|
+
- lib/boxgrinder-core/appliance-validator.rb
|
82
|
+
- lib/boxgrinder-core/errors.rb
|
64
83
|
- lib/boxgrinder-core/helpers/appliance-config-helper.rb
|
65
84
|
- lib/boxgrinder-core/helpers/appliance-definition-helper.rb
|
85
|
+
- lib/boxgrinder-core/helpers/appliance-transformation-helper.rb
|
66
86
|
- lib/boxgrinder-core/helpers/exec-helper.rb
|
67
87
|
- lib/boxgrinder-core/helpers/log-helper.rb
|
68
88
|
- lib/boxgrinder-core/models/appliance-config.rb
|
69
89
|
- lib/boxgrinder-core/models/config.rb
|
70
90
|
- lib/boxgrinder-core/models/task.rb
|
71
|
-
- lib/boxgrinder-core/
|
72
|
-
- lib/boxgrinder-core/
|
91
|
+
- lib/boxgrinder-core/schemas/appliance_schema_0.8.0.yaml
|
92
|
+
- lib/boxgrinder-core/schemas/appliance_schema_0.9.0.yaml
|
73
93
|
files:
|
74
94
|
- CHANGELOG
|
75
95
|
- LICENSE
|
@@ -78,23 +98,33 @@ files:
|
|
78
98
|
- Rakefile
|
79
99
|
- boxgrinder-core.gemspec
|
80
100
|
- lib/boxgrinder-core.rb
|
101
|
+
- lib/boxgrinder-core/appliance-parser.rb
|
102
|
+
- lib/boxgrinder-core/appliance-validator.rb
|
103
|
+
- lib/boxgrinder-core/errors.rb
|
81
104
|
- lib/boxgrinder-core/helpers/appliance-config-helper.rb
|
82
105
|
- lib/boxgrinder-core/helpers/appliance-definition-helper.rb
|
106
|
+
- lib/boxgrinder-core/helpers/appliance-transformation-helper.rb
|
83
107
|
- lib/boxgrinder-core/helpers/exec-helper.rb
|
84
108
|
- lib/boxgrinder-core/helpers/log-helper.rb
|
85
109
|
- lib/boxgrinder-core/models/appliance-config.rb
|
86
110
|
- lib/boxgrinder-core/models/config.rb
|
87
111
|
- lib/boxgrinder-core/models/task.rb
|
88
|
-
- lib/boxgrinder-core/
|
89
|
-
- lib/boxgrinder-core/
|
112
|
+
- lib/boxgrinder-core/schemas/appliance_schema_0.8.0.yaml
|
113
|
+
- lib/boxgrinder-core/schemas/appliance_schema_0.9.0.yaml
|
90
114
|
- rubygem-boxgrinder-core.spec
|
115
|
+
- spec/appliance-parser-spec.rb
|
116
|
+
- spec/appliance-validator-spec.rb
|
91
117
|
- spec/helpers/appliance-config-helper-spec.rb
|
92
118
|
- spec/helpers/appliance-definition-helper-spec.rb
|
119
|
+
- spec/helpers/appliance-transformation-helper-spec.rb
|
93
120
|
- spec/helpers/exec-helper-spec.rb
|
94
121
|
- spec/helpers/log-helper-spec.rb
|
95
122
|
- spec/models/config-spec.rb
|
96
123
|
- spec/rspec/ls/one
|
97
124
|
- spec/rspec/ls/two
|
125
|
+
- spec/rspec/src/appliances/0.8.x.appl
|
126
|
+
- spec/rspec/src/appliances/0.9.x-invalid.appl
|
127
|
+
- spec/rspec/src/appliances/0.9.x.appl
|
98
128
|
- spec/rspec/src/appliances/ephemeral-repo.appl
|
99
129
|
- spec/rspec/src/appliances/full.appl
|
100
130
|
- spec/rspec/src/appliances/invalid-yaml.appl
|
@@ -102,9 +132,8 @@ files:
|
|
102
132
|
- spec/rspec/src/appliances/repo.appl
|
103
133
|
- spec/rspec/src/config/empty
|
104
134
|
- spec/rspec/src/config/valid
|
105
|
-
- spec/validators/appliance-config-validator-spec.rb
|
106
135
|
has_rdoc: true
|
107
|
-
homepage: http://
|
136
|
+
homepage: http://boxgrinder.org
|
108
137
|
licenses: []
|
109
138
|
|
110
139
|
post_install_message:
|
@@ -1,65 +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/validators/errors'
|
20
|
-
|
21
|
-
module BoxGrinder
|
22
|
-
class ApplianceConfigValidator
|
23
|
-
def initialize(appliance_config, options = {})
|
24
|
-
@appliance_config = appliance_config
|
25
|
-
@options = options
|
26
|
-
end
|
27
|
-
|
28
|
-
def validate
|
29
|
-
check_for_missing_field('name')
|
30
|
-
# check_for_missing_field('summary')
|
31
|
-
|
32
|
-
validate_os
|
33
|
-
validate_hardware
|
34
|
-
validate_repos
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
|
39
|
-
def check_for_missing_field(name)
|
40
|
-
raise ApplianceValidationError, "Missing field: appliance definition file should have field '#{name}'" if eval("@appliance_config.#{name}").nil?
|
41
|
-
end
|
42
|
-
|
43
|
-
def validate_hardware
|
44
|
-
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
|
45
|
-
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/
|
46
|
-
raise ApplianceValidationError, "Not valid memory amount: '#{@appliance_config.hardware.memory}' is not allowed here. Memory should be multiplicity of 64. Please correct your appliance definition file" if (@appliance_config.hardware.memory.to_i % 64 > 0)
|
47
|
-
|
48
|
-
raise ApplianceValidationError, "No partitions found. Please correct your appliance definition file" if @appliance_config.hardware.partitions.size == 0
|
49
|
-
end
|
50
|
-
|
51
|
-
def validate_os
|
52
|
-
raise ApplianceValidationError, "No operating system selected" if @appliance_config.os.name.nil?
|
53
|
-
end
|
54
|
-
|
55
|
-
def validate_repos
|
56
|
-
return if @appliance_config.repos.size == 0
|
57
|
-
|
58
|
-
@appliance_config.repos.each do |repo|
|
59
|
-
raise ApplianceValidationError, "Not valid repo format: '#{repo}' is wrong value. Please correct your appliance definition file, thanks." unless repo.class.eql?(Hash)
|
60
|
-
raise ApplianceValidationError, "Not valid repo format: Please specify name for repository. Please correct your appliance definition file, thanks." unless repo.keys.include?('name')
|
61
|
-
raise ApplianceValidationError, "Not valid repo format: There is no 'mirrorlist' or 'baseurl' specified for '#{repo['name']}' repository. Please correct your appliance definition file, thanks." unless repo.keys.include?('mirrorlist') or repo.keys.include?('baseurl')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|