Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add location LED operations #7

Merged
merged 1 commit into from
Jun 8, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ module PhysicalInfraManager::Operations
extend ActiveSupport::Concern

include_concern "Power"
include_concern "Led"
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module ManageIQ::Providers::Redfish
module PhysicalInfraManager::Operations::Led
# Keep this in sync with app/models/physical_server/operations/led.rb in
# core and IndicatorLED enum in Redfish ComputerSystem type. Name of the
# method comes from the core and the action name used in the reset call
# from the IndicatorLED enum.

def blink_loc_led(server, _options)
set_led_state("Blinking", server)
end

def turn_on_loc_led(server, _options)
set_led_state("Lit", server)
end

def turn_off_loc_led(server, _options)
set_led_state("Off", server)
end

private

def set_led_state(state, server)
$redfish_log.info("Setting #{server.ems_ref} LED state to #{state}.")
with_provider_connection do |client|
system = client.find(server.ems_ref)
if system.nil?
$redfish_log.error("#{server.ems_ref} does not exist anymore.")
return
end

response = system.patch(:payload => { "IndicatorLED" => state })
unless response.status == 200
$redfish_log.error("LED state change on #{server.ems_ref} failed.")
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
describe ManageIQ::Providers::Redfish::PhysicalInfraManager do
let(:server) { FactoryGirl.create(:redfish_physical_server, :vcr) }
subject(:ems) do
FactoryGirl.create(:ems_redfish_physical_infra, :vcr)
end

describe "#blink_loc_led", :vcr do
it "makes location LED start blinking" do
ems.blink_loc_led(server, nil)
end
end

describe "#turn_on_loc_led", :vcr do
it "turns on location LED" do
ems.turn_on_loc_led(server, nil)
end
end

describe "#turn_off_loc_led", :vcr do
it "turns off location LED" do
ems.turn_off_loc_led(server, nil)
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading