forked from ManageIQ/manageiq-api
-
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.
Merge pull request ManageIQ#410 from douglasgabriel/ph_chassis_actions
Adding Physical Chassis Location LED actions
- Loading branch information
Showing
3 changed files
with
123 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,22 @@ | ||
module Api | ||
class PhysicalChassisController < BaseController | ||
include Subcollections::EventStreams | ||
include Api::Mixins::Operations | ||
|
||
def refresh_resource(type, id, _data = nil) | ||
raise BadRequestError, "Must specify an id for refreshing a #{type} resource" if id.blank? | ||
|
||
ensure_resource_exists(type, id) if single_resource? | ||
|
||
api_action(type, id) do |klass| | ||
physical_chassis = resource_search(id, type, klass) | ||
api_log_info("Refreshing #{physical_chassis_ident(physical_chassis)}") | ||
refresh_physical_chassis(physical_chassis) | ||
end | ||
end | ||
|
||
private | ||
|
||
def ensure_resource_exists(type, id) | ||
raise NotFoundError, "#{type} with id:#{id} not found" unless collection_class(type).exists?(id) | ||
def blink_loc_led_resource(type, id, _data) | ||
perform_action(:blink_loc_led, type, id) | ||
end | ||
|
||
def refresh_physical_chassis(physical_chassis) | ||
method_name = "refresh_ems" | ||
role = "ems_operations" | ||
|
||
act_refresh(physical_chassis, method_name, role) | ||
rescue => err | ||
action_result(false, err.to_s) | ||
def turn_on_loc_led_resource(type, id, _data) | ||
perform_action(:turn_on_loc_led, type, id) | ||
end | ||
|
||
def physical_chassis_ident(physical_chassis) | ||
"Physical Chassis id:#{physical_chassis.id} name:'#{physical_chassis.name}'" | ||
def turn_off_loc_led_resource(type, id, _data) | ||
perform_action(:turn_off_loc_led, type, id) | ||
end | ||
|
||
def act_refresh(physical_chassis, method_name, role) | ||
desc = "#{physical_chassis_ident(physical_chassis)} refreshing" | ||
task_id = queue_object_action(physical_chassis, desc, :method_name => method_name, :role => role) | ||
action_result(true, desc, :task_id => task_id) | ||
def refresh_resource(type, id, _data = nil) | ||
perform_action(:refresh_ems, type, id) | ||
end | ||
end | ||
end |
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
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