Class: Device
- Inherits:
-
Object
- Object
- Device
- Defined in:
- lib/AIX/device.rb
Instance Attribute Summary collapse
-
#attr_default ⇒ Object
readonly
Returns the value of attribute attr_default.
-
#attr_odm ⇒ Object
readonly
Returns the value of attribute attr_odm.
-
#attr_running ⇒ Object
readonly
Returns the value of attribute attr_running.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#initialize ⇒ Device
constructor
A new instance of Device.
- #set_attr(string, type = 'odm') ⇒ Object
- #validate ⇒ Object
-
#validate_attr_odm_running ⇒ Object
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.
Constructor Details
#initialize ⇒ Device
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_default ⇒ Object (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_odm ⇒ Object (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_running ⇒ Object (readonly)
Returns the value of attribute attr_running.
8 9 10 |
# File 'lib/AIX/device.rb', line 8 def attr_running @attr_running end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
11 12 13 |
# File 'lib/AIX/device.rb', line 11 def errors @errors end |
#warnings ⇒ Object (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 |
#validate ⇒ Object
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_running ⇒ Object
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
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 |