dell / iDRAC-Redfish-Scripting

Python and PowerShell scripting for Dell EMC PowerEdge iDRAC REST API with DMTF Redfish
GNU General Public License v2.0
584 stars 273 forks source link

PowerShell Get-IdracLifecycleLogsREDFISH options #269

Closed jgranduel closed 6 months ago

jgranduel commented 9 months ago

Hi,

Redfish Python GetIdracLcLogsREDFISH.py allows a fine query of iDRAC logs, specifically passing a start and end date.

GetIdracLcLogsREDFISH.py [-h] [-ip IP] [-u U] [-p P] [-x X] [--ssl SSL] [--script-examples] [--get-all] [--get-severity GET_SEVERITY] [--get-category GET_CATEGORY]  [--get-date-range] [--start-date START_DATE] [--end-date END_DATE] [--get-fail] [--get-message-id GET_MESSAGE_ID]

Will PowerShell Cmdlet (Get-IdracLifecycleLogsREDFISH) be on par with Python scripts in the coming future ? I may have missed cmdlet options maybe. Thanks

texroemer commented 9 months ago

Hi @jgranduel

Yes plan is to update the cmdlet to be in sync with python script. I just made multiple changes to the python script, will update the cmdlet and let you know once it's ready.

Thanks Tex

texroemer commented 9 months ago

Hi @jgranduel

Get-IdracLifecycleLogsREDFISH cmdlet has been updated with similar argument support to compared to python script. Please see cmdlet help text and examples for more details.

Thanks Tex

jgranduel commented 9 months ago

Hi,

I installed IdracRedfishSupport version 22.5.0.0 along version 22.3.0.0 (Install-Module -Name IdracRedfishSupport -Force).

Unfortunately I cannot make it work, but it works with version 22.3:

Get-IdracLifecycleLogsREDFISH -idrac_ip <IP> -idrac_username root -Verbose -OutVariable l

PowerShell credential request
Enter iDRAC username and password to run cmdlet
User: root
Password for user root: ************

- FAIL, either incorrect parameter(s) used or missing required parameters(s), please see help or examples for more information.

Some other suggestions:

Thanks!

texroemer commented 9 months ago

Hi @jgranduel

Fixed the bug where it prompts you to enter username again if you pass in username argument for Get-Credential.

image

To get examples leverage Get-Help and -examples for each cmdlet.

image

For get_severity argument you need to see help text for supported possible values.

image

Thanks Tex

jgranduel commented 8 months ago

Hi, for possible values for get_severity, I added [ValidateSet("critical","warning", "informational")]

    [ValidateSet("critical", "warning", "informational")]
    [Parameter(Mandatory=$False)]
    [string]$get_severity

to the parameters for the sake of completion...

texroemer commented 8 months ago

@jgranduel Thanks for clearing up the ask for possible values reported, changes have been made and checked in. Please try out latest version and let me know.

Thanks Tex

jgranduel commented 8 months ago

I've tried latest version (22.9.0.0). A few things don't work for me:

 > get-idracLifecycleLogsREDFISH -idrac_ip <IP>  -idrac_username root

- FAIL, either incorrect parameter(s) used or missing required parameters(s), please see help or examples for more information.

Option get_all doesn't return anything (but works fine with Python) :

-  get-idracLifecycleLogsREDFISH -idrac_ip <IP>  -idrac_username root -get_all -Verbose

- INFO, getting Lifecycle Logs for iDRAC <IP> This may take a few minutes to complete depending on log file size

VERBOSE: HTTP/1.1 GET with 0-byte payload
VERBOSE: received 365-byte response of content type application/json

- INFO, cmdlet execution complete. Note: If needed, execute cmdlet again and redirect output to a file.

The URL that's built is this one as you know: https://<IP>/redfish/v1/Managers/iDRAC.Embedded.1/LogServices/Lclog/Entries?$skip=0, but doesn't work in my version:

curl -s -k -uroot:$($idracCreds.GetNetworkCredential().Password) 'https://<IP>/redfish/v1/Managers/iDRAC.Embedded.1/LogServices/Lclog/Entries?$skip=0' | jq
{
  "error": {
    "code": "Base.1.0.GeneralError",
    "message": "A general error has occurred. See ExtendedInfo for more information.",
    "@Message.ExtendedInfo": [
      {
        "@odata.type": "#Message.v1_0_0.Message",
        "MessageId": "Base.1.0.InternalError",
        "Message": "not supported, Query parameter skip not supported"
      }
    ]
  }
}

Equivalent result with Invoke-WebRequest of course.

- get-idracLifecycleLogsREDFISH -idrac_ip <IP> -idrac_username root -get_category updates -Verbose

- INFO, getting 'updates' category entries from LC logs. This may take a few minutes to complete depending on LC log size
VERBOSE: HTTP/1.1 GET with 0-byte payload
VERBOSE: received 532-byte response of content type application/json
- WARNING, no 'updates' category entries detected in LC logs

same for audit, configuration, storage and so on.

Maybe precising iDRAC version in .SYNOPSIS would help in telling which features and options are supported? redfish/v1/Managers/iDRAC.Embedded.1/LogServices/Lclog/Entries is not supported I think.

I compared with Python version, and indeed there is the distinction between new and old iDRAC versions in PowerShell as there is in Python, ie using Entries. If PowerShell is not intended to be used with version 8, which is understandable, add it into documentation, please.

Thanks!

texroemer commented 8 months ago

I added code to the PS cmdlet to handle both iDRAC 8 and iDRAC 9, cmdlet posted to GitHub and PSGallery. Also note that for iDRAC 8 arguments get date range or specific group entries are not supported. I added a check in the cmdlet to error out gracefully for these arguments.

Thanks Tex