Class BoxGrinder::ApplianceConfig
In: lib/boxgrinder-core/models/appliance-config.rb
lib/boxgrinder-core/models/appliance-config.rb
Parent: Object

Methods

Attributes

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] 

Public Class methods

[Source]

    # File lib/boxgrinder-core/models/appliance-config.rb, line 25
25:     def initialize
26:       @name = nil
27:       @summary = nil
28: 
29:       @default_repos = true
30: 
31:       @os = OpenCascade.new
32: 
33:       @os.name = nil
34:       @os.version = nil
35:       @os.password = nil
36:       @os.pae = true
37: 
38:       @hardware = OpenCascade.new
39: 
40:       @hardware.cpus = 1
41:       @hardware.memory = 256
42:       @hardware.network = 'NAT'
43:       @hardware.partitions = {"/" => {'size' => 1}}
44: 
45:       @variables = {}
46:       @post = {}
47:       @files = {}
48: 
49:       @packages = []
50:       @appliances = []
51:       @repos = []
52: 
53:       @version = 1
54:       @release = 0
55:     end

[Source]

    # File lib/boxgrinder-core/models/appliance-config.rb, line 25
25:     def initialize
26:       @name = nil
27:       @summary = nil
28: 
29:       @default_repos = true
30: 
31:       @os = OpenCascade.new
32: 
33:       @os.name = nil
34:       @os.version = nil
35:       @os.password = nil
36:       @os.pae = true
37: 
38:       @hardware = OpenCascade.new
39: 
40:       @hardware.cpus = 1
41:       @hardware.memory = 256
42:       @hardware.network = 'NAT'
43:       @hardware.partitions = {"/" => {'size' => 1}}
44: 
45:       @variables = {}
46:       @post = {}
47:       @files = {}
48: 
49:       @packages = []
50:       @appliances = []
51:       @repos = []
52: 
53:       @version = 1
54:       @release = 0
55:     end

Public Instance methods

[Source]

    # File lib/boxgrinder-core/models/appliance-config.rb, line 73
73:     def [](k)
74:       instance_variable_get("@#{k}")
75:     end

[Source]

    # File lib/boxgrinder-core/models/appliance-config.rb, line 73
73:     def [](k)
74:       instance_variable_get("@#{k}")
75:     end

[Source]

    # File lib/boxgrinder-core/models/appliance-config.rb, line 77
77:     def []=(k, v)
78:       case k
79:         when "hardware"
80:           @hardware.cpus = v['cpus'] if v['cpus']
81:           @hardware.memory = v['memory'] if v['memory']
82:           @hardware.network = v['network'] if v['network']
83:           @hardware.partitions = v['partitions'] if v['partitions']
84:         when "os"
85:           @os.name = v['name'] if v['name']
86:           @os.version = v['version'] if v['version']
87:           @os.password = v['password'] if v['password']
88:           # TODO this is OS specific, move it to OS plugin!
89:           @os.pae = false if v['pae'] == false
90:         else
91:           instance_variable_set("@#{k}", v)
92:       end
93: 
94:     end

[Source]

    # File lib/boxgrinder-core/models/appliance-config.rb, line 77
77:     def []=(k, v)
78:       case k
79:         when "hardware"
80:           @hardware.cpus = v['cpus'] if v['cpus']
81:           @hardware.memory = v['memory'] if v['memory']
82:           @hardware.network = v['network'] if v['network']
83:           @hardware.partitions = v['partitions'] if v['partitions']
84:         when "os"
85:           @os.name = v['name'] if v['name']
86:           @os.version = v['version'] if v['version']
87:           @os.password = v['password'] if v['password']
88:           # TODO this is OS specific, move it to OS plugin!
89:           @os.pae = false if v['pae'] == false
90:         else
91:           instance_variable_set("@#{k}", v)
92:       end
93: 
94:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 120
120:     def all_values(input=nil)
121:       avoid     = ['@variables']
122:       input = (self.instance_variables - avoid).
123:         collect{ |v| self.instance_variable_get(v) } if input.nil?
124: 
125:       vars = input.inject([]) do |arr, var|
126:         case var
127:           when Hash
128:             arr.concat(all_values(var.values))
129:           when Array
130:             arr.concat(all_values(var))
131:           when String
132:             arr.push var
133:           end
134:         arr
135:         end
136:       vars
137:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 120
120:     def all_values(input=nil)
121:       avoid     = ['@variables']
122:       input = (self.instance_variables - avoid).
123:         collect{ |v| self.instance_variable_get(v) } if input.nil?
124: 
125:       vars = input.inject([]) do |arr, var|
126:         case var
127:           when Hash
128:             arr.concat(all_values(var.values))
129:           when Array
130:             arr.concat(all_values(var))
131:           when String
132:             arr.push var
133:           end
134:         arr
135:         end
136:       vars
137:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 169
169:     def clone
170:       Marshal::load(Marshal.dump(self))
171:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 169
169:     def clone
170:       Marshal::load(Marshal.dump(self))
171:     end

Returns default filesystem type for current OS

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 140
140:     def default_filesystem_type
141:       fs = 'ext4'
142: 
143: # Since RHEL 5.6 the default filesystem is ext4
144: #
145: #      case @os.name
146: #        when 'rhel', 'centos'
147: #          case @os.version
148: #            when '5'
149: #              fs = 'ext3'
150: #          end
151: #      end
152: 
153:       fs
154:     end

Returns default filesystem type for current OS

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 140
140:     def default_filesystem_type
141:       fs = 'ext4'
142: 
143: # Since RHEL 5.6 the default filesystem is ext4
144: #
145: #      case @os.name
146: #        when 'rhel', 'centos'
147: #          case @os.version
148: #            when '5'
149: #              fs = 'ext3'
150: #          end
151: #      end
152: 
153:       fs
154:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 161
161:     def eql?(other)
162:       hash.eql?(other.hash)
163:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 161
161:     def eql?(other)
162:       hash.eql?(other.hash)
163:     end

used to checking if configuration differs from previous in appliance-kickstart

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 157
157:     def hash
158:       "#{@name}-#{@summary}-#{@version}-#{@release}-#{@os.name}-#{@os.version}-#{@os.password}-#{@hardware.cpus}-#{@hardware.memory}-#{@hardware.partitions}-#{@appliances}".hash
159:     end

used to checking if configuration differs from previous in appliance-kickstart

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 157
157:     def hash
158:       "#{@name}-#{@summary}-#{@version}-#{@release}-#{@os.name}-#{@os.version}-#{@os.password}-#{@hardware.cpus}-#{@hardware.memory}-#{@hardware.partitions}-#{@appliances}".hash
159:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 96
 96:     def init
 97:       init_arch
 98:       initialize_paths
 99:       self
100:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 96
 96:     def init
 97:       init_arch
 98:       initialize_paths
 99:       self
100:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 102
102:     def init_arch
103:       @hardware.arch = `uname -m`.chomp.strip
104:       @hardware.base_arch = is64bit? ? "x86_64" : "i386"
105:       self
106:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 102
102:     def init_arch
103:       @hardware.arch = `uname -m`.chomp.strip
104:       @hardware.base_arch = is64bit? ? "x86_64" : "i386"
105:       self
106:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 108
108:     def initialize_paths
109:       @path = OpenCascade.new
110: 
111:       @path.os = "#{@os.name}/#{@os.version}"
112:       @path.version = "#{@version}.#{@release}"
113:       @path.main = "#{@hardware.arch}/#{@path.os}"
114:       @path.appliance = "appliances/#{@path.main}/#{@name}/#{@path.version}"
115:       @path.build = "build/#{@path.appliance}"
116: 
117:       self
118:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 108
108:     def initialize_paths
109:       @path = OpenCascade.new
110: 
111:       @path.os = "#{@os.name}/#{@os.version}"
112:       @path.version = "#{@version}.#{@release}"
113:       @path.main = "#{@hardware.arch}/#{@path.os}"
114:       @path.appliance = "appliances/#{@path.main}/#{@name}/#{@path.version}"
115:       @path.build = "build/#{@path.appliance}"
116: 
117:       self
118:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 165
165:     def is64bit?
166:       @hardware.arch.eql?("x86_64")
167:     end

[Source]

     # File lib/boxgrinder-core/models/appliance-config.rb, line 165
165:     def is64bit?
166:       @hardware.arch.eql?("x86_64")
167:     end

[Validate]