From 12569036377dbec2fa2e22531c0ee687ee6239f1 Mon Sep 17 00:00:00 2001 From: Tim Skirvin Date: Tue, 23 Jul 2024 09:58:03 -0500 Subject: [PATCH] infiniband_fw_versions.rb - report on all firmware versions --- CHANGELOG.md | 6 ++++++ lib/facter/infiniband_fw_versions.rb | 29 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 lib/facter/infiniband_fw_versions.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 9beb256..8750c24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). +## Unreleased + +- tskirvin: adding `infiniband_fw_versions.rb` to report multiple firmware + versions on different adapters + ## [v4.1.0](https://github.com/treydock/puppet-infiniband/tree/v4.1.0) (2022-08-22) [Full Changelog](https://github.com/treydock/puppet-infiniband/compare/v4.0.0...v4.1.0) ### Added + - Replace CentOS 8 support with Rocky/AlmaLinux 8 [\#34](https://github.com/treydock/puppet-infiniband/pull/34) ([treydock](https://github.com/treydock)) - Mirror puppet-module-mofed nm\_controlled behavior [\#33](https://github.com/treydock/puppet-infiniband/pull/33) ([pedmon](https://github.com/pedmon)) diff --git a/lib/facter/infiniband_fw_versions.rb b/lib/facter/infiniband_fw_versions.rb new file mode 100644 index 0000000..b0b972a --- /dev/null +++ b/lib/facter/infiniband_fw_versions.rb @@ -0,0 +1,29 @@ +# Fact: infiniband_fw_versions +# +# Purpose: Report the version of all InfiniBand hardware +# +# Resolution: +# Returns InfiniBand device FW Versions +# + +require 'facter/util/infiniband' + +Facter.add(:infiniband_fw_versions) do + confine has_infiniband: true + ports = Facter::Util::Infiniband.ports + setcode do + versions = {} + ports.each do |port| + fw_version = Facter::Util::Infiniband.get_port_fw_version(port) + if fw_version + versions[port] = fw_version + end + end + + if versions.empty? + nil + else + versions + end + end +end