Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/host/managed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ def bmc_proxy
def bmc_available?
ipmi = bmc_nic
return false if ipmi.nil?
(ipmi.credentials_present? && %w(IPMI Redfish).include?(ipmi.provider)) || ipmi.provider == 'SSH'
(ipmi.credentials_present? && %w(IPMI Redfish).include?(ipmi.provider))

@evgeni evgeni May 15, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is already merged, but given IPMI and Redfish are the only providers left, this could be:

Suggested change
(ipmi.credentials_present? && %w(IPMI Redfish).include?(ipmi.provider))
ipmi.credentials_present?

the "credentials present and IPMI/Redfish" was only needed to shortcut to "or SSH"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, this was done like this since 40df7df (and only a8d5cb3 added a second BMC implementation)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looking at #7616 , it added credentials must be present if provider is Redfish or IPMI.

I have created a updated the logic #10987 , should it have its own redmine or there is a way to link 2 PRs to one redmine?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO you can just do Refs #39321 as that's not in a released version of Foreman yet.

end
alias_method :bmc_available, :bmc_available?

Expand Down
2 changes: 1 addition & 1 deletion app/models/nic/bmc.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Nic
class BMC < Managed
PROVIDERS = %w(IPMI Redfish SSH)
PROVIDERS = %w(IPMI Redfish)
before_validation :ensure_physical
before_validation { |nic| nic.provider == 'Redfish' || nic.provider.try(:upcase!) }
validates :provider, :presence => true, :inclusion => { :in => PROVIDERS }
Expand Down
7 changes: 0 additions & 7 deletions test/models/nics/bmc_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ class BMCTest < ActiveSupport::TestCase
assert host.bmc_available?
end

test 'BMC SSH availability' do
host = FactoryBot.build_stubbed(:host, :managed)
nic = FactoryBot.build_stubbed(:nic_bmc, :host => host, :provider => 'SSH', :subnet => subnets(:one))
host.expects(:bmc_nic).returns(nic)
assert host.bmc_available?
end

test 'upcasing provider does not fail if provider is not present' do
host = FactoryBot.build_stubbed(:host, :managed)
assert_nothing_raised do
Expand Down
Loading