dell / iDRAC-Redfish-Scripting

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

Can we use redfish api to execute a command/get output remotely on the idrac console. iDRAC Firmware Version 5.10.30.00 #238

Closed sivakumarv47 closed 1 year ago

sivakumarv47 commented 1 year ago

I did not find any api call in the documentation https://developer.dell.com/apis/2978/versions/5.xx/docs/0WhatsNew.md

texroemer commented 1 year ago

Hi @sivakumarv47

Can i get more details about your ask? What do you mean by iDRAC console? Are you asking if you can make a Redfish GET request from a client system to the iDRAC?

Thanks Tex

sivakumarv47 commented 1 year ago

Hi Tex, I am asking can we use redfish api to execute a command or get output on the virtual console of the server.

Thanks Siva

texroemer commented 1 year ago

Ok, so from the virtual console or local operating system, this is no local Redfish support like local RACADM where with local RACADM you don't need to pass in iDRAC IP and creds to run local RACADM commands. If running Redfish commands from within the OS, you can leverage either iDRAC IP or iDRAC USB-NIC IP.

See example below where i use iDRAC USB-NIC IP to run Redfish GET request from the OS.

image

image

Thanks Tex

sivakumarv47 commented 1 year ago

Thanks Tex for the answer. But i think there is a confusion in my question

I am asking is there any way from redfish api or any other automated way to execute command on the virtual console.

For E.g. ls -ltr command on virtual console and get the output Attaching the screenshot.

Thanks Siva

Screenshot 2023-01-31 at 9 33 45 PM Screenshot 2023-01-31 at 9 41 50 PM
texroemer commented 1 year ago

Thanks for the example, this clears up the ask. So this is not supported by iDRAC and Redfish. For automating you could SSH to linux OS IP and then run any command, capture the output to a variable or a file.

Examples:

Python code:

import subprocess

command_output = subprocess.run("ssh root@192.168.0.120 ls -la /nfs", shell=True) print(command_output)

Capture output to a file:

C:\Python310>ssh root@192.168.0.130 "ls -la /nfs" > output.txt root@192.168.0.130's password:

C:\Python310>type output.txt total 8388620 drwxrwxrwx 2 root root 4096 Jan 30 20:29 . drwxr-xr-x 20 root root 4096 Jan 30 14:27 .. -rw-r--r-- 1 root root 8589934592 Jan 30 20:29 data.img

sshnaidm commented 1 year ago

@texroemer wouldn't be SOL (serial-over-lan) useful here? Or it's only for output?

texroemer commented 1 year ago

Yes you can use SOL to run OS linux commands but you must first configure grub in the OS, configure iDRAC and BIOS settings.

  1. Add these 3 lines to /etc/default/grub file (I used RHEL 8.5 OS):

GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200n8" GRUB_TERMINAL=serial GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

  1. Then run "grub2-mkconfig -o /etc/grub2-efi.cfg" to compile the changes.

  2. Make iDRAC changes for IPMI and SOL:

  1. Make BIOS changes under Serial Communication:

From your client system, you can use the following two methods to start the SOL session to the OS:

  1. SSH to the iDRAC, then at the RACADM prompt type "connect com2"
  2. Run "ipmitool.exe -U -P -H -I lanplus sol activate"