Class: Storcs::Parsers::Netapp
- Inherits:
-
Object
- Object
- Storcs::Parsers::Netapp
- Includes:
- Utils
- Defined in:
- lib/storcs/parsers/netapp.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
Returns the value of attribute device.
Instance Method Summary collapse
- #aggregates ⇒ Object
-
#initialize(name, file) ⇒ Netapp
constructor
A new instance of Netapp.
- #parse! ⇒ Object
Methods included from Utils
Constructor Details
#initialize(name, file) ⇒ Netapp
Returns a new instance of Netapp.
7 8 9 10 11 |
# File 'lib/storcs/parsers/netapp.rb', line 7 def initialize(name, file) @device = Storcs::Device.new(name) @lines = File.readlines(file) parse! end |
Instance Attribute Details
#device ⇒ Object
Returns the value of attribute device.
5 6 7 |
# File 'lib/storcs/parsers/netapp.rb', line 5 def device @device end |
Instance Method Details
#aggregates ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/storcs/parsers/netapp.rb', line 17 def aggregates return @aggregates if @aggregates @aggregates = [] state = nil current_aggr = nil current_aggr_usable_size = 0 @lines.each do |line| # Aggregate 'aggr0' if line =~ /^Aggregate '([^']*)'/ name = Regexp.last_match[1] current_aggr = Storcs::Device.new(name) current_aggr.children = [] state = :aggr elsif state == :aggr case line # Volume Allocated Used Guarantee when /^Volume.+Allocated/ state = :volume # Total space 492030416KB 12922692KB 23052692KB when /^Total space\s+(.*)$/ data = Regexp.last_match[1] alloc = parse_size(data.split(/\s+/).first) current_aggr.real_unassigned = current_aggr_usable_size - alloc current_aggr_usable_size = 0 # Snap reserve 0KB 1406504KB 0KB when /^Snap reserve\s+(.*)$/ data = Regexp.last_match[1] vol = Storcs::Device.new('Snapshots') size = parse_size(data.split(/\s+/)[1]) vol.real_size = vol.real_used = size current_aggr.children << vol current_aggr.real_unassigned -= size @aggregates << current_aggr current_aggr = nil # Total space WAFL reserve Snap reserve ... when /^\s+Total space/ state = :aggr_total end # 573419008KB 57341880KB 0KB 516077128KB 0KB 0KB 0KB elsif state == :aggr_total usable_size = line.split(/\s+/)[4] current_aggr_usable_size = parse_size(usable_size) state = :aggr elsif state == :volume case line when /^\s*$/ state = :aggr # vol0 492030416KB 12922692KB volume else name, alloc, used = line.split(/\s+/) vol = Storcs::Device.new(name) vol.real_size = parse_size(alloc) vol.real_used = parse_size(used) current_aggr.children << vol end end end @aggregates end |
#parse! ⇒ Object
13 14 15 |
# File 'lib/storcs/parsers/netapp.rb', line 13 def parse! @device.children = aggregates end |