Sha256: 3d94398e7818c465e92ebadebdb77f1b013bc2c276477f8b46aa16e84b6de6d4

Contents?: true

Size: 923 Bytes

Versions: 178

Compression:

Stored size: 923 Bytes

Contents

module Specinfra
  class HostInventory
    class BlockDevice < Base
      # examples:
      #   /sys/block/sda/size	10000
      #   /sys/block/sr0/device/model	CD-ROM
      BLOCK_DEVICE_REGEX = %r|\A/sys/block/(\w+)/(\w+)(?:/(\w+))?\t(.+)\z|

      def get
        cmd = backend.command.get(:get_inventory_block_device)
        ret = backend.run_command(cmd)
        if ret.exit_status == 0
          parse(ret.stdout)
        else
          nil
        end
      end
      def parse(ret)
        block_device = {}
        ret.each_line do |line|
          line.strip!
          if m = line.match(BLOCK_DEVICE_REGEX)
            device = m[1].to_s
            check = m[3].nil? ? m[2].to_s : m[3].to_s
            value = m[4].to_s

            block_device[device] = {} if block_device[device].nil?
            block_device[device][check] = value
          end
        end
        block_device
      end
    end
  end
end

Version data entries

178 entries across 178 versions & 2 rubygems

Version Path
specinfra-2.91.0 lib/specinfra/host_inventory/block_device.rb
specinfra-2.90.1 lib/specinfra/host_inventory/block_device.rb
specinfra-2.90.0 lib/specinfra/host_inventory/block_device.rb
specinfra-2.89.0 lib/specinfra/host_inventory/block_device.rb
specinfra-2.88.2 lib/specinfra/host_inventory/block_device.rb
specinfra-2.88.1 lib/specinfra/host_inventory/block_device.rb
specinfra-2.88.0 lib/specinfra/host_inventory/block_device.rb
specinfra-2.87.2 lib/specinfra/host_inventory/block_device.rb
specinfra-2.87.1 lib/specinfra/host_inventory/block_device.rb
specinfra-2.87.0 lib/specinfra/host_inventory/block_device.rb
specinfra-2.86.0 lib/specinfra/host_inventory/block_device.rb
specinfra-2.85.1 lib/specinfra/host_inventory/block_device.rb
specinfra-2.85.0 lib/specinfra/host_inventory/block_device.rb
specinfra-2.84.1 lib/specinfra/host_inventory/block_device.rb
specinfra-2.84.0 lib/specinfra/host_inventory/block_device.rb
specinfra-2.83.4 lib/specinfra/host_inventory/block_device.rb
specinfra-2.83.3 lib/specinfra/host_inventory/block_device.rb
specinfra-2.83.2 lib/specinfra/host_inventory/block_device.rb
specinfra-2.83.1 lib/specinfra/host_inventory/block_device.rb
specinfra-2.83.0 lib/specinfra/host_inventory/block_device.rb