Skip to content

Commit

Permalink
Merge pull request #7 from xlab-si/location-led-operations
Browse files Browse the repository at this point in the history
Add location LED operations
  • Loading branch information
agrare authored Jun 8, 2018
2 parents 43e583f + e3b0606 commit 5263636
Show file tree
Hide file tree
Showing 6 changed files with 771 additions and 0 deletions.
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

0 comments on commit 5263636

Please sign in to comment.