class Device

Attributes

attr_default[R]
attr_odm[R]
attr_running[R]
errors[R]
warnings[R]

Public Class Methods

new() click to toggle source
# 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

Public Instance Methods

set_attr(string, type='odm') click to toggle source
# 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
validate() click to toggle source
# File lib/AIX/device.rb, line 43
def validate

  result = true

  result = false unless self.validate_attr_odm_running
end
validate_attr_odm_running() click to toggle source

let's compare running settings with those from ODM the idea is taken from: www.ibm.com/developerworks/community/blogs/brian/entry/script_to_show_if_aix_device_attributes_are_actually_in_effect?lang=en

# 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