forked from ManageIQ/manageiq-providers-redfish
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These operations are triggered by identify menu actions in the UI.
- Loading branch information
Tadej Borovšak
committed
Jun 8, 2018
1 parent
43e583f
commit e3b0606
Showing
6 changed files
with
771 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/models/manageiq/providers/redfish/physical_infra_manager/operations/led.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
24 changes: 24 additions & 0 deletions
24
spec/models/manageiq/providers/redfish/physical_infra_manager/operations/led_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
236 changes: 236 additions & 0 deletions
236
...oviders_Redfish_PhysicalInfraManager/_blink_loc_led/makes_location_LED_start_blinking.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.