Image by way of Gerd Altmann from Pixabay
While discussions of the cloud dominate the trendy IT panorama, just about each machine administrator can fondly keep in mind racking and configuring bodily servers. Hardware configuration has classically been fraught with error-prone handbook steps. Attempts to script the bodily provisioning procedure steadily concerned parsing the output of instructions that had been antagonistic to text-based processing. Manufacturer gear to engage with a machine’s baseboard control controller (BMC) generally published difficult output that did not lend itself to automation.
The Redfish usual fromย DMTF goals to modify that have. Redfish permits operators to engage with programs via usual internet services and products, like HTTP and REST APIs. This manner makes it considerably more uncomplicated to interrogate and configure bodily programs. Instead of parsing output from a device this is prone to alternate between variations, directors can write powerful automation to engage with HTTP-based APIs of their language of selection.
This article introduces the fundamentals of the usage of Redfish. While Redfish brings standardization to many configuration parameters, seller implementations nonetheless range. This article walks you via a vendor-agnostic state of affairs the usage of the Redfish Mockup Server so as to perceive the underlying ideas for interacting with a Redfish machine.
[ Download 5 steps to automate your business. ]
Run the Redfish Mockup Server
You do not want bodily {hardware} to start experimenting with Redfish. The DMTF maintains a Redfish Mockup Server that you’ll run to achieve revel in with the Redfish API. While you will have to at all times verify that your automation works in opposition to the bodily machines you plan to control, the mockup server supplies an effective way to get began with the ideas.
First, clone the Redfish repository and set up the vital dependencies. I set up them in a digital surroundings to keep away from cluttering my machine Python:
# Clone the repository
$ git clone
# Create and turn on a digital surroundings
$ python3 -m venv venv
$ supply venv/bin/turn on
# Install dependencies
(venv) $ cd Redfish-Mockup-Server
(venv) $ python3 -m pip set up -r necessities.txt
Next, get started the mockup server by way of operating the redfishMockupServer.py
software. The server begins and listens on 127.0.0.1:8000
by way of default:
(venv) $ python3 redfishMockupServer.py
Redfish Mockup Server, model 1.2.2
Hostname: 127.0.0.1
Port: 8000
Mockup listing trail specified: public-rackmount1
Response time: 0 seconds
Serving Mockup in absolute trail: /house/acritelli/Desktop/ac/Desktop/enable_sysadmin/redfish/Redfish-Mockup-Server/public-rackmount1
Serving Redfish mockup on port: 8000
operating Server...
Finally, verify that the server is practical by way of sending an HTTP request to localhost:8000/redfish
:
$ curl localhost:8000/redfish
"v1": "/redfish/v1"
$
Gather knowledge
Redfish is a real REST API that implements Hypermedia because the Engine of Application State (HATEOAS). You can discover the API, starting on the rootย endpoint and following hyperlinks to different assets. This is a formidable idea, as you do not want any prior wisdom of Redfish or its knowledge style to discover the assets uncovered by way of the API.
Start by way of querying the /redfish/v1/Systems
endpoint to acquire details about the programs controlled by way of this Redfish example. Consult the introductory documentation for more info in regards to the varieties of high-level assets uncovered by way of Redfish. You can see that theย Members
listing accommodates a hyperlink to a selected machine with a machine ID of 437XR1138R2
:
$ curl -s localhost:8000/redfish/v1/Systems
"@odata.id": "/redfish/v1/Systems",
"@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
"Members": [
"@odata.id": "/redfish/v1/Systems/437XR1138R2"
],
"[email protected]": 1,
"Name": "Computer System Collection"
$
Next, apply the hyperlink for the machine to acquire details about it. Below, I go the output to jq
to seek out details about the processors within the machine:
$ curl -s localhost:8000/redfish/v1/Systems/437XR1138R2 | jq .Processors
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Processors"
You can apply the Processors hyperlink to acquire details about the entire processors within the machine. Just like with the programs endpoint, the Members
listing supplies an inventory of processors on this machine:
$ curl -s localhost:8000/redfish/v1/Systems/437XR1138R2/Processors
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Processors",
"@odata.type": "#ProcessorCollection.ProcessorCollection",
"Members": [
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Processors/CPU1"
,
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Processors/CPU2"
,
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Processors/FPGA1"
],
"[email protected]": 3,
"Name": "Processors Collection"
$
Finally, you’ll apply the hyperlink to seek out details about CPU1
. Below, I go the output to jq
to seek out details about the working pace for this actual processor style:
$ curl -s localhost:8000/redfish/v1/Systems/437XR1138R2/Processors/CPU1
| jq .OperatingSpeedRangeMHz
"AllowableMax": 3700,
"AllowableMin": 1200,
"ControlMode": "Automatic",
"DataSourceUri": "/redfish/v1/Chassis/1U/Controls/CPU1Freq",
"SettingMax": 2400,
"SettingMin": 2000
Interrogating a machine and following hyperlinks is a formidable technique to acquire knowledge programmatically. Sysadmins steadily wish to acquire knowledge about programs for asset monitoring and capability making plans functions. Redfish supplies a easy interface to assemble this data.
Modify knowledge
Querying details about a machine is an effective way to get began with Redfish and this is a nice candidate for automation in maximum environments. However, Redfish is not a read-only API. You too can use Redfish to configure information about faraway programs. Building on its use of usual internet ideas, Redfish leverages HTTP strategies reminiscent of PATCH
, PUT
, and POST
to change the settings of a faraway machine.
To reveal this, I can simulate the stairs desirous about relocating a bodily server from one rack to every other. First, download details about the bodily location of the 1U chassis related to the program:
$ curl -s localhost:8000/redfish/v1/Chassis/1U
| jq .Location.Placement
"Rack": "WEB43",
"RackOffset": 12,
"RackOffsetUnits": "EIA_310",
"Row": "North"
The present placement knowledge displays this chassis within the WEB43
rack. Suppose this server was once moved to the DB06
rack and and also you will have to replace its placement knowledge. Send a PATCH
request to change the bodily location of the host. The PATCH
request accommodates a JSON payload with up to date location knowledge, as proven underneath:
# JSON Update payload
$ cat location_update.json
"Location":
"Placement":
"Rack": "DB06",
"RackOffset": 8,
"RackOffsetUnits": "EIA_310",
"Row": "North"
# Send the PATCH request
$ curl -s -X PATCH -d @./location_update.json
-H 'Content-Type: software/json'
localhost:8000/redfish/v1/Chassis/1U
Finally, verify that the replace was once a hit by way of querying the position knowledge:
$ curl -s localhost:8000/redfish/v1/Chassis/1U
| jq .Location.Placement
"Rack": "DB06",
"RackOffset": 8,
"RackOffsetUnits": "EIA_310",
"Row": "North"
The preliminary configuration of bodily programs is an error-prone process in lots of environments. Automation would possibly cut back a few of these mistakes and configure programs persistently in keeping with organizational absolute best practices. Redfish lets you enact this configuration via a typical, programmatic interface.
[ Download now: 6 ways to promote organization-wide IT automation. ]
Perform movements
Many Redfish assets additionally divulge movements you’ll execute in opposition to them. For instance, you could wish to reboot a machine or connect an ISO to the digital media console. Redfish exposes a lot of these one-time movements. Following the RESTful idea of HATEOAS, you’ll uncover the movements to be had for Redfish assets and the accepted values for those duties.
For instance, the person programs within the Redfish mockup server divulge a machine reset motion, as noticed underneath.
Start by way of querying the person machine (437XR1138R2
) within the mockup server and evaluate the Actions
object:
$ curl -s localhost:8000/redfish/v1/Systems/437XR1138R2
| jq .Actions
"#ComputerSystem.Reset":
"[email protected]": [
"On",
"ForceOff",
"GracefulShutdown",
"GracefulRestart",
"ForceRestart",
"Nmi",
"ForceOn",
"PushPowerButton"
],
"target": "/redfish/v1/Systems/437XR1138R2/Actions/ComputerSystem.Reset"
,
"Oem":
"#Contoso.Reset":
"target": "/redfish/v1/Systems/437XR1138R2/Oem/Contoso/Actions/Contoso.Reset"
The Actions
object defines quite a lot of particular person movements that may be finished in opposition to the machine, together with the objective uniform useful resource identifier (URI), and allowed movements for every. Execute the motion by way of sending a POST
request with a suitable price for the ResetType
, as proven underneath:ย
$ curl -v -X POST -H 'Content-Type: software/json'
localhost:8000/redfish/v1/Systems/437XR1138R2/Actions/ComputerSystem.Reset
-d '"ResetType":"ForceRestart"'
No motion is in fact taken because the present endpoint is a ridicule server. However, an actual machine would reboot. Numerous movements are to be had for various assets, relying at the implementation. Additionally, producers would possibly put into effect their very own movements. Since Redfish is a real REST API, you’ll simply discover and evaluate the movements to be had on your {hardware}.
[ Looking for more on system automation? Get started with The Automated Enterprise, a complimentary book from Red Hat. ]
Wrap up
Any sysadmin with revel in configuring bodily {hardware} has felt the disappointment of parsing difficult output from vendor-specific command line interface (CLI) gear. This issue has incessantly stood in the way in which of establishing powerful automation for provisioning and managing bodily programs. Redfish introduces a typical strategy to programmatically uncover and interface with bodily programs.
In this text, you put up the Redfish Mockup Server and discovered learn how to question, configure, and execute movements in opposition to faraway programs. The Redfish API may be very tough, and I urge you to analyze the choices to be had to your bodily programs.
No Comment! Be the first one.