Copyright 2016-2018 DMTF. All rights reserved.
# redfishtool
## About
***redfishtool*** is a commandline tool that implements the client side of the Redfish RESTful API for Data Center Hardware Management.
**Redfish** is the new RESTful API for hardware management defined by the DMTF Scalable Platform Management Forum (SPMF). It provides a modern, secure, multi-node, extendable interface for doing hardware management. The initial release included hardware inventory, server power-on/off/reset, reading power draw, setting power limits, reading sensors such as fans, read/write of ID LEDs, asset tags, and went beyond IPMI in functionality to include inventory of processors, storage, Ethernet controllers, and total memory. New Redfish extensions have now been added to the spec and include firmware update, BIOS config, memory inventory, direct attached storage control, and the list grows.
***redfishtool*** makes it simple to use the Redfish API from a BASH script or interactively from a client command shell.
While other generic HTTP clients such as Linux curl can send and receive Redfish requests, ***redfishtool*** goes well beyond these generic HTTP clients by automatically handling many of the hypermedia and Redfish-specific protocol aspects of the Redfish API that require a client to often execute multiple queries to a redfish service to walk the hypermedia links from the redfish root down to the detailed URI of a specific resource (eg Processor-2 of Blade-4 in a computer blade system). Specifically, redfishtool provides the following functions over curl:
* implements Redfish Session Authentication as well as HTTP Basic Auth
* walks the Redfish schema following strict interoperpbility processors...] to find find the targeted instance based on Id, UUID, URL or other attributes
* handles GETs for collections that are returned in multiple pieces--requiring client to read in a loop until the full collection is returned
* handles ETag and If-Match headers when PATCHing a resource to write properties
* implements many common set or action operations with simple commandline syntax (eg server reset, setting LEDs, assetTag, powerLimits, etc)
* negotiates the latest redfish protocol version between client and service (demonstrating the proper way to do this)
* can read specific properties of a resource, or expand collections to include all members of the collection expanded
* supports adding and deleting users, and common Redfish account service operations
* For debug, provides multiple levels of verbose output to add descriptive headers, and show what HTTP requests are being executed
* For debug, includes multiple levels of status display showing HTTP status codes and headers returned and sent
* For easy parsing, outputs all responses in JSON format unless verbose or status debug options were specified
## Why redfishtool?
1. ***redfishtool*** was originally written during the development of the Redfish specification to help find ambiguities in the spec.
1. ***redfishtool*** is now also being used to test inter-operability between redfish service implementations.
1. In addition, ***redfishtool*** provides an example implementation for how a client can execute common server management functions like inventory; power-on/off/reset; setting power limits, indicator LEDs, and AssetTags, and searching a multi-node redfish service to find a specific node (with specific UUID, redfish Id, etc). redfishtool follows strict rules of interoperability. To support this goal, liberal comments are added throughout code to explain why each step is being executed.
1. As described above, it makes it easy to use the Redfish API from a BASH script, or as an easy-to-use interactive CLI -- but WITHOUIT creating a 'new API'. All (rather most) of the responses from ***redfishtool*** are Redfish-defined responses. The properties and resources are defined in the redfish spec. ***redfishtool*** is just a tool to access the Redfish API-not a new interface itself.
* The execption is that a 'list' operation was added for all collections to display the key properties for each of the members--rather than just the URIs to the members.
## Installation
`redfishtool` can be installed via [pip](https://pip.pypa.io/en/stable/).
```
pip install redfishtool
```
## Requirements
***redfishtool*** is based on Python 3 and the client system is required to have the Python framework installed before the tool can be installed and executed on the system.
If cloning the tool from Github, as opposed to performing the installation via pip, the following packages are required to be installed and accessible from the python environment:
* requests - https://github.com/kennethreitz/requests
You may install the required packages by running:
pip install -r requirements.txt
## Usage
***python*** ***redfishtool*** [ ***Options*** ] [ ***SubCommands*** ] [ ***Operation*** ] [ ***OtherArgs*** ]
* ***redfishtool*** is a python3.4+ program. It uses the python3 "requests" lib for sending HTTP requests, and a host of other standard libs in python3.4+
* The ***redfishtool*** option/optarg parsing strictly follows the well established linux/GNU getopt syntax where arguments and options can be specified in any order, and both short (eg -r <host>) or long (--rhost=<host>) syntax is supported.
* ***options*** are used to pass usernames, passwords, Host:port, authentication options, verbose/status flags, and also to specify how to search to find specific collection members (-I <Id>, -a (all), -M <prop>:<val> ).
* ***subCommands*** indicate the general area of the API (following ipmitool convention), and align with Redfish navigation property names like "Chassis", "Systems", "AccountService", etc.
* ***Operations*** are specify an action or operation you want to perform like S`ystems setBootOverride` ..., or `Systems reset`.
* ***OtherArgs*** are any other arguments after the Operation that are sometimes required--like: `Systems <setBootOverride> <enableValue>` <targetValue>`
### Common OPTIONS:
-V, --version -- show redfishtool version, and exit
-h, --help -- show Usage, Options, and list of subCommands, and exit
-v, --verbose -- verbose level, can repeat up to 5 times for more verbose output
-v(header), -vv(+addl info), -vvv(Request trace), -vvvv(+subCmd dbg), -vvvvv(max dbg)
-s, --status -- status level, can repeat up to 5 times for more status output
-s(http_status),
-ss(+r.url, +r.elapsed executionTime ),
-sss(+request hdrs,data,authType, +response status_code, +response executionTime,
+login auth token/sessId/sessUri)
-ssss(+response headers), -sssss(+response data
-u <user>, --user=<usernm> -- username used for remote redfish authentication
-p <passwd>, --password=<passwd> -- password used for remote redfish authentication
-r <rhost>, --rhost=<rhost> -- remote redfish service hostname or IP:port
-t <token>, --token=<token> -- redfish auth session token-for sessions across multiple calls
-q, --quiet -- quiet mode--suppress error, warning, and diagnostic messages
-c <cfgFile>,--config=<cfgFile> -- read options (including credentials) from file <cfgFile>
-T <timeout>,--Timeout=<timeout> -- timeout in seconds for each http request. Default=10
-P <property>, --Prop=<property> -- return only the specified property. Applies only to all "get" operations
-E, --Entries -- Fetch the Logs entries. Applies to Logs sub-command of Systems, Chassis and Managers
###### Options used by "raw" subcommand:
-d <data> --data=<data> -- the http request "data" to send on PATCH,POST,or PUT requests
######