BMC_IP=10.0.1.123
BMC_USER=ADMIN
BMC_PASS=ADMIN
# Install redfishtool (CLI)
git clone https://github.com/DMTF/Redfishtool.git
cd Redfishtool/
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Systems -F
for BMC_IP in 10.0.1.11 10.0.1.12 10.0.1.13; do
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Systems -F | jq .SerialNumber
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Systems -F | jq .IndicatorLED
done
BMC_HOSTS=$(grep 10.52 /var/lib/misc/dnsmasq.leases | cut -d" " -f3 | sort)
for BMC_HOST in ${BMC_HOSTS}; do
echo ${BMC_HOST}
curl --connect-timeout 1 -s https://${BMC_HOST}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq -r .IndicatorLED
echo
done
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Chassis list
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Chassis -I 1
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Chassis -I HA-RAID.0.StorageEnclosure.0
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Systems -F | jq .UUID
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Systems -F | jq .IndicatorLED
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Chassis -I 1 setIndicatorLed Off
BMC_IP=$(dig +short node1.example.com)
unset https_proxy
# gret firmware versions
# BMC
python3 redfishtool.py -r ${BMC_HOST} -u ${BMC_USER} -p ${BMC_PASS} Managers -F | jq .FirmwareVersion
curl -s https://${BMC_IP}/redfish/v1/Managers/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq .FirmwareVersion
# BIOS
python3 redfishtool.py -r ${BMC_HOST} -u ${BMC_USER} -p ${BMC_PASS} Systems -F | jq .BiosVersion
curl -s https://${BMC_IP}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq .BiosVersion
# System manufactor
curl -s https://${BMC_IP}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq .Manufacturer
# System model
curl -s https://${BMC_IP}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq .PartNumber
# get serial
curl -s https://${BMC_IP}/redfish/v1/Systems/1 -k -u ${BMC_USER}:${BMC_PASS} | jq .UUID
curl -s https://${BMC_IP}/redfish/v1/Systems/1 -k -u ${BMC_USER}:${BMC_PASS} | jq .SerialNumber
curl -s https://${BMC_IP}/redfish/v1/Chassis/1 -k -u ${BMC_USER}:${BMC_PASS} | jq .SerialNumber
# get CPU information
curl -s https://${BMC_IP}/redfish/v1/Systems/1/Processors/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq -r .Model | awk '{$1=$1};1'
curl -s https://${BMC_IP}/redfish/v1/Systems/1/Processors/1 -k -u ${BMC_USER}:${BMC_PASS} | jq .TotalCores
curl -s https://${BMC_IP}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq .ProcessorSummary.Count
# ram
curl -s https://${BMC_IP}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq .MemorySummary.TotalSystemMemoryGiB
curl -k -u ${BMC_USER}:${BMC_PASS} -s https://${BMC_IP}/redfish/v1/Systems/1/Memory | jq ".Members | length"
# get BMC settings
curl -s https://${BMC_IP}/redfish/v1/Managers/1/EthernetInterfaces/2 -k -u ${BMC_USER}:${BMC_PASS} | jq .IPv4Addresses[0].Address
# get Health
curl -s https://${BMC_IP}/redfish/v1/Chassis/1 -k -u ${BMC_USER}:${BMC_PASS} | jq .Status.Health
# get IndicatorLED
curl -s https://${BMC_IP}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq -r .IndicatorLED
# fan mode
curl -s https://${BMC_IP}//redfish/v1/Managers/1/FanMode -k -u ${BMC_USER}:${BMC_PASS} | jq .Mode
# temperature
curl -s https://${BMC_IP}/redfish/v1/Chassis/1/Thermal -k -u ${BMC_USER}:${BMC_PASS} | jq '.Temperatures[] | select(.Name == "System Temp") .ReadingCelsius'
# GPU
curl -s https://${BMC_NODE}/redfish/v1/Chassis/1/PCIeDevices/GPU1/ -k -u ${BMC_USER}:${BMC_PASS} | jq -r .Model
# storage
curl -s https://${BMC_IP}/redfish/v1/Systems/1/SimpleStorage/1 -k -u ${BMC_USER}:${BMC_PASS} | jq .Devices[].Model
# raid
curl -s https://${BMC_IP}/redfish/v1/Chassis/HA-RAID.0.StorageEnclosure.0 -k -u ${BMC_USER}:${BMC_PASS} | python -m json.tool
curl -s https://${BMC_IP}/redfish/v1/Chassis/HA-RAID.0.StorageEnclosure.0/Drives/Disk.Bay.0 -k -u ${BMC_USER}:${BMC_PASS} | python -m json.tool
curl -k https://BMC_IP/registries/BiosAttributeRegistry.v1_0_0.json | python -m json.tool
curl -s https://BMC_IP/redfish/v1/Chassis/1/Thermal -k -u ADMIN:ADMIN | python -m json.tool
# power control
curl -s https://${BMC_IP}/redfish/v1/Chassis/1/Power/ -k -u ${BMC_USER}:${BMC_PASS} | jq -r ".PowerControl[].Status.State"
# power consumption
curl -s https://${BMC_IP}/redfish/v1/Chassis/1/Power/ -k -u ${BMC_USER}:${BMC_PASS} | jq .PowerControl[].PowerConsumedWatts
curl -s https://${BMC_IP}/redfish/v1/Chassis/1/Power/ -k -u ${BMC_USER}:${BMC_PASS} | jq .PowerControl[].PowerMetrics.AverageConsumedWattsGet NIC information
# get BMC mac
curl -s https://${BMC_IP}/redfish/v1/Managers/1/EthernetInterfaces/1 -k -u ${BMC_USER}:${BMC_PASS} | jq -r '.MACAddress | ascii_downcase'
# get NIC(s) MAC addresses
for NIC_ID in {1..4}; do
curl -s https://${BMC_IP}/redfish/v1/Systems/1/EthernetInterfaces/${NIC_ID} -k -u ${BMC_USER}:${BMC_PASS} | jq -r '.MACAddress | ascii_downcase'
done
SuperMicro
https://www.supermicro.com/manuals/other/RedfishRefGuide.pdf
https://www.supermicro.com/manuals/other/redfish-ref-guide-html/Content/general-content/available-apis.htm
HPE Cloudline get parameter with redfish
https://servermanagementportal.ext.hpe.com/docs/redfishservices/ilos/ilo5/ilo5_295/ilo5_serviceroot_resourcedefns295/
https://hewlettpackard.github.io/ilo-rest-api-docs/ilo5/#uefi-bios-standard-redfish-support
https://support.hpe.com/hpsc/doc/public/display?docId=c04423967
# Manufacturer
curl -s https://${BMC_IP}/redfish/v1/Systems/Self -k -u ${BMC_USER}:${BMC_PASS} | jq -r .Manufacturer
# Model
curl -s https://${BMC_IP}/redfish/v1/Systems/Self -k -u ${BMC_USER}:${BMC_PASS} | jq -r .Model
# Serial
curl -s https://${BMC_IP}/redfish/v1/Systems/Self -k -u ${BMC_USER}:${BMC_PASS} | jq -r .SerialNumber
# UUID
curl -s https://${BMC_IP}/redfish/v1/Systems/Self -k -u ${BMC_USER}:${BMC_PASS} | jq -r .UUID
# Indicatior LED
curl -s -k -u ${BMC_USER}:${BMC_PASS} https://${BMC_IP}/redfish/v1/Chassis/Self | jq -r .IndicatorLED
# CPU
curl -s https://${BMC_IP}/redfish/v1/Systems/Self -k -u ${BMC_USER}:${BMC_PASS} | jq -r .ProcessorSummary.Model
curl -s https://${BMC_IP}/redfish/v1/Systems/Self -k -u ${BMC_USER}:${BMC_PASS} | jq -r .ProcessorSummary.Count
# Memory
for DIMM_ID in {0..24}; do
DIMM_CAPACITY=$(curl -s https://${BMC_IP}/redfish/v1/Systems/Self/Memory/DevType2_DIMM${DIMM_ID} -k -u ${BMC_USER}:${BMC_PASS} | jq -r ".CapacityMiB | select( . != null)")
if [ "${DIMM_CAPACITY}" ]; then
if [ ${DIMM_CAPACITY} -gt 0 ]; then
echo ${DIMM_CAPACITY}
fi
fi
done
# Disks
for DEVICE_ID in {0..16}; do
for PORT_ID in {0..16}; do
DISK_MODEL=$(curl -s https://${BMC_IP}/redfish/v1/Systems/Self/Storage/1/Drives/SATA_Device${DEVICE_ID}_Port${PORT_ID} -k -u ${BMC_USER}:${BMC_PASS} | jq -r ".Model | select( . != null)")
if [ "${DISK_MODEL}" ]; then
echo ${DISK_MODEL}
fi
done
done
# get MAC
curl -k -s -u ${BMC_USER}:${BMC_PASS} https://${BMC_IP}/redfish/v1/Managers/Self/EthernetInterfaces/eth0 | jq -r .MACAddress
# NICs
for NIC_ID in {0..8}; do
NIC_MAC=$(curl -s https://${BMC_IP}/redfish/v1/Systems/Self/EthernetInterfaces/NicInterface${NIC_ID} -k -u ${BMC_USER}:${BMC_PASS} | jq -r ".MACAddress | select( . != null) | ascii_downcase")
if [ "${NIC_MAC}" ]; then
echo ${NIC_MAC}
fi
done
# BIOS settings
curl -s https://${BMC_IP}/redfish/v1/Systems/Self/Bios -k -u ${BMC_USER}:${BMC_PASS} | jq -r
sudo dpkg -i /home/pko/Downloads/ilorest-4.9.0.0-10_amd64.debpython-ilorest-library
pip install python-ilorest-library
git clone https://github.com/HewlettPackard/python-ilorest-library.git
cd python-ilorest-library/exampls
vi quickstart_redfish.py
python3 quickstart_redfish.py
# Redfishtool (redfish CLI)
https://github.com/DMTF/Redfishtool
# boot to bios
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Systems setBootOverride Once BiosSetup
python3 redfishtool.py -r ${BMC_IP} -u ${BMC_USER} -p ${BMC_PASS} Systems reset ForceRestartManage Redfish with Curl
curl -d '{
"Boot": {
"BootSourceOverrideEnabled": "Once",
"BootSourceOverrideTarget": "Pxe"
}
}' \
-H "Content-Type: application/json" \
-X PATCH \
--insecure \
--silent \
https://${BMC_HOST}}/redfish/v1/Systems/1/
curl -sk -H "$token" -H "Content-Type: application/json" -X POST https://$1/redfish/v1/Systems/1/Actions/ComputerSystem.Reset/ -d '{"ResetType": "ForceRestart"}'
curl -sk -H "$token" -H "Content-Type: application/json" -X POST https://$1/redfish/v1/Systems/1/Actions/ComputerSystem.Reset/ -d '{"ResetType": "ForceOff"}'
curl -sk -H "$token" -H "Content-Type: application/json" -X POST https://$1/redfish/v1/Systems/1/Actions/ComputerSystem.Reset/ -d '{"ResetType": "On"}'Get server data
for BMC_IP in $(cat /var/lib/misc/dnsmasq.leases | grep 10.0.98 | cut -d" " -f3); do
echo ${BMC_IP}
curl -s https://${BMC_IP}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq -r .Manufacturer
curl -s https://${BMC_IP}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq -r .PartNumber
curl -s https://${BMC_IP}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq -r .IndicatorLED
curl -s https://${BMC_IP}/redfish/v1/Systems/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq .BiosVersion
curl -s https://${BMC_IP}/redfish/v1/Managers/1/ -k -u ${BMC_USER}:${BMC_PASS} | jq .FirmwareVersion
echo
doneVirtualMedia / ISO
# mount ISO image
curl https://${BMC_HOST}/redfish/v1/Managers/1/VirtualMedia/CD1/Actions/VirtualMedia.InsertMedia \
-u ${BMC_USER}:${BMC_PASS} \
--insecure \
--silent \
-X POST \
-H "Content-Type: application/json" \
-d "{
\"Image\": \"http://${DL_SRV_IP}/iso/${ISO}\"
}"
# get VirtualMedia state
curl -k -u ${BMC_USER}:${BMC_PASS} -s https://${BMC_IP}/redfish/v1/Managers/1/VirtualMedia/CD1 | jq
# boot from ISO (use "UsbCd" on Supermicro else "Cd")
curl https://${BMC_HOST}/redfish/v1/Systems/1/ \
-u ${BMC_USER}:${BMC_PASS} \
--insecure \
--silent \
-X PATCH \
-H "Content-Type: application/json" \
-d '{
"Boot":{
"BootSourceOverrideEnabled":"Once",
"BootSourceOverrideMode":"UEFI",
"BootSourceOverrideTarget": "UsbCd"
}
}'
# boot from HDD
curl https://${BMC_HOST}/redfish/v1/Systems/1/ \
-u ${BMC_USER}:${BMC_PASS} \
--insecure \
--silent \
-X PATCH \
-H "Content-Type: application/json" \
-d '{
"Boot":{
"BootSourceOverrideEnabled":"Continuous",
"BootSourceOverrideMode":"UEFI",
"BootSourceOverrideTarget": "Hdd"
}
}'
# get boot state
curl --silent -k --user ${BMC_USER}:${BMC_PASS} https://${BMC_HOST}/redfish/v1/Systems/1/ | jq '.Boot'
# reboot server
curl https://${BMC_HOST}/redfish/v1/Systems/1/Actions/ComputerSystem.Reset \
-u ${BMC_USER}:${BMC_PASS} \
--insecure \
--silent \
-H "Content-Type: application/json" \
-X POST \
-d '{
"ResetType": "GracefulRestart"
}'
Redfish Interface Emulator
https://github.com/DMTF/Redfish-Interface-Emulator
git clone https://github.com/DMTF/Redfish-Interface-Emulator.git
cd Redfish-Interface-Emulator
pip install -r requirements.txt
python emulator.py -debug
REST API browser
https://chromewebstore.google.com/detail/talend-api-tester-free-ed/aejoelaoggembcahagimdiliamlcdmfm
Links
https://www.thomas-krenn.com/de/wiki/Redfish
https://github.com/DMTF/python-redfish-library
https://docs.linuxfabrik.ch/topics/redfish.html