keepcalculator

06 Numbers and Powers

BMC Server Management via API: How It Works

Card No. 06·68087 · Updated · Standard formula, shown below

Yes, BMC server management via API is possible and widely used. BMC (Baseboard Management Controller) is a dedicated microcontroller on servers that provides out-of-band management, and it exposes a RESTful API (typically Redfish) that allows you to query hardware status, control power, and configure settings programmatically. This article explains how the API works, what you can do with it, and how to get started.

What Is BMC and Why Use an API?

Every modern server has a BMC, a small computer-on-a-chip that runs independently of the main CPU and operating system. It monitors temperature, fan speed, power supply health, and allows remote power on/off, even if the OS is down. Traditionally, you interact with the BMC through a web interface or CLI (like IPMI). An API simply exposes these same functions as structured HTTP requests, allowing automation, integration with monitoring tools, and scripted management across many servers.

Using the API is beneficial because it is:

  • Automation-friendly: You can write scripts to check health, apply updates, or power-cycle machines without manual steps.
  • Standardized: The Redfish API is an industry standard (DMTF), so the same code can work across different vendors (Dell iDRAC, HPE iLO, Supermicro, etc.) with minor adjustments.
  • Secure: API calls use HTTPS and require authentication, typically with username/password or tokens.
  • Scalable: You can manage hundreds of servers from a single script, rather than clicking through each web UI.

How the BMC API Works: Redfish and IPMI

The modern standard for BMC APIs is Redfish, a RESTful API that uses JSON and HTTPS. Redfish is designed to be easy for programmers: you send HTTP GET, POST, PATCH, and DELETE requests to specific endpoints (URLs) to read or modify resources. For example, to get system health, you might send:

GET https://bmc-ip/redfish/v1/Systems/1

This returns a JSON object with properties like PowerState, Status, and ProcessorSummary. To power on the server, you would send a POST to /redfish/v1/Systems/1/Actions/ComputerSystem.Reset with a body like {"ResetType": "On"}.

Older BMCs may still support IPMI, which is a binary protocol over port 623. While IPMI is still used, Redfish is the recommended approach for new integrations because it is more secure (uses HTTPS, not plaintext) and easier to work with in modern programming languages.

What Can You Do with the BMC API?

The API gives you full control over the BMC’s capabilities. Typical operations include:

  • Power management: Turn on/off, reset, and check power state.
  • Sensor data: Read temperature, fan speed, voltage, and power consumption.
  • Firmware updates: Upload and apply BMC or BIOS firmware (often requires a multi-step process).
  • Remote console: Start a virtual KVM (keyboard/video/mouse) session (this is often done via a separate protocol, but the API can initiate it).
  • User management: Create/modify BMC users and roles.
  • Network configuration: Change IP, DNS, and other network settings.
  • Boot settings: Set the next boot device (e.g., PXE, disk, CD-ROM).
  • Event log: Retrieve system event logs (SEL) to diagnose crashes or errors.

How to Authenticate to the BMC API

Redfish supports two main authentication methods:

  1. Basic Authentication: Send the username and password as an HTTP header (Base64 encoded). This is simple but should only be used over HTTPS, as credentials are sent in plaintext if not encrypted.
  2. Session Authentication: First, POST to /redfish/v1/SessionService/Sessions with your credentials to get a session token. Then, include that token in the X-Auth-Token header for subsequent requests. This is more secure and recommended for long-running scripts.

Example of creating a session with curl:

curl -X POST https://bmc-ip/redfish/v1/SessionService/Sessions \
  -H "Content-Type: application/json" \
  -d '{"UserName":"admin","Password":"secret"}'

The response will include a token that you then use in the X-Auth-Token header.

Common Use Cases and Real-World Examples

Here are a few scenarios where the BMC API shines:

  • Automated health checks: A script that queries all servers’ sensor data and alerts if any temperature exceeds a threshold.
  • Auto-recovery: If a server becomes unresponsive, a monitoring system can call the API to power-cycle it.
  • Provisioning: During OS install, the BMC API can set boot order to PXE and then power on.
  • Inventory tracking: Collect serial numbers, firmware versions, and hardware details from all servers into a CMDB.

For example, to get the power state of a server using Python and the requests library:

import requests
url = "https://bmc-ip/redfish/v1/Systems/1"
headers = {"X-Auth-Token": "your-token"}
resp = requests.get(url, headers=headers, verify=False)  # verify=False for self-signed certs
print(resp.json()["PowerState"])

Choosing the Right API Approach

When deciding how to use the BMC API, consider the following:

  • Standard vs. Vendor-specific: Redfish is standard, but some vendors add proprietary extensions. If you need a specific feature, check the vendor’s Redfish documentation.
  • Security: Always use HTTPS and strong authentication. Disable plaintext IPMI if you don’t need it.
  • Rate limits: Some BMCs have limited resources; don’t hammer the API with too many requests per second.
  • Error handling: BMCs can be slow or return errors during firmware updates; build retry logic into your scripts.
  • Testing: Test on a lab server first, as a mistake can cause a production outage.

Common Problems and How to Avoid Them

Here are typical pitfalls when working with BMC APIs:

  • Self-signed certificates: Most BMCs use self-signed HTTPS certificates. Your script will need to bypass certificate validation (insecure) or import the certificate. This is a security trade-off.
  • Authentication issues: Some BMCs lock out accounts after multiple failed attempts. Use a dedicated API user with limited privileges.
  • Timeout: BMCs can be slow to respond, especially during firmware updates. Set generous timeouts in your HTTP client.
  • Incomplete JSON: Some BMCs return non-standard JSON or omit fields. Write defensive code that checks for key existence.
  • Firmware quirks: Different firmware versions may have different Redfish schemas. Always test against your exact BMC version.

Costs and Alternatives

Using the BMC API itself is free—it’s built into the server. However, there are indirect costs: you may need to purchase licenses for advanced features (e.g., remote console on some vendors), and you’ll need to invest time in development and maintenance. Alternatives to direct API usage include:

  • Vendor management tools: Dell OpenManage, HPE OneView, etc., which wrap the API in a user-friendly interface.
  • Open-source tools: Projects like OpenStack Ironic or Ansible modules that abstract the BMC API.
  • IPMI commands: Using ipmitool for quick, one-off tasks, but it’s less scriptable than REST.

Frequently Asked Questions

Is the BMC API the same as IPMI?

No, they are different. IPMI is a binary protocol over UDP port 623, while Redfish is a RESTful API over HTTPS. Redfish is newer and recommended for new integrations, but IPMI is still widely supported on older hardware.

Do I need to enable anything on the BMC to use the API?

Yes, the BMC must have a network connection (usually a dedicated management port) and you need valid credentials. Some BMCs have a web interface that must be enabled to access the API, but most have it on by default.

Can I use the BMC API to update BIOS firmware?

Yes, many BMCs allow firmware updates via Redfish. The process typically involves uploading the firmware image to the BMC and then triggering an update. It’s a multi-step operation that requires careful handling to avoid bricking the system.

What if my server’s BMC doesn’t support Redfish?

If your server is older and only supports IPMI, you can still automate it using IPMI tools, but you’ll miss out on the ease of REST. Some vendors offer a bridge that converts IPMI to Redfish, but it’s not universal.

Is it safe to expose the BMC API to the internet?

No, it’s not safe. The BMC is a high-value target for attackers. Always keep it on a separate management VLAN, use strong passwords, and consider using a VPN or jump host to access it.

How can I test the API without risking my production server?

Use a lab server or a virtual BMC (some vendors provide virtual appliances). You can also use Redfish mockups provided by the DMTF to test your code.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →