Class: Facter::Util::MellanoxInfiniband

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/util/mellanox_infiniband.rb

Overview

Class for Mellanox Infiniband fact functions

Constant Summary collapse

LSPCI_IB_REGEX =
%r{\s15b3:}

Class Method Summary collapse

Class Method Details

.count_ib_devicesInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the number of InfiniBand interfaces found in lspci output

Returns:

  • (Integer)


21
22
23
24
25
26
27
28
29
# File 'lib/facter/util/mellanox_infiniband.rb', line 21

def self.count_ib_devices
  count = 0
  if Facter::Util::Resolution.which('lspci')
    output = lspci
    matches = output.scan(LSPCI_IB_REGEX)
    count = matches.flatten.reject { |s| s.nil? }.length
  end
  count
end

.lspci(command = 'lspci -n 2>/dev/null') ⇒ Object

lspci is a delegating helper method intended to make it easier to stub the system call without affecting other calls to Facter::Core::Execution.exec



8
9
10
11
12
13
# File 'lib/facter/util/mellanox_infiniband.rb', line 8

def self.lspci(command = 'lspci -n 2>/dev/null')
  # TODO: Deprecated in facter-2.0
  Facter::Util::Resolution.exec command
  # TODO: Not supported in facter < 2.0
  # Facter::Core::Execution.exec command
end