Copyright 2017-2019 DMTF. All rights reserved.
libRedfish is a C client library that allows for Creation of Entities (POST), Read of Entities (GET), Update of Entities (PATCH), Deletion of Entities (DELETE), running Actions (POST), receiving events, and providing some basic query abilities.
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# yum install jansson libcurl readline
$ wget https://github.com/DMTF/libredfish/releases/download/1.2.0/libredfish-1.2.0-1.el7.x86_64.rpm
# rpm -ivh libredfish-1.2.0-1.el7.x86_64.rpm
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
# yum install jansson libcurl readline
$ wget https://github.com/DMTF/libredfish/releases/download/1.2.0/libredfish-1.2.0-1.el6.x86_64.rpm
# rpm -ivh libredfish-1.2.0-1.el6.x86_64.rpm
apt-get install libjansson4 libcurl4 libreadline7
#dpkg -i libredfish-1.2.0-1.x86_64.deb
Compile from source, see below.
libRedfish is based on C and the compiling system is required to have:
Run cmake.
libRedfish uses a query language based on XPath (https://www.w3.org/TR/1999/REC-xpath-19991116/). This library and query language essentially treat the entire Redfish Service like it was a single JSON document. In other words whenever it encounters an @odata.id it will retrieve the new document (if needed).
Expression | Description |
---|---|
nodename | Selects the JSON entity with the name "nodename" |
/ | Selects from the root node |
[index] | Selects the index number JSON entity from an array or object. For arrays, the index is 0-based. |
[last()] | Selects the last index number JSON entity from an array or object |
[nodename] | Selects all the elements from an array or object that contain a property named "nodename" |
[name=value] | Selects all the elements from an array or object where the property "name" is equal to "value" |
[name<value] | Selects all the elements from an array or object where the property "name" is less than "value" |
[name<=value] | Selects all the elements from an array or object where the property "name" is less than or equal to "value" |
[name>value] | Selects all the elements from an array or object where the property "name" is greater than "value" |
[name>=value] | Selects all the elements from an array or object where the property "name" is greater than or equal to "value" |
[name!=value] | Selects all the elements from an array or object where the property "name" does not equal "value" |
[*] | Selects all the elements from an array or object |
[node.child] | Selects all the elements from an array or object that contain a property named "node" which contains "child" |
Some examples:
#include <redfish.h>
#include <stdio.h>
int main(int argc, char** argv)
{
redfishService* service = createRedfishServiceEnumerator(argv[1], NULL, NULL, 0);
redfishPayload* payload = getPayloadByPath(service, argv[2]);
char* payloadStr = payloadToString(payload, true);
printf("Payload Value = %s\n", payloadStr);
free(payloadStr);
cleanupPayload(payload);
cleanupEnumerator(service);
}