Sha256: 963b59060c839b1dff12d61a2947b6a2df87858e46645b6dfab4e4bc6468da80

Contents?: true

Size: 1.95 KB

Versions: 19

Compression:

Stored size: 1.95 KB

Contents

# frozen_string_literal: true

module Facter
  module Util
    module Aix
      module InfoExtractor
        MEGABYTES_EXPONENT = 1024**2
        GIGABYTES_EXPONENT = 1024**3
        PROPERTIES = {
          lslv: [
            'LOGICAL VOLUME:',
            'VOLUME GROUP:',
            'LV IDENTIFIER:',
            'PERMISSION:',
            'VG STATE:',
            'LV STATE:',
            'TYPE:',
            'WRITE VERIFY:',
            'MAX LPs:',
            'PP SIZE:',
            'COPIES:',
            'SCHED POLICY:',
            'LPs:',
            'PPs:',
            'STALE PPs:',
            'BB POLICY:',
            'INTER-POLICY:',
            'RELOCATABLE:',
            'INTRA-POLICY:',
            'UPPER BOUND:',
            'MOUNT POINT:',
            'LABEL:',
            'MIRROR WRITE CONSISTENCY:',
            'EACH LP COPY ON A SEPARATE PV ?:',
            'Serialize IO ?:'
          ],
          lspv: [
            'PHYSICAL VOLUME:',
            'VOLUME GROUP:',
            'PV IDENTIFIER:',
            'VG IDENTIFIER',
            'PV STATE:',
            'STALE PARTITIONS:',
            'ALLOCATABLE:',
            'PP SIZE:',
            'LOGICAL VOLUMES:',
            'TOTAL PPs:',
            'VG DESCRIPTORS:',
            'FREE PPs:',
            'HOT SPARE:',
            'USED PPs:',
            'MAX REQUEST:',
            'FREE DISTRIBUTION:',
            'USED DISTRIBUTION:',
            'MIRROR POOL:'
          ]
        }.freeze

        def self.extract(content, cmd)
          property_hash = {}
          properties = PROPERTIES[cmd]
          properties.each do |property|
            str = (properties - [property]).join('|')
            matcher = content.match(/#{Regexp.escape(property)}([^\n]*?)(#{str}|\n|$)/s)
            if matcher
              value = matcher[1].strip
              property_hash[property.split(':').first] = value
            end
          end
          property_hash
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
facter-4.5.1 lib/facter/util/aix/info_extractor.rb
facter-4.5.0 lib/facter/util/aix/info_extractor.rb
facter-4.4.3 lib/facter/util/aix/info_extractor.rb
facter-4.4.2 lib/facter/util/aix/info_extractor.rb
facter-4.4.1 lib/facter/util/aix/info_extractor.rb
facter-4.4.0 lib/facter/util/aix/info_extractor.rb
facter-4.3.1 lib/facter/util/aix/info_extractor.rb
facter-4.3.0 lib/facter/util/aix/info_extractor.rb
facter-4.2.14 lib/facter/util/aix/info_extractor.rb
facter-4.2.13 lib/facter/util/aix/info_extractor.rb
facter-4.2.12 lib/facter/util/aix/info_extractor.rb
facter-4.2.11 lib/facter/util/aix/info_extractor.rb
facter-4.2.10 lib/facter/util/aix/info_extractor.rb
facter-4.2.9 lib/facter/util/aix/info_extractor.rb
facter-4.2.8 lib/facter/util/aix/info_extractor.rb
facter-4.2.7 lib/facter/util/aix/info_extractor.rb
facter-4.2.6 lib/facter/util/aix/info_extractor.rb
facter-4.2.5 lib/facter/util/aix/info_extractor.rb
facter-4.2.4 lib/facter/util/aix/info_extractor.rb