Class: Device

Inherits:
Object
  • Object
show all
Defined in:
lib/AIX/device.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDevice

Returns a new instance of Device.



13
14
15
16
17
18
19
20
21
# File 'lib/AIX/device.rb', line 13

def initialize

  @attr_odm     = Array.new
  @attr_default = Array.new
  @attr_running = Array.new

  @warnings = Array.new
  @errors   = Array.new
end

Instance Attribute Details

#attr_defaultObject (readonly)

Returns the value of attribute attr_default.



7
8
9
# File 'lib/AIX/device.rb', line 7

def attr_default
  @attr_default
end

#attr_odmObject (readonly)

Returns the value of attribute attr_odm.



6
7
8
# File 'lib/AIX/device.rb', line 6

def attr_odm
  @attr_odm
end

#attr_runningObject (readonly)

Returns the value of attribute attr_running.



8
9
10
# File 'lib/AIX/device.rb', line 8

def attr_running
  @attr_running
end

#errorsObject (readonly)

Returns the value of attribute errors.



11
12
13
# File 'lib/AIX/device.rb', line 11

def errors
  @errors
end

#warningsObject (readonly)

Returns the value of attribute warnings.



10
11
12
# File 'lib/AIX/device.rb', line 10

def warnings
  @warnings
end

Instance Method Details

#set_attr(string, type = 'odm') ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/AIX/device.rb', line 23

def set_attr(string, type='odm')

  array = Array.new

  if (string.include?(':'))
    array = lsattr_O(string)
  else
    array = lsattr(string)
  end

  case type
    when 'odm' then @attr_odm = array
    when 'default' then @attr_default = array
    when 'running' then @attr_running = array
    else
      raise "can't setup attr, unknown type"
  end

end

#validateObject



43
44
45
46
47
48
# File 'lib/AIX/device.rb', line 43

def validate

  result = true

  result = false unless self.validate_attr_odm_running
end

#validate_attr_odm_runningObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/AIX/device.rb', line 53

def validate_attr_odm_running

    result = true

    if @attr_odm.size > 0 and @attr_running.size > 0
      @attr_odm.keys.each do |key|
        if @attr_odm[key]['value'] != @attr_running[key]['value']
          @warnings.push("#{key}: ODM value #{@attr_odm[key]['value']} is different from running: #{@attr_running[key]['value']}")
          result = false
        end
      end
  end

  result
end