| Class | BoxGrinder::ApplianceConfig |
| In: |
lib/boxgrinder-core/models/appliance-config.rb
lib/boxgrinder-core/models/appliance-config.rb |
| Parent: | Object |
| appliances | [RW] | |
| appliances | [RW] | |
| default_repos | [RW] | |
| default_repos | [RW] | |
| files | [R] | |
| files | [R] | |
| hardware | [R] | |
| hardware | [R] | |
| name | [RW] | |
| name | [RW] | |
| os | [R] | |
| os | [R] | |
| packages | [RW] | |
| packages | [RW] | |
| path | [R] | |
| path | [R] | |
| post | [R] | |
| post | [R] | |
| release | [RW] | |
| release | [RW] | |
| repos | [RW] | |
| repos | [RW] | |
| summary | [RW] | |
| summary | [RW] | |
| variables | [R] | |
| variables | [R] | |
| version | [RW] | |
| version | [RW] |
# File lib/boxgrinder-core/models/appliance-config.rb, line 24
24: def initialize
25: @name = nil
26: @summary = nil
27:
28: @variables = {}
29:
30: @os = OpenCascade.new
31:
32: @os.name = nil
33: @os.version = nil
34: @os.password = nil
35: @os.pae = true
36:
37: @hardware = OpenCascade.new
38:
39: @hardware.cpus = 1
40: @hardware.memory = 256
41: @hardware.network = 'NAT'
42: @hardware.partitions = {"/" => {'size' => 1}}
43:
44: @default_repos = true
45:
46: @post = {}
47: @files = {}
48:
49: @packages = []
50: @appliances = []
51: @repos = []
52:
53: @version = 1
54: @release = 0
55: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 24
24: def initialize
25: @name = nil
26: @summary = nil
27:
28: @variables = {}
29:
30: @os = OpenCascade.new
31:
32: @os.name = nil
33: @os.version = nil
34: @os.password = nil
35: @os.pae = true
36:
37: @hardware = OpenCascade.new
38:
39: @hardware.cpus = 1
40: @hardware.memory = 256
41: @hardware.network = 'NAT'
42: @hardware.partitions = {"/" => {'size' => 1}}
43:
44: @default_repos = true
45:
46: @post = {}
47: @files = {}
48:
49: @packages = []
50: @appliances = []
51: @repos = []
52:
53: @version = 1
54: @release = 0
55: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 97
97: def all_values(input=nil)
98: avoid = ['@variables']
99: input = (self.instance_variables - avoid).
100: collect{ |v| self.instance_variable_get(v) } if input.nil?
101:
102: vars = input.inject([]) do |arr, var|
103: case var
104: when Hash
105: arr.concat(all_values(var.values))
106: when Array
107: arr.concat(all_values(var))
108: when String
109: arr.push var
110: end
111: arr
112: end
113: vars
114: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 97
97: def all_values(input=nil)
98: avoid = ['@variables']
99: input = (self.instance_variables - avoid).
100: collect{ |v| self.instance_variable_get(v) } if input.nil?
101:
102: vars = input.inject([]) do |arr, var|
103: case var
104: when Hash
105: arr.concat(all_values(var.values))
106: when Array
107: arr.concat(all_values(var))
108: when String
109: arr.push var
110: end
111: arr
112: end
113: vars
114: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 146
146: def clone
147: Marshal::load(Marshal.dump(self))
148: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 146
146: def clone
147: Marshal::load(Marshal.dump(self))
148: end
Returns default filesystem type for current OS
# File lib/boxgrinder-core/models/appliance-config.rb, line 117
117: def default_filesystem_type
118: fs = 'ext4'
119:
120: # Since RHEL 5.6 the default filesystem is ext4
121: #
122: # case @os.name
123: # when 'rhel', 'centos'
124: # case @os.version
125: # when '5'
126: # fs = 'ext3'
127: # end
128: # end
129:
130: fs
131: end
Returns default filesystem type for current OS
# File lib/boxgrinder-core/models/appliance-config.rb, line 117
117: def default_filesystem_type
118: fs = 'ext4'
119:
120: # Since RHEL 5.6 the default filesystem is ext4
121: #
122: # case @os.name
123: # when 'rhel', 'centos'
124: # case @os.version
125: # when '5'
126: # fs = 'ext3'
127: # end
128: # end
129:
130: fs
131: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 138
138: def eql?(other)
139: hash.eql?(other.hash)
140: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 138
138: def eql?(other)
139: hash.eql?(other.hash)
140: end
used to checking if configuration differs from previous in appliance-kickstart
# File lib/boxgrinder-core/models/appliance-config.rb, line 134
134: def hash
135: "#{@name}-#{@summary}-#{@version}-#{@release}-#{@os.name}-#{@os.version}-#{@os.password}-#{@hardware.cpus}-#{@hardware.memory}-#{@hardware.partitions}-#{@appliances}".hash
136: end
used to checking if configuration differs from previous in appliance-kickstart
# File lib/boxgrinder-core/models/appliance-config.rb, line 134
134: def hash
135: "#{@name}-#{@summary}-#{@version}-#{@release}-#{@os.name}-#{@os.version}-#{@os.password}-#{@hardware.cpus}-#{@hardware.memory}-#{@hardware.partitions}-#{@appliances}".hash
136: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 73
73: def init
74: init_arch
75: initialize_paths
76: self
77: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 73
73: def init
74: init_arch
75: initialize_paths
76: self
77: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 79
79: def init_arch
80: @hardware.arch = `uname -m`.chomp.strip
81: @hardware.base_arch = is64bit? ? "x86_64" : "i386"
82: self
83: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 79
79: def init_arch
80: @hardware.arch = `uname -m`.chomp.strip
81: @hardware.base_arch = is64bit? ? "x86_64" : "i386"
82: self
83: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 85
85: def initialize_paths
86: @path = OpenCascade.new
87:
88: @path.os = "#{@os.name}/#{@os.version}"
89: @path.version = "#{@version}.#{@release}"
90: @path.main = "#{@hardware.arch}/#{@path.os}"
91: @path.appliance = "appliances/#{@path.main}/#{@name}/#{@path.version}"
92: @path.build = "build/#{@path.appliance}"
93:
94: self
95: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 85
85: def initialize_paths
86: @path = OpenCascade.new
87:
88: @path.os = "#{@os.name}/#{@os.version}"
89: @path.version = "#{@version}.#{@release}"
90: @path.main = "#{@hardware.arch}/#{@path.os}"
91: @path.appliance = "appliances/#{@path.main}/#{@name}/#{@path.version}"
92: @path.build = "build/#{@path.appliance}"
93:
94: self
95: end
# File lib/boxgrinder-core/models/appliance-config.rb, line 142
142: def is64bit?
143: @hardware.arch.eql?("x86_64")
144: end