Module: IDRAC::License
- Included in:
- Client
- Defined in:
- lib/idrac/license.rb
Instance Method Summary collapse
-
#license_info ⇒ Hash
Gets the license information from the iDRAC.
-
#license_version ⇒ Integer?
Extracts the iDRAC version from the license description or server header.
Instance Method Details
#license_info ⇒ Hash
Gets the license information from the iDRAC
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/idrac/license.rb', line 5 def license_info # Try the standard license endpoint first (works in iDRAC 9+) response = authenticated_request(:get, "/redfish/v1/LicenseService/Licenses") if response.status == 200 license_data = JSON.parse(response.body) debug "License collection: #{license_data}", 2 # Check if there are any license entries if !license_data["Members"] || license_data["Members"].empty? debug "No licenses found", 1, :yellow return try_dell_oem_license_path() end # Get the first license in the list license_uri = license_data["Members"][0]["@odata.id"] debug "Using license URI: #{license_uri}", 2 # Get detailed license information license_response = authenticated_request(:get, license_uri) if license_response.status != 200 debug "Failed to retrieve license details: #{license_response.status}", 1, :red return try_dell_oem_license_path() end license_details = JSON.parse(license_response.body) debug "License details: #{license_details}", 2 return license_details else # The endpoint is not available (probably iDRAC 8) debug "Standard license endpoint failed: #{response.status}, trying Dell OEM path", 1, :yellow return try_dell_oem_license_path() end end |
#license_version ⇒ Integer?
Extracts the iDRAC version from the license description or server header
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/idrac/license.rb', line 43 def license_version # First try to get from license info license = license_info if license # Check the Description field, which often contains the version # Example: "iDRAC9 Enterprise License" if license["Description"]&.match(/iDRAC(\d+)/i) version = license["Description"].match(/iDRAC(\d+)/i)[1].to_i debug "Found license version from Description: #{version}", 1 return version end # Try alternative fields if Description didn't work if license["Name"]&.match(/iDRAC(\d+)/i) version = license["Name"].match(/iDRAC(\d+)/i)[1].to_i debug "Found license version from Name: #{version}", 1 return version end # For Dell OEM license response format if license["LicenseDescription"]&.match(/iDRAC(\d+)/i) version = license["LicenseDescription"].match(/iDRAC(\d+)/i)[1].to_i debug "Found license version from LicenseDescription: #{version}", 1 return version end end # If license info failed or didn't have version info, try to get from server header # Make a simple request to check the server header (often contains iDRAC version) response = authenticated_request(:get, "/redfish/v1") if response.headers["server"] && response.headers["server"].match(/iDRAC\/(\d+)/i) version = response.headers["server"].match(/iDRAC\/(\d+)/i)[1].to_i debug "Found license version from server header: #{version}", 1 return version end debug "Could not determine license version from license info or server header", 1, :yellow nil end |