class RedfishTools::Server
Attributes
datastore[R]
login_path[R]
password[R]
username[R]
Public Class Methods
new(datastore, username, password, config = {})
click to toggle source
Calls superclass method
# File lib/redfish_tools/server.rb, line 12 def initialize(datastore, username, password, config = {}) super(config) @datastore = datastore root = datastore.get("/redfish/v1").body @login_path = root.dig("Links", "Sessions", "@odata.id")&.chomp("/") @username = username @password = password mount("/", Servlet) end
Public Instance Methods
actions()
click to toggle source
# File lib/redfish_tools/server.rb, line 31 def actions # Hash of action_id => system_id @actions ||= load_all_actions end
basic_auth_header()
click to toggle source
# File lib/redfish_tools/server.rb, line 26 def basic_auth_header @basic_auth_header ||= "Basic " + Base64.strict_encode64("#{username}:#{password}") end
systems()
click to toggle source
# File lib/redfish_tools/server.rb, line 36 def systems @systems ||= load_all_system_ids end
Private Instance Methods
load_all_actions()
click to toggle source
# File lib/redfish_tools/server.rb, line 47 def load_all_actions load_all_system_actions.merge(load_update_actions) end
load_all_system_actions()
click to toggle source
# File lib/redfish_tools/server.rb, line 51 def load_all_system_actions systems_id = datastore.get("/redfish/v1").body["Systems"]["@odata.id"] datastore.get(systems_id).body["Members"].reduce({}) do |acc, link| acc.merge(load_system_actions(link["@odata.id"])) end end
load_all_system_ids()
click to toggle source
# File lib/redfish_tools/server.rb, line 42 def load_all_system_ids systems_id = datastore.get("/redfish/v1").body["Systems"]["@odata.id"] datastore.get(systems_id).body["Members"].map { |l| l["@odata.id"] } end
load_system_actions(id)
click to toggle source
# File lib/redfish_tools/server.rb, line 58 def load_system_actions(id) actions = datastore.get(id).body.dig("Actions") || {} actions.each_with_object({}) do |(name, data), acc| acc[data["target"]] = { name: name, id: id } end end
load_update_actions()
click to toggle source
# File lib/redfish_tools/server.rb, line 65 def load_update_actions update_service_id = datastore.get("/redfish/v1").body.dig( "UpdateService", "@odata.id", ) return {} if update_service_id.nil? actions = datastore.get(update_service_id).body["Actions"] || {} actions.each_with_object({}) do |(name, data), acc| acc[data["target"]] = { name: name, id: update_service_id } end end